OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 | 8 |
9 from environment import IsPreviewServer | 9 from environment import IsPreviewServer |
10 from extensions_paths import ( | 10 from extensions_paths import ( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 '%s/intro_tables.json' % JSON_TEMPLATES) | 83 '%s/intro_tables.json' % JSON_TEMPLATES) |
84 self._api_features = json_cache.GetFromFile(API_FEATURES) | 84 self._api_features = json_cache.GetFromFile(API_FEATURES) |
85 self._template_cache = template_cache | 85 self._template_cache = template_cache |
86 self._event_byname_function = event_byname_function | 86 self._event_byname_function = event_byname_function |
87 self._namespace = api_models.GetModel(api_name).Get() | 87 self._namespace = api_models.GetModel(api_name).Get() |
88 | 88 |
89 def _FormatDescription(self, description): | 89 def _FormatDescription(self, description): |
90 if self._disable_refs: | 90 if self._disable_refs: |
91 return description | 91 return description |
92 return self._ref_resolver.ResolveAllLinks(description, | 92 return self._ref_resolver.ResolveAllLinks(description, |
| 93 None, |
93 namespace=self._namespace.name) | 94 namespace=self._namespace.name) |
94 | 95 |
95 def _GetLink(self, link): | 96 def _GetLink(self, link): |
96 if self._disable_refs: | 97 if self._disable_refs: |
97 type_name = link.split('.', 1)[-1] | 98 type_name = link.split('.', 1)[-1] |
98 return { 'href': '#type-%s' % type_name, 'text': link, 'name': link } | 99 return { 'href': '#type-%s' % type_name, 'text': link, 'name': link } |
99 return self._ref_resolver.SafeGetLink(link, namespace=self._namespace.name) | 100 return self._ref_resolver.SafeGetLink(link, namespace=self._namespace.name) |
100 | 101 |
101 def ToDict(self): | 102 def ToDict(self): |
102 if self._namespace is None: | 103 if self._namespace is None: |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 # anything. Don't do it. | 556 # anything. Don't do it. |
556 if not IsPreviewServer(): | 557 if not IsPreviewServer(): |
557 handlebar_dict['samples'] = _LazySamplesGetter( | 558 handlebar_dict['samples'] = _LazySamplesGetter( |
558 handlebar_dict['name'], | 559 handlebar_dict['name'], |
559 self._samples) | 560 self._samples) |
560 return handlebar_dict | 561 return handlebar_dict |
561 | 562 |
562 def get(self, api_name, disable_refs=False): | 563 def get(self, api_name, disable_refs=False): |
563 return self._GenerateHandlebarContext( | 564 return self._GenerateHandlebarContext( |
564 self._get_schema_model(api_name, disable_refs)) | 565 self._get_schema_model(api_name, disable_refs)) |
OLD | NEW |