Docserver: Add 'deprecated since' message for API nodes

BUG=392319
NOTRY=True

Review URL: https://codereview.chromium.org/386443003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283899 0039d316-1c4b-4281-b951-d872f2087c98
parent 1bbdb52c
...@@ -171,7 +171,7 @@ class _APINodeCursor(object): ...@@ -171,7 +171,7 @@ class _APINodeCursor(object):
return None return None
def _LookupAvailability(self, lookup_path): 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. returns the node availability if found, None otherwise.
''' '''
for lookup in (self._LookupNodeAvailability, for lookup in (self._LookupNodeAvailability,
...@@ -210,6 +210,20 @@ class _APINodeCursor(object): ...@@ -210,6 +210,20 @@ class _APINodeCursor(object):
return 'properties' return 'properties'
raise AssertionError('Could not classify node %s' % self) 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): def GetAvailability(self):
'''Returns availability information for this node. '''Returns availability information for this node.
''' '''
...@@ -555,16 +569,10 @@ class _JSCModel(object): ...@@ -555,16 +569,10 @@ class _JSCModel(object):
return intro_rows return intro_rows
def _GetAvailabilityTemplate(self, status=None, version=None, scheduled=None): def _CreateAvailabilityTemplate(self, status, scheduled, version):
'''Returns an object that the templates use to display availability '''Returns an object suitable for use in templates to display availability
information. 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 { return {
'partial': self._template_cache.GetFromFile( 'partial': self._template_cache.GetFromFile(
'%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(), '%sintro_tables/%s_message.html' % (PRIVATE_TEMPLATES, status)).Get(),
...@@ -572,6 +580,25 @@ class _JSCModel(object): ...@@ -572,6 +580,25 @@ class _JSCModel(object):
'version': version '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): def _GetIntroDescriptionRow(self):
''' Generates the 'Description' row data for an API intro table. ''' Generates the 'Description' row data for an API intro table.
''' '''
...@@ -587,18 +614,16 @@ class _JSCModel(object): ...@@ -587,18 +614,16 @@ class _JSCModel(object):
''' '''
if self._IsExperimental(): if self._IsExperimental():
status = 'experimental' status = 'experimental'
version = None
scheduled = None scheduled = None
version = None
else: else:
status = self._availability.channel_info.channel status = self._availability.channel_info.channel
version = self._availability.channel_info.version
scheduled = self._availability.scheduled scheduled = self._availability.scheduled
version = self._availability.channel_info.version
return { return {
'title': 'Availability', 'title': 'Availability',
'content': [ 'content': [
self._GetAvailabilityTemplate(status=status, self._CreateAvailabilityTemplate(status, scheduled, version)
version=version,
scheduled=scheduled)
] ]
} }
......
...@@ -369,6 +369,13 @@ class APIDataSourceWithNodeAvailabilityTest(unittest.TestCase): ...@@ -369,6 +369,13 @@ class APIDataSourceWithNodeAvailabilityTest(unittest.TestCase):
assertEquals('tabs.onActivated', assertEquals('tabs.onActivated',
model_dict['events'][0]['availability']['version']) model_dict['events'][0]['availability']['version'])
# Test a node that became deprecated.
self.assertEquals({
'scheduled': None,
'version': 26,
'partial': 'handlebar chrome/common/extensions/docs/templates/' +
'private/intro_tables/deprecated_message.html'
}, model_dict['types'][2]['availability'])
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
application: chrome-apps-doc application: chrome-apps-doc
version: 3-31-0 version: 3-32-0
runtime: python27 runtime: python27
api_version: 1 api_version: 1
threadsafe: false threadsafe: false
......
...@@ -202,7 +202,7 @@ class AvailabilityFinder(object): ...@@ -202,7 +202,7 @@ class AvailabilityFinder(object):
# The _api_features.json file first appears in version 28 and should be # The _api_features.json file first appears in version 28 and should be
# the most reliable for finding API availability. # the most reliable for finding API availability.
available_channel = _GetChannelFromAPIFeatures(api_name, available_channel = _GetChannelFromAPIFeatures(api_name,
features_bundle) features_bundle)
if version >= _ORIGINAL_FEATURES_MIN_VERSION: if version >= _ORIGINAL_FEATURES_MIN_VERSION:
# The _permission_features.json and _manifest_features.json files are # The _permission_features.json and _manifest_features.json files are
# present in Chrome 20 and onwards. Use these if no information could be # present in Chrome 20 and onwards. Use these if no information could be
...@@ -365,7 +365,7 @@ class AvailabilityFinder(object): ...@@ -365,7 +365,7 @@ class AvailabilityFinder(object):
file_system, file_system,
channel_info.version)) channel_info.version))
availability_graph.Update(version_graph.Subtract(availability_graph), availability_graph.Update(version_graph.Subtract(availability_graph),
annotation=channel_info) annotation=AvailabilityInfo(channel_info))
previous.stat = version_stat previous.stat = version_stat
previous.graph = version_graph previous.graph = version_graph
......
...@@ -188,9 +188,16 @@ class AvailabilityFinderTest(unittest.TestCase): ...@@ -188,9 +188,16 @@ class AvailabilityFinderTest(unittest.TestCase):
only_on='apps') only_on='apps')
def testGetAPINodeAvailability(self): def testGetAPINodeAvailability(self):
def assertEquals(found, channel_info, actual, scheduled=None):
lookup_result = api_schema_graph.LookupResult
if channel_info is None:
self.assertEquals(lookup_result(found, None), actual)
else:
self.assertEquals(lookup_result(found, AvailabilityInfo(channel_info,
scheduled=scheduled)), actual)
for platform in GetPlatforms(): for platform in GetPlatforms():
# Allow the LookupResult constructions below to take just one line. # Allow the LookupResult constructions below to take just one line.
lookup_result = api_schema_graph.LookupResult
avail_finder = self._create_availability_finder( avail_finder = self._create_availability_finder(
self._node_fs_creator, self._node_fs_creator,
self._node_fs_iterator, self._node_fs_iterator,
...@@ -198,115 +205,78 @@ class AvailabilityFinderTest(unittest.TestCase): ...@@ -198,115 +205,78 @@ class AvailabilityFinderTest(unittest.TestCase):
tabs_graph = avail_finder.GetAPINodeAvailability('tabs') tabs_graph = avail_finder.GetAPINodeAvailability('tabs')
fake_tabs_graph = avail_finder.GetAPINodeAvailability('fakeTabs') fake_tabs_graph = avail_finder.GetAPINodeAvailability('fakeTabs')
self.assertEquals( assertEquals(True, self._branch_utility.GetChannelInfo('trunk'),
lookup_result(True, self._branch_utility.GetChannelInfo('trunk')), tabs_graph.Lookup('tabs', 'properties', 'fakeTabsProperty3'))
tabs_graph.Lookup('tabs', 'properties', assertEquals(True, self._branch_utility.GetChannelInfo('dev'),
'fakeTabsProperty3')) tabs_graph.Lookup('tabs', 'events', 'onActivated', 'parameters',
self.assertEquals( 'activeInfo', 'properties', 'windowId'))
lookup_result(True, self._branch_utility.GetChannelInfo('dev')), assertEquals(True, self._branch_utility.GetChannelInfo('dev'),
tabs_graph.Lookup('tabs', 'events', 'onActivated', tabs_graph.Lookup('tabs', 'events', 'onUpdated', 'parameters', 'tab'))
'parameters', 'activeInfo', 'properties', assertEquals(True, self._branch_utility.GetChannelInfo('beta'),
'windowId')) tabs_graph.Lookup('tabs', 'events', 'onActivated'))
self.assertEquals( assertEquals(True, self._branch_utility.GetChannelInfo('beta'),
lookup_result(True, self._branch_utility.GetChannelInfo('dev')), tabs_graph.Lookup('tabs', 'functions', 'get', 'parameters', 'tabId'))
tabs_graph.Lookup('tabs', 'events', 'onUpdated', 'parameters', assertEquals(True, self._branch_utility.GetChannelInfo('stable'),
'tab')) tabs_graph.Lookup('tabs', 'types', 'InjectDetails', 'properties',
self.assertEquals( 'code'))
lookup_result(True, self._branch_utility.GetChannelInfo('beta')), assertEquals(True, self._branch_utility.GetChannelInfo('stable'),
tabs_graph.Lookup('tabs', 'events','onActivated')) tabs_graph.Lookup('tabs', 'types', 'InjectDetails', 'properties',
self.assertEquals( 'file'))
lookup_result(True, self._branch_utility.GetChannelInfo('beta')), assertEquals(True, self._branch_utility.GetStableChannelInfo(25),
tabs_graph.Lookup('tabs', 'functions', 'get', 'parameters',
'tabId'))
self.assertEquals(
lookup_result(True, self._branch_utility.GetChannelInfo('stable')),
tabs_graph.Lookup('tabs', 'types', 'InjectDetails',
'properties', 'code'))
self.assertEquals(
lookup_result(True, self._branch_utility.GetChannelInfo('stable')),
tabs_graph.Lookup('tabs', 'types', 'InjectDetails',
'properties', 'file'))
self.assertEquals(
lookup_result(True, self._branch_utility.GetStableChannelInfo(25)),
tabs_graph.Lookup('tabs', 'types', 'InjectDetails')) tabs_graph.Lookup('tabs', 'types', 'InjectDetails'))
# Test inlined type. # Test inlined type.
self.assertEquals( assertEquals(True, self._branch_utility.GetChannelInfo('trunk'),
lookup_result(True, self._branch_utility.GetChannelInfo('trunk')),
tabs_graph.Lookup('tabs', 'types', 'InlinedType')) tabs_graph.Lookup('tabs', 'types', 'InlinedType'))
# Test implicitly inlined type. # Test implicitly inlined type.
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(25),
lookup_result(True, self._branch_utility.GetStableChannelInfo(25)),
fake_tabs_graph.Lookup('fakeTabs', 'types', fake_tabs_graph.Lookup('fakeTabs', 'types',
'WasImplicitlyInlinedType')) 'WasImplicitlyInlinedType'))
# Nothing new in version 24 or 23. # Nothing new in version 24 or 23.
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(22),
lookup_result(True, self._branch_utility.GetStableChannelInfo(22)), tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties', 'windowId'))
tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties', assertEquals(True, self._branch_utility.GetStableChannelInfo(21),
'windowId')) tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties', 'selected'))
self.assertEquals(
lookup_result(True, self._branch_utility.GetStableChannelInfo(21)),
tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties',
'selected'))
# Nothing new in version 20. # Nothing new in version 20.
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(19),
lookup_result(True, self._branch_utility.GetStableChannelInfo(19)),
tabs_graph.Lookup('tabs', 'functions', 'getCurrent')) tabs_graph.Lookup('tabs', 'functions', 'getCurrent'))
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(18),
lookup_result(True, self._branch_utility.GetStableChannelInfo(18)), tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties', 'index'))
tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties', assertEquals(True, self._branch_utility.GetStableChannelInfo(17),
'index'))
self.assertEquals(
lookup_result(True, self._branch_utility.GetStableChannelInfo(17)),
tabs_graph.Lookup('tabs', 'events', 'onUpdated', 'parameters', tabs_graph.Lookup('tabs', 'events', 'onUpdated', 'parameters',
'changeInfo')) 'changeInfo'))
# Nothing new in version 16. # Nothing new in version 16.
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(15),
lookup_result(True, self._branch_utility.GetStableChannelInfo(15)), tabs_graph.Lookup('tabs', 'properties', 'fakeTabsProperty2'))
tabs_graph.Lookup('tabs', 'properties',
'fakeTabsProperty2'))
# Everything else is available at the API's release, version 14 here. # Everything else is available at the API's release, version 14 here.
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(14),
lookup_result(True, self._branch_utility.GetStableChannelInfo(14)),
tabs_graph.Lookup('tabs', 'types', 'Tab')) tabs_graph.Lookup('tabs', 'types', 'Tab'))
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(14),
lookup_result(True, self._branch_utility.GetStableChannelInfo(14)), tabs_graph.Lookup('tabs', 'types', 'Tab', 'properties', 'url'))
tabs_graph.Lookup('tabs', 'types', 'Tab', assertEquals(True, self._branch_utility.GetStableChannelInfo(14),
'properties', 'url')) tabs_graph.Lookup('tabs', 'properties', 'fakeTabsProperty1'))
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(14),
lookup_result(True, self._branch_utility.GetStableChannelInfo(14)),
tabs_graph.Lookup('tabs', 'properties',
'fakeTabsProperty1'))
self.assertEquals(
lookup_result(True, self._branch_utility.GetStableChannelInfo(14)),
tabs_graph.Lookup('tabs', 'functions', 'get', 'parameters', tabs_graph.Lookup('tabs', 'functions', 'get', 'parameters',
'callback')) 'callback'))
self.assertEquals( assertEquals(True, self._branch_utility.GetStableChannelInfo(14),
lookup_result(True, self._branch_utility.GetStableChannelInfo(14)),
tabs_graph.Lookup('tabs', 'events', 'onUpdated')) tabs_graph.Lookup('tabs', 'events', 'onUpdated'))
# Test things that aren't available. # Test things that aren't available.
self.assertEqual(lookup_result(False, None), assertEquals(False, None, tabs_graph.Lookup('tabs', 'types',
tabs_graph.Lookup('tabs', 'types', 'UpdateInfo'))
'UpdateInfo')) assertEquals(False, None, tabs_graph.Lookup('tabs', 'functions', 'get',
self.assertEqual(lookup_result(False, None), 'parameters', 'callback', 'parameters', 'tab', 'id'))
tabs_graph.Lookup('tabs', 'functions', 'get', assertEquals(False, None, tabs_graph.Lookup('functions'))
'parameters', 'callback', assertEquals(False, None, tabs_graph.Lookup('events', 'onActivated',
'parameters', 'tab', 'id')) 'parameters', 'activeInfo', 'tabId'))
self.assertEqual(lookup_result(False, None),
tabs_graph.Lookup('functions'))
self.assertEqual(lookup_result(False, None),
tabs_graph.Lookup('events', 'onActivated',
'parameters', 'activeInfo',
'tabId'))
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -2,4 +2,4 @@ cron: ...@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data. - description: Repopulates all cached data.
url: /_cron url: /_cron
schedule: every 5 minutes schedule: every 5 minutes
target: 3-31-0 target: 3-32-0
...@@ -42,7 +42,11 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -42,7 +42,11 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
} }
}, },
'api': { 'api': {
'_api_features.json': '{}', '_api_features.json': json.dumps({
'tabs.scheduledFunc': {
'channel': 'stable'
}
}),
'_manifest_features.json': '{}', '_manifest_features.json': '{}',
'_permission_features.json': '{}', '_permission_features.json': '{}',
'fake_tabs.idl': FAKE_TABS_IDL, 'fake_tabs.idl': FAKE_TABS_IDL,
...@@ -89,6 +93,11 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -89,6 +93,11 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
'type':'any' 'type':'any'
} }
} }
},
{
'id': 'DeprecatedType',
'type': 'any',
'deprecated': 'This is deprecated'
} }
], ],
'properties': { 'properties': {
...@@ -136,6 +145,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -136,6 +145,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
'type': 'any' 'type': 'any'
} }
] ]
},
{
'name': 'scheduledFunc',
'parameters': []
} }
], ],
'events': [ 'events': [
...@@ -189,7 +202,11 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -189,7 +202,11 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
}, },
'1500': { '1500': {
'api': { 'api': {
'_api_features.json': "{}", '_api_features.json': json.dumps({
'tabs.scheduledFunc': {
'channel': 'stable'
}
}),
'_manifest_features.json': "{}", '_manifest_features.json': "{}",
'_permission_features.json': "{}", '_permission_features.json': "{}",
'fake_tabs.idl': FAKE_TABS_IDL, 'fake_tabs.idl': FAKE_TABS_IDL,
...@@ -213,6 +230,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -213,6 +230,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
'code': {}, 'code': {},
'file': {} 'file': {}
} }
},
{
'id': 'DeprecatedType',
'deprecated': 'This is deprecated'
} }
], ],
'properties': { 'properties': {
...@@ -248,6 +269,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -248,6 +269,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
'name': 'tabId' 'name': 'tabId'
} }
] ]
},
{
'name': 'scheduledFunc',
'parameters': []
} }
], ],
'events': [ 'events': [
...@@ -311,6 +336,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -311,6 +336,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
'code': {}, 'code': {},
'file': {} 'file': {}
} }
},
{
'id': 'DeprecatedType',
'deprecated': 'This is deprecated'
} }
], ],
'properties': { 'properties': {
...@@ -404,6 +433,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -404,6 +433,10 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
'code': {}, 'code': {},
'file': {} 'file': {}
} }
},
{
'id': 'DeprecatedType',
'deprecated': 'This is deprecated'
} }
], ],
'properties': { 'properties': {
...@@ -481,6 +514,9 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, { ...@@ -481,6 +514,9 @@ TABS_SCHEMA_BRANCHES = MoveAllTo(CHROME_EXTENSIONS, {
'properties': { 'properties': {
'allFrames': {} 'allFrames': {}
} }
},
{
'id': 'DeprecatedType',
} }
], ],
'properties': { 'properties': {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment