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

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: 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/app.yaml » ('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 052abcd87031a42edb248916ed60b3ab62b04fe6..9277a41e129300a326c8e1c31426f2b8b932a1c5 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -171,16 +171,20 @@ class _APINodeCursor(object):
return node_availability
return None
- def _LookupAvailability(self, lookup_path):
+ def _LookupAvailability(self, lookup_path, no_assert=False):
'''Runs all the lookup checks on self._lookup_path and
returns the node availability if found, None otherwise.
'''
for lookup in (self._LookupNodeAvailability,
self._CheckEventCallback,
self._CheckNamespacePrefix):
- node_availability = lookup(lookup_path)
- if node_availability is not None:
- return node_availability
+ try:
+ node_availability = lookup(lookup_path)
+ if node_availability is not None:
+ return node_availability
+ except AssertionError:
not at google - send to devlin 2014/07/10 16:28:48 Catching AssertionError is quite dangerous, becaus
+ if not no_assert:
+ raise
return None
def _GetCategory(self):
@@ -211,6 +215,17 @@ 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.
+ '''
+ # HACK(ahernadez.miralles): Tacking on 'deprecated' to the lookup
+ # path is a slight abuse of the lookup functions, which is why
+ # assertions need to be ignored. However, this ensures that
+ # we find when a node became deprecated, if it did at all.
+ return self._LookupAvailability(self._lookup_path + ['deprecated'],
+ no_assert=True)
+
def GetAvailability(self):
'''Returns availability information for this node.
'''
@@ -564,7 +579,10 @@ class _JSCModel(object):
availability_info = self._current_node.GetAvailability()
if availability_info is None:
return None
- status = availability_info.channel
+ if self._current_node.GetDeprecated() is not None:
+ status = 'deprecated'
+ else:
+ status = availability_info.channel
version = availability_info.version
return {
'partial': self._template_cache.GetFromFile(
« 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