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

Unified Diff: chrome/common/extensions/docs/server2/api_list_data_source.py

Issue 48263002: list apis by channel info, e.g. dev, stable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 2 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
Index: chrome/common/extensions/docs/server2/api_list_data_source.py
diff --git a/chrome/common/extensions/docs/server2/api_list_data_source.py b/chrome/common/extensions/docs/server2/api_list_data_source.py
index c84a34b88c2b63fd12658f6dc58592f87cd2d39d..66a0c496679b9b337e7a871ed126b9b81c39def9 100644
--- a/chrome/common/extensions/docs/server2/api_list_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_list_data_source.py
@@ -5,8 +5,6 @@
from operator import itemgetter
import os
-from third_party.json_schema_compiler.json_parse import Parse
-import third_party.json_schema_compiler.model as model
import docs_server_utils as utils
def _GetAPICategory(api, documented_apis):
@@ -40,7 +38,9 @@ class APIListDataSource(object):
file_system,
public_template_path,
features_bundle,
- object_store_creator):
+ object_store_creator,
+ api_data_source_factory,
not at google - send to devlin 2013/10/31 00:05:26 I don't want to introduce a dependency on api_data
hukun 2013/11/01 09:31:52 Done. Remove dependency of api_data_source_factory
+ availability_finder):
self._file_system = file_system
def NormalizePath(string):
return string if string.endswith('/') else (string + '/')
@@ -50,6 +50,22 @@ class APIListDataSource(object):
APIListDataSource)
self._features_bundle = features_bundle
self._object_store_creator = object_store_creator
+ self._api_data_source = api_data_source_factory.Create(None,
+ disable_refs=True)
+ self._availability_finder = availability_finder
+ self._cached_documented_apis = None
+ self._cachhed_api_features = None
not at google - send to devlin 2013/10/31 00:05:26 the places you get these from do their own caching
hukun 2013/11/01 09:31:52 Done.remove the cache.
+
+ def _GetDocumentedApis(self):
+ if (not self._cached_documented_apis):
+ self._cached_documented_apis = self._cache.GetFromFileListing(
+ self._public_template_path).Get()
+ return self._cached_documented_apis
+
+ def _GetApiFeatures(self):
+ if (not self._cachhed_api_features) :
+ self._cachhed_api_features = self._features_bundle.GetAPIFeatures()
+ return self._cachhed_api_features
def _CollectDocumentedAPIs(self, base_dir, files):
def GetDocumentedAPIsForPlatform(names, platform):
@@ -67,10 +83,13 @@ class APIListDataSource(object):
'extensions': GetDocumentedAPIsForPlatform(api_names, 'extensions')
}
+ def GetAllNames(self):
+ api_features = self._GetApiFeatures().itervalues()
+ return [api['name'] for api in api_features]
+
def _GenerateAPIDict(self):
- documented_apis = self._cache.GetFromFileListing(
- self._public_template_path).Get()
- api_features = self._features_bundle.GetAPIFeatures()
+ documented_apis = self._GetDocumentedApis()
+ api_features = self._GetApiFeatures()
def FilterAPIs(platform):
return (api for api in api_features.itervalues()
@@ -86,9 +105,39 @@ class APIListDataSource(object):
utils.MarkLast(platform_dict[category])
return platform_dict
+ def MakeDictForChannel(dict_for_platform, availability_finder,
+ api_data_source):
not at google - send to devlin 2013/10/31 00:05:26 this should still [be able to be arranged to] have
hukun 2013/11/01 09:31:52 Done. Use self' point directly.
+ platform_list = [ 'chrome', 'experimental']
+
+ for platform in platform_list:
+ platform_dict = dict_for_platform[platform]
+ channel_dict = { 'stable': [], 'beta': [], 'dev': [], 'trunk': [] }
+ for api in platform_dict:
+ api_name = api['name']
+ description_list = api_data_source.get(api_name)["introList"];
+ for description in description_list:
+ if description["title"] == 'Description':
+ api['description'] = description['content'][0]['text']
+ break
+ channel_info = availability_finder.GetApiAvailability(api_name)
+ channel = channel_info.channel
+ if channel == 'stable':
+ api['version'] = channel_info.version
+ channel_dict[channel].append(api)
+
not at google - send to devlin 2013/10/31 00:05:26 I'm finding this sa bit hard to follow, can you br
hukun 2013/11/01 09:31:52 Done. Remove my func.
+ for channel, apis in channel_dict.iteritems():
+ channel_dict[channel] = sorted(apis, key=itemgetter('name'))
+ utils.MarkLast(channel_dict[channel])
+ dict_for_platform[platform] = channel_dict
+ return dict_for_platform
+
return {
- 'apps': MakeDictForPlatform('apps'),
- 'extensions': MakeDictForPlatform('extensions')
+ 'apps': MakeDictForChannel(MakeDictForPlatform('apps'),
not at google - send to devlin 2013/10/31 00:05:26 MakeDictForPlatform('apps') here was right. MakeDi
hukun 2013/11/01 09:31:52 Done. Still use MakeDictForPlatform
+ self._availability_finder,
+ self._api_data_source),
+ 'extensions': MakeDictForChannel(MakeDictForPlatform('extensions'),
+ self._availability_finder,
+ self._api_data_source)
}
def Create(self):
@@ -99,11 +148,11 @@ class APIListDataSource(object):
self._object_store = object_store_creator.Create(APIListDataSource)
def GetAllNames(self):
- apis = []
- for platform in ['apps', 'extensions']:
- for category in ['chrome', 'experimental', 'private']:
- apis.extend(self.get(platform).get(category))
- return [api['name'] for api in apis]
+ data = self._object_store.Get('all_names').Get()
+ if data is None:
+ data = self._factory.GetAllNames()
+ self._object_store.Set('all_names', data)
+ return data
def _GetCachedAPIData(self):
data = self._object_store.Get('api_data').Get()

Powered by Google App Engine
This is Rietveld 408576698