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

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

Issue 386443003: Docserver: Add 'deprecated since' message for API nodes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 from copy import copy 5 from copy import copy
6 import logging 6 import logging
7 import os 7 import os
8 import posixpath 8 import posixpath
9 9
10 from data_source import DataSource 10 from data_source import DataSource
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 assert 'callback' in lookup_path, self 164 assert 'callback' in lookup_path, self
165 callback_index = lookup_path.index('callback') 165 callback_index = lookup_path.index('callback')
166 try: 166 try:
167 lookup_path.pop(callback_index) 167 lookup_path.pop(callback_index)
168 node_availability = self._LookupNodeAvailability(lookup_path) 168 node_availability = self._LookupNodeAvailability(lookup_path)
169 finally: 169 finally:
170 lookup_path.insert(callback_index, 'callback') 170 lookup_path.insert(callback_index, 'callback')
171 return node_availability 171 return node_availability
172 return None 172 return None
173 173
174 def _LookupAvailability(self, lookup_path): 174 def _LookupAvailability(self, lookup_path, no_assert=False):
175 '''Runs all the lookup checks on self._lookup_path and 175 '''Runs all the lookup checks on self._lookup_path and
176 returns the node availability if found, None otherwise. 176 returns the node availability if found, None otherwise.
177 ''' 177 '''
178 for lookup in (self._LookupNodeAvailability, 178 for lookup in (self._LookupNodeAvailability,
179 self._CheckEventCallback, 179 self._CheckEventCallback,
180 self._CheckNamespacePrefix): 180 self._CheckNamespacePrefix):
181 node_availability = lookup(lookup_path) 181 try:
182 if node_availability is not None: 182 node_availability = lookup(lookup_path)
183 return node_availability 183 if node_availability is not None:
184 return node_availability
185 except AssertionError:
not at google - send to devlin 2014/07/10 16:28:48 Catching AssertionError is quite dangerous, becaus
186 if not no_assert:
187 raise
184 return None 188 return None
185 189
186 def _GetCategory(self): 190 def _GetCategory(self):
187 '''Returns the category this node belongs to. 191 '''Returns the category this node belongs to.
188 ''' 192 '''
189 if self._lookup_path[-2] in _NODE_CATEGORIES: 193 if self._lookup_path[-2] in _NODE_CATEGORIES:
190 return self._lookup_path[-2] 194 return self._lookup_path[-2]
191 # If lookup_path[-2] is not in _NODE_CATEGORIES and 195 # If lookup_path[-2] is not in _NODE_CATEGORIES and
192 # lookup_path[-1] is 'callback', then we know we have 196 # lookup_path[-1] is 'callback', then we know we have
193 # an event callback. 197 # an event callback.
(...skipping 10 matching lines...) Expand all
204 # lookup paths like 208 # lookup paths like
205 # 'events > types > Rule > properties > tags > tagsType'. 209 # 'events > types > Rule > properties > tags > tagsType'.
206 # These nodes are treated as properties. 210 # These nodes are treated as properties.
207 return 'properties' 211 return 'properties'
208 if self._lookup_path[0] == 'events': 212 if self._lookup_path[0] == 'events':
209 # HACK(ahernandez.miralles): This catches a few edge cases, 213 # HACK(ahernandez.miralles): This catches a few edge cases,
210 # such as 'webviewTag > events > consolemessage > level'. 214 # such as 'webviewTag > events > consolemessage > level'.
211 return 'properties' 215 return 'properties'
212 raise AssertionError('Could not classify node %s' % self) 216 raise AssertionError('Could not classify node %s' % self)
213 217
218 def GetDeprecated(self):
219 '''Returns when this node became deprecated, or None if it
220 is not deprecated.
221 '''
222 # HACK(ahernadez.miralles): Tacking on 'deprecated' to the lookup
223 # path is a slight abuse of the lookup functions, which is why
224 # assertions need to be ignored. However, this ensures that
225 # we find when a node became deprecated, if it did at all.
226 return self._LookupAvailability(self._lookup_path + ['deprecated'],
227 no_assert=True)
228
214 def GetAvailability(self): 229 def GetAvailability(self):
215 '''Returns availability information for this node. 230 '''Returns availability information for this node.
216 ''' 231 '''
217 if self._GetCategory() in self._ignored_categories: 232 if self._GetCategory() in self._ignored_categories:
218 return None 233 return None
219 node_availability = self._LookupAvailability(self._lookup_path) 234 node_availability = self._LookupAvailability(self._lookup_path)
220 if node_availability is None: 235 if node_availability is None:
221 logging.warning('No availability found for: %s' % self) 236 logging.warning('No availability found for: %s' % self)
222 return None 237 return None
223 238
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 return intro_rows 572 return intro_rows
558 573
559 def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None): 574 def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None):
560 '''Returns an object that the templates use to display availability 575 '''Returns an object that the templates use to display availability
561 information. 576 information.
562 ''' 577 '''
563 if status is None: 578 if status is None:
564 availability_info = self._current_node.GetAvailability() 579 availability_info = self._current_node.GetAvailability()
565 if availability_info is None: 580 if availability_info is None:
566 return None 581 return None
567 status = availability_info.channel 582 if self._current_node.GetDeprecated() is not None:
583 status = 'deprecated'
584 else:
585 status = availability_info.channel
568 version = availability_info.version 586 version = availability_info.version
569 return { 587 return {
570 'partial': self._template_cache.GetFromFile( 588 'partial': self._template_cache.GetFromFile(
571 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), 589 '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(),
572 'scheduled': scheduled, 590 'scheduled': scheduled,
573 'version': version 591 'version': version
574 } 592 }
575 593
576 def _GetIntroDescriptionRow(self): 594 def _GetIntroDescriptionRow(self):
577 ''' Generates the 'Description' row data for an API intro table. 595 ''' Generates the 'Description' row data for an API intro table.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 getter = lambda: 0 787 getter = lambda: 0
770 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get() 788 getter.get = lambda api_name: self._GetImpl(platform, api_name).Get()
771 return getter 789 return getter
772 790
773 def Cron(self): 791 def Cron(self):
774 futures = [] 792 futures = []
775 for platform in GetPlatforms(): 793 for platform in GetPlatforms():
776 futures += [self._GetImpl(platform, name) 794 futures += [self._GetImpl(platform, name)
777 for name in self._platform_bundle.GetAPIModels(platform).GetNames()] 795 for name in self._platform_bundle.GetAPIModels(platform).GetNames()]
778 return Collect(futures, except_pass=FileNotFoundError) 796 return Collect(futures, except_pass=FileNotFoundError)
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698