Docserver: Add more support for object level availability in templates

BUG=233982
NOTRY=True

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281952 0039d316-1c4b-4281-b951-d872f2087c98
parent a702da79
......@@ -38,21 +38,6 @@ class _FakeTemplateCache(object):
return Future(value='handlebar %s' % key)
class _FakeAvailabilityFinder(object):
def __init__(self, fake_availability):
self._fake_availability = fake_availability
def GetAPIAvailability(self, api_name):
return self._fake_availability
def GetAPINodeAvailability(self, api_name):
'''The tests that use this fake class don't
use the node availability, so just return a
dummy graph.
'''
return APISchemaGraph(_graph={'dummy': 'graph'})
class _FakeFeaturesBundle(object):
def GetAPIFeatures(self):
return Future(value={
......@@ -73,11 +58,12 @@ class _FakeAvailabilityFinder(object):
return self._fake_availability
def GetAPINodeAvailability(self, api_name):
'''The tests that use this fake class don't
use the node availability, so just return a
dummy graph.
'''
return APISchemaGraph(_graph={'dummy': 'graph'})
schema_graph = APISchemaGraph()
api_graph = APISchemaGraph(json.loads(
CANNED_TRUNK_FS_DATA['api'][api_name + '.json']))
# Give the graph fake ChannelInfo; it's not used in tests.
schema_graph.Update(api_graph, annotation=ChannelInfo('stable', '28', 28))
return schema_graph
class APIDataSourceTest(unittest.TestCase):
......@@ -162,7 +148,6 @@ class APIDataSourceTest(unittest.TestCase):
fake_avail_finder = _FakeAvailabilityFinder(self._fake_availability)
dict_ = _JSCModel(self._api_models.GetModel('add_rules_tester').Get(),
fake_avail_finder,
#self._fake_availability,
self._json_cache,
_FakeTemplateCache(),
self._features_bundle,
......
application: chrome-apps-doc
version: 3-29-0
version: 3-30-0
runtime: python27
api_version: 1
threadsafe: false
......
......@@ -26,26 +26,6 @@ _EXTENSION_API_MAX_VERSION = 17
_SVN_MIN_VERSION = 5
def _GetNamespaceFromFilename(api_name):
'''API names passed in from the templates follow a different naming
convention than the actual API namespace names. Convert |api_name|
to its proper namespace name.
'''
# Devtools APIs are located in a devtools/ directory
# (e.g. devtools/panels.json). The namespace will be devtools.panels.
if 'devtools/' in api_name:
api_name = api_name.replace('/', '.')
# Experimental API filenames have a 'experimental_' prefixed to them (e.g.
# devtools/experimental_audits.json). The namespace always has
# 'experimental.' prefixed to it (e.g. experimental.devtools.audits).
if 'experimental_' in api_name:
api_name = 'experimental.' + api_name.replace('experimental_', '')
# API filenames use '_'s as separators; the separator for namespaces is
# always a '.'.
api_name = api_name.replace('_', '.')
return api_name
def _GetChannelFromFeatures(api_name, features):
'''Finds API channel information for |api_name| from |features|.
Returns None if channel information for the API cannot be located.
......@@ -319,7 +299,6 @@ class AvailabilityFinder(object):
'''Returns an APISchemaGraph annotated with each node's availability (the
ChannelInfo at the oldest channel it's available in).
'''
api_name = _GetNamespaceFromFilename(api_name)
availability_graph = self._node_level_object_store.Get(api_name).Get()
if availability_graph is not None:
return availability_graph
......
......@@ -7,9 +7,7 @@ import sys
import unittest
import api_schema_graph
from availability_finder import (AvailabilityFinder,
AvailabilityInfo,
_GetNamespaceFromFilename)
from availability_finder import AvailabilityFinder, AvailabilityInfo
from branch_utility import BranchUtility, ChannelInfo
from compiled_file_system import CompiledFileSystem
from fake_host_file_system_provider import FakeHostFileSystemProvider
......@@ -74,23 +72,6 @@ class AvailabilityFinderTest(unittest.TestCase):
self._branch_utility.GetStableChannelInfo(13),
stat_paths)
def testGetNamespaceFromFilename(self):
# Test simple name
self.assertEqual('storage', _GetNamespaceFromFilename('storage'))
# Test multi-word names
self.assertEqual('contextMenus',
_GetNamespaceFromFilename('contextMenus'))
self.assertEqual('app.window', _GetNamespaceFromFilename('app_window'))
# Test devtools API
self.assertEqual('devtools.inspectedWindow',
_GetNamespaceFromFilename('devtools/inspectedWindow'))
# Test experimental API
self.assertEqual('experimental.infobars',
_GetNamespaceFromFilename('experimental_infobars'))
# Test experimental API in devtools
self.assertEqual('experimental.devtools.audits',
_GetNamespaceFromFilename('devtools/experimental_audits'))
def testGraphOptimization(self):
for platform in GetPlatforms():
# Keep track of how many times the APISchemaGraph constructor is called.
......
......@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data.
url: /_cron
schedule: every 5 minutes
target: 3-29-0
target: 3-30-0
......@@ -3,6 +3,9 @@
<h3 id="{{id}}">{{name}}</h3>
{{+partials.warning_deprecated item:event/}}
<div class="description">
{{?availability}}
<span class="availability">{{+availability.partial content:availability/}}</span>
{{/availability}}
{{?description}}<p>
{{{description}}}
</p>{{/description}}
......
......@@ -6,6 +6,10 @@
{{?deprecated}}
{{+partials.warning_deprecated item:property/}}
{{/deprecated}}
{{?availability}}
<span class="availability">{{+availability.partial content:availability/}}</span>
{{/availability}}
{{?description}}
{{{description}}}
{{/description}}
......
......@@ -3,6 +3,9 @@
{{?display_name}}
<h3 id="{{id}}">{{display_name}}</h3>
{{/display_name}}
{{?availability}}
<span class="availability">{{+availability.partial content:availability/}}</span>
{{/availability}}
<table>
{{^is_object}}
{{?enum_values}}
......
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