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

Unified 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: Nit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/server2/api_data_source.py
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index 91dcfc34ba3a8447d37c0dff1fd74e29cf12307f..89296fa073cf73ef3d96946ec158eb89141344bf 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -171,7 +171,7 @@ class _APINodeCursor(object):
return None
def _LookupAvailability(self, lookup_path):
- '''Runs all the lookup checks on self._lookup_path and
+ '''Runs all the lookup checks on |lookup_path| and
returns the node availability if found, None otherwise.
'''
for lookup in (self._LookupNodeAvailability,
@@ -210,6 +210,20 @@ class _APINodeCursor(object):
return 'properties'
raise AssertionError('Could not classify node %s' % self)
+ def GetDeprecated(self):
+ '''Returns when this node became deprecated, or None if it
+ is not deprecated.
+ '''
+ deprecated_path = self._lookup_path + ['deprecated']
+ for lookup in (self._LookupNodeAvailability,
+ self._CheckNamespacePrefix):
+ node_availability = lookup(deprecated_path)
+ if node_availability is not None:
+ return node_availability
+ if 'callback' in self._lookup_path:
+ return self._CheckEventCallback(deprecated_path)
+ return None
+
def GetAvailability(self):
'''Returns availability information for this node.
'''
@@ -555,16 +569,10 @@ class _JSCModel(object):
return intro_rows
- def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None):
- '''Returns an object that the templates use to display availability
+ def _CreateAvailabilityTemplate(self, status, scheduled, version):
+ '''Returns an object suitable for use in templates to display availability
information.
'''
- if status is None:
- availability_info = self._current_node.GetAvailability()
- if availability_info is None:
- return None
- status = availability_info.channel
- version = availability_info.version
return {
'partial': self._template_cache.GetFromFile(
'%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(),
@@ -572,6 +580,25 @@ class _JSCModel(object):
'version': version
}
+ def _GetAvailabilityTemplate(self):
+ '''Gets availability for the current node and returns an appropriate
+ template object.
+ '''
+ # Displaying deprecated status takes precedence over when the API
+ # became stable.
+ availability_info = self._current_node.GetDeprecated()
+ if availability_info is not None:
+ status = 'deprecated'
+ else:
+ availability_info = self._current_node.GetAvailability()
+ if availability_info is None:
+ return None
+ status = availability_info.channel_info.channel
+ return self._CreateAvailabilityTemplate(
+ status,
+ availability_info.scheduled,
+ availability_info.channel_info.version)
+
def _GetIntroDescriptionRow(self):
''' Generates the 'Description' row data for an API intro table.
'''
@@ -587,18 +614,16 @@ class _JSCModel(object):
'''
if self._IsExperimental():
status = 'experimental'
- version = None
scheduled = None
+ version = None
else:
status = self._availability.channel_info.channel
- version = self._availability.channel_info.version
scheduled = self._availability.scheduled
+ version = self._availability.channel_info.version
return {
'title': 'Availability',
'content': [
- self._GetAvailabilityTemplate(status=status,
- version=version,
- scheduled=scheduled)
+ self._CreateAvailabilityTemplate(status, scheduled, version)
]
}
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698