Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: chrome/common/extensions/docs/server2/template_data_source.py

Issue 12996003: Dynamically generate a heading for Extension Docs API pages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AvailabilityFinder Overhaul; Removing ConfigureFakeFetchers() calls Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 logging 5 import logging
6 import os 6 import os
7 7
8 from branch_utility import BranchUtility 8 from branch_utility import BranchUtility
9 import compiled_file_system as compiled_fs 9 import compiled_file_system as compiled_fs
10 from docs_server_utils import FormatKey 10 from docs_server_utils import FormatKey
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 self._public_template_path = public_template_path 104 self._public_template_path = public_template_path
105 self._private_template_path = private_template_path 105 self._private_template_path = private_template_path
106 self._static_resources = static_resources 106 self._static_resources = static_resources
107 107
108 def Render(self, template_name): 108 def Render(self, template_name):
109 """This method will render a template named |template_name|, fetching all 109 """This method will render a template named |template_name|, fetching all
110 the partial templates needed from |self._cache|. Partials are retrieved 110 the partial templates needed from |self._cache|. Partials are retrieved
111 from the TemplateDataSource with the |get| method. 111 from the TemplateDataSource with the |get| method.
112 """ 112 """
113 template = self.GetTemplate(self._public_template_path, template_name) 113 template = self.GetTemplate(self._public_template_path, template_name)
114 if not template: 114 if template is None:
115 return None 115 return None
116 # TODO error handling 116 # TODO error handling
117 render_data = template.render({ 117 render_data = template.render({
118 'api_list': self._api_list_data_source, 118 'api_list': self._api_list_data_source,
119 'apis': self._api_data_source, 119 'apis': self._api_data_source,
120 'branchInfo': self._branch_info, 120 'branchInfo': self._branch_info,
121 'intros': self._intro_data_source, 121 'intros': self._intro_data_source,
122 'sidenavs': self._sidenav_data_source, 122 'sidenavs': self._sidenav_data_source,
123 'partials': self, 123 'partials': self,
124 'samples': self._samples_data_source, 124 'samples': self._samples_data_source,
(...skipping 19 matching lines...) Expand all
144 144
145 def get(self, key): 145 def get(self, key):
146 return self.GetTemplate(self._private_template_path, key) 146 return self.GetTemplate(self._private_template_path, key)
147 147
148 def GetTemplate(self, base_path, template_name): 148 def GetTemplate(self, base_path, template_name):
149 try: 149 try:
150 return self._cache.GetFromFile( 150 return self._cache.GetFromFile(
151 '/'.join((base_path, FormatKey(template_name)))) 151 '/'.join((base_path, FormatKey(template_name))))
152 except FileNotFoundError as e: 152 except FileNotFoundError as e:
153 return None 153 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698