Add support for "documented_in" annotation in json api schema

BUG=341275
NOTRY=true

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260306 0039d316-1c4b-4281-b951-d872f2087c98
parent ba3db738
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
"description": "Use the <code>webview</code> tag to actively load live content from the web over the network and embed it in your Chrome App. Your app can control the appearance of the <code>webview</code> and interact with the web content, initiate navigations in an embedded web page, react to error events that happen within it, and more (see <a href=\"#usage\">Usage</a>).", "description": "Use the <code>webview</code> tag to actively load live content from the web over the network and embed it in your Chrome App. Your app can control the appearance of the <code>webview</code> and interact with the web content, initiate navigations in an embedded web page, react to error events that happen within it, and more (see <a href=\"#usage\">Usage</a>).",
"documentation_options": { "documentation_options": {
"title": "<webview> Tag", "title": "<webview> Tag",
"namespace": "<webview>" "namespace": "<webview>",
"documented_in": "tags/webview"
}, },
"types": [ "types": [
{ {
......
...@@ -64,6 +64,12 @@ class _FakeAPIDataSource(object): ...@@ -64,6 +64,12 @@ class _FakeAPIDataSource(object):
return self._json[key] return self._json[key]
class _FakeNamespace(object):
def __init__(self):
self.documentation_options = {}
class _FakeAPIModels(object): class _FakeAPIModels(object):
def __init__(self, names): def __init__(self, names):
...@@ -72,6 +78,9 @@ class _FakeAPIModels(object): ...@@ -72,6 +78,9 @@ class _FakeAPIModels(object):
def GetNames(self): def GetNames(self):
return self._names return self._names
def GetModel(self, name):
return Future(value=_FakeNamespace())
class _FakeTemplateCache(object): class _FakeTemplateCache(object):
...@@ -160,15 +169,15 @@ class APIDataSourceTest(unittest.TestCase): ...@@ -160,15 +169,15 @@ class APIDataSourceTest(unittest.TestCase):
_FakeTemplateCache(), _FakeTemplateCache(),
self._features_bundle, self._features_bundle,
None).ToDict() None).ToDict()
self.assertEquals(_MakeLink('ref_test.html#type-type2', 'type2'), self.assertEquals(_MakeLink('ref_test#type-type2', 'type2'),
_GetType(dict_, 'type1')['description']) _GetType(dict_, 'type1')['description'])
self.assertEquals( self.assertEquals(
'A %s, or %s' % (_MakeLink('ref_test.html#type-type3', 'type3'), 'A %s, or %s' % (_MakeLink('ref_test#type-type3', 'type3'),
_MakeLink('ref_test.html#type-type2', 'type2')), _MakeLink('ref_test#type-type2', 'type2')),
_GetType(dict_, 'type2')['description']) _GetType(dict_, 'type2')['description'])
self.assertEquals( self.assertEquals(
'%s != %s' % (_MakeLink('other.html#type-type2', 'other.type2'), '%s != %s' % (_MakeLink('other#type-type2', 'other.type2'),
_MakeLink('ref_test.html#type-type2', 'type2')), _MakeLink('ref_test#type-type2', 'type2')),
_GetType(dict_, 'type3')['description']) _GetType(dict_, 'type3')['description'])
......
application: chrome-apps-doc application: chrome-apps-doc
version: 3-15-2 version: 3-16-0
runtime: python27 runtime: python27
api_version: 1 api_version: 1
threadsafe: false threadsafe: false
......
...@@ -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-15-2 target: 3-16-0
...@@ -114,8 +114,10 @@ class ReferenceResolver(object): ...@@ -114,8 +114,10 @@ class ReferenceResolver(object):
category, node_name = node_info category, node_name = node_info
if namespace is not None and text.startswith('%s.' % namespace): if namespace is not None and text.startswith('%s.' % namespace):
text = text[len('%s.' % namespace):] text = text[len('%s.' % namespace):]
api_model = self._api_models.GetModel(api_name).Get()
filename = api_model.documentation_options.get('documented_in', api_name)
return { return {
'href': '%s.html#%s-%s' % (api_name, category, name.replace('.', '-')), 'href': '%s#%s-%s' % (filename, category, name.replace('.', '-')),
'text': text, 'text': text,
'name': node_name 'name': node_name
} }
...@@ -125,7 +127,7 @@ class ReferenceResolver(object): ...@@ -125,7 +127,7 @@ class ReferenceResolver(object):
# to other APIs. # to other APIs.
if ref in api_list: if ref in api_list:
return { return {
'href': '%s.html' % ref, 'href': '%s' % ref,
'text': ref, 'text': ref,
'name': ref 'name': ref
} }
......
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