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

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: done Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_list_data_source_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6263871cf3d55a1cf5227cf229131b096b28e27b..7bb671db5b46641142a3c366f2d168a397c777a9 100644
--- a/chrome/common/extensions/docs/server2/api_list_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_list_data_source.py
@@ -7,14 +7,15 @@ import os
import posixpath
import docs_server_utils as utils
+from branch_utility import ChannelInfo
from extensions_paths import PUBLIC_TEMPLATES
+from file_system import FileNotFoundError
-def _GetAPICategory(api, documented_apis):
- name = api['name']
- if (name.endswith('Private') or
- name not in documented_apis):
+def _GetAPICategory(api_name, documented_apis):
+ if (api_name.endswith('Private') or
+ api_name not in documented_apis):
return 'private'
- if name.startswith('experimental.'):
+ if api_name.startswith('experimental.'):
return 'experimental'
return 'chrome'
@@ -39,13 +40,20 @@ class APIListDataSource(object):
compiled_fs_factory,
file_system,
features_bundle,
- object_store_creator):
+ object_store_creator,
+ api_models,
+ availability_finder):
self._file_system = file_system
self._cache = compiled_fs_factory.Create(file_system,
self._CollectDocumentedAPIs,
APIListDataSource)
self._features_bundle = features_bundle
self._object_store_creator = object_store_creator
+ self._api_models = api_models
+ self._availability_finder = availability_finder
+
+ def _GetDocumentedApis(self):
+ return self._cache.GetFromFileListing(self._public_template_path).Get()
def _CollectDocumentedAPIs(self, base_dir, files):
def GetDocumentedAPIsForPlatform(names, platform):
@@ -64,27 +72,64 @@ class APIListDataSource(object):
}
def _GenerateAPIDict(self):
+
documented_apis = self._cache.GetFromFileListing(PUBLIC_TEMPLATES).Get()
- api_features = self._features_bundle.GetAPIFeatures().Get()
- def FilterAPIs(platform):
- return (api for api in api_features.itervalues()
- if platform in api['platforms'])
+ def GetChannelInfo(api_name):
+ return self._availability_finder.GetApiAvailability(api_name)
+
+ def GetApiDescription(model):
+ try:
+ return model.Get().description if model.Get() else ''
+ except FileNotFoundError:
+ return ''
+
+ def GetApiPlatform(api_name):
+ feature = self._features_bundle.GetAPIFeatures().Get()[api_name]
+ return feature['platforms']
def MakeDictForPlatform(platform):
- platform_dict = { 'chrome': [], 'experimental': [], 'private': [] }
- for api in FilterAPIs(platform):
- if api['name'] in documented_apis[platform]:
- category = _GetAPICategory(api, documented_apis[platform])
- platform_dict[category].append(api)
- for category, apis in platform_dict.iteritems():
- platform_dict[category] = sorted(apis, key=itemgetter('name'))
- utils.MarkLast(platform_dict[category])
- return platform_dict
+ platform_dict = {
+ 'chrome': {'stable': [], 'beta': [], 'dev': [], 'trunk': []}
+ }
+ private_apis = []
+ experimental_apis = []
+ all_apis = []
+ for api_name, api_model in self._api_models.IterModels():
+ api = {
+ 'name': api_name,
+ 'description': GetApiDescription(api_model),
+ 'platforms': GetApiPlatform(api_name),
+ }
+ category = _GetAPICategory(api_name, documented_apis[platform])
+ if category == 'chrome':
+ channel_info = GetChannelInfo(api_name)
+ channel = channel_info.channel
+ if channel == 'stable':
+ api['version'] = channel_info.version
+ platform_dict[category][channel].append(api)
+ all_apis.append(api)
+ elif category == 'experimental':
+ experimental_apis.append(api)
+ all_apis.append(api)
+ elif category == 'private':
+ private_apis.append(api)
+
+ for channel, apis_by_channel in platform_dict['chrome'].iteritems():
+ apis_by_channel = sorted(apis_by_channel, key=itemgetter('name'))
+ utils.MarkLast(apis_by_channel)
+ platform_dict['chrome'][channel] = apis_by_channel
+ for key, apis in (('all', all_apis),
+ ('private', private_apis),
+ ('experimental', experimental_apis)):
+ apis = sorted(apis, key=itemgetter('name'))
+ utils.MarkLast(apis)
+ platform_dict[key] = apis
+ return platform_dict
return {
'apps': MakeDictForPlatform('apps'),
- 'extensions': MakeDictForPlatform('extensions')
+ 'extensions': MakeDictForPlatform('extensions'),
}
def Create(self):
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_list_data_source_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698