Docserver: Add annotation to intro_tables.json to restrict content by platform

BUG=233971
NOTRY=True

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287101 0039d316-1c4b-4281-b951-d872f2087c98
parent 1ebdfd3c
......@@ -71,7 +71,8 @@ class APIDataSource(DataSource):
self._json_cache,
self._template_cache,
self._platform_bundle.GetFeaturesBundle(platform),
self._LoadEventByName(platform)).ToDict()
self._LoadEventByName(platform),
platform).ToDict()
self._view_cache.Set(object_store_key, jsc_view)
return jsc_view
return Future(callback=resolve)
......
application: chrome-apps-doc
version: 3-38-0
version: 3-39-0
runtime: python27
api_version: 1
threadsafe: false
......
......@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data.
url: /_cron
schedule: every 5 minutes
target: 3-38-0
target: 3-39-0
......@@ -11,6 +11,7 @@ from api_schema_graph import APINodeCursor
from docs_server_utils import MarkFirstAndLast
from extensions_paths import JSON_TEMPLATES, PRIVATE_TEMPLATES
from operator import itemgetter
from platform_util import PlatformToExtensionType
import third_party.json_schema_compiler.model as model
......@@ -59,8 +60,6 @@ def _FormatValue(value):
return ','.join([s[max(0, i - 3):i] for i in range(len(s), 0, -3)][::-1])
class JSCView(object):
'''Uses a Model from the JSON Schema Compiler and generates a dict that
a Handlebar template can use for a data source.
......@@ -73,7 +72,8 @@ class JSCView(object):
json_cache,
template_cache,
features_bundle,
event_byname_future):
event_byname_future,
platform):
self._content_script_apis = content_script_apis
self._availability = availability_finder.GetAPIAvailability(jsc_model.name)
self._current_node = APINodeCursor(availability_finder, jsc_model.name)
......@@ -85,6 +85,7 @@ class JSCView(object):
self._template_cache = template_cache
self._event_byname_future = event_byname_future
self._jsc_model = jsc_model
self._platform = platform
def _GetLink(self, link):
ref = link if '.' in link else (self._jsc_model.name + '.' + link)
......@@ -544,6 +545,10 @@ class JSCView(object):
for category in table_info.iterkeys():
content = []
for node in table_info[category]:
ext_type = PlatformToExtensionType(self._platform)
# Don't display nodes restricted to a different platform.
if ext_type not in node.get('extension_types', (ext_type,)):
continue
# If there is a 'partial' argument and it hasn't already been
# converted to a Handlebar object, transform it to a template.
if 'partial' in node:
......
......@@ -123,7 +123,8 @@ class JSCViewTest(unittest.TestCase):
self._json_cache,
_FakeTemplateCache(),
self._features_bundle,
None).ToDict()
None,
'extensions').ToDict()
self.assertEquals('type-TypeA', dict_['types'][0]['id'])
self.assertEquals('property-TypeA-b',
dict_['types'][0]['properties'][0]['id'])
......@@ -140,7 +141,8 @@ class JSCViewTest(unittest.TestCase):
self._json_cache,
_FakeTemplateCache(),
self._features_bundle,
None).ToDict()
None,
'extensions').ToDict()
self.assertEquals(expected_json, dict_)
def testAddRules(self):
......@@ -151,7 +153,8 @@ class JSCViewTest(unittest.TestCase):
self._json_cache,
_FakeTemplateCache(),
self._features_bundle,
self._FakeLoadAddRulesSchema()).ToDict()
self._FakeLoadAddRulesSchema(),
'extensions').ToDict()
# Check that the first event has the addRulesFunction defined.
self.assertEquals('add_rules_tester', dict_['name'])
......@@ -176,7 +179,8 @@ class JSCViewTest(unittest.TestCase):
self._json_cache,
_FakeTemplateCache(),
self._features_bundle,
None)
None,
'extensions')
expected_list = [
{ 'title': 'Description',
'content': [
......@@ -238,7 +242,8 @@ class JSCViewTest(unittest.TestCase):
self._json_cache,
_FakeTemplateCache(),
self._features_bundle,
None)
None,
'extensions')
expected_list[1] = {
'title': 'Availability',
'content': [
......@@ -282,7 +287,8 @@ class JSCViewWithoutNodeAvailabilityTest(unittest.TestCase):
self._json_cache,
_FakeTemplateCache(),
_FakeFeaturesBundle(),
None).ToDict()
None,
'extensions').ToDict()
self.assertEquals(availability,
model_dict['introList'][1]['content'][0]['version'])
......@@ -356,7 +362,8 @@ class JSCViewWithNodeAvailabilityTest(unittest.TestCase):
self._json_cache,
_FakeTemplateCache(),
_FakeFeaturesBundle(),
None).ToDict()
None,
'extensions').ToDict()
# Test nodes that have the same availability as their parent.
......
......@@ -214,7 +214,8 @@
"Learn More": [
{
"link": "app_lifecycle",
"text": "Manage App Lifecycle"
"text": "Manage App Lifecycle",
"extension_types": ["platform_app"]
},
{
"link": "event_pages",
......
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