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 59f62d1549e00c8c578dec26e90a0a8f3bc2d137..035eea7a5279508487a90277589d1e3edffb1995 100644 |
--- a/chrome/common/extensions/docs/server2/api_list_data_source.py |
+++ b/chrome/common/extensions/docs/server2/api_list_data_source.py |
@@ -8,6 +8,8 @@ import posixpath |
from svn_constants import PUBLIC_TEMPLATE_PATH |
import docs_server_utils as utils |
+from file_system import FileNotFoundError |
+from branch_utility import ChannelInfo |
not at google - send to devlin
2013/11/10 01:39:57
sorting: branch_utility should go above svn_consta
hukun
2013/11/11 10:23:03
Done
|
def _GetAPICategory(api, documented_apis): |
not at google - send to devlin
2013/11/10 01:39:57
(for comment below, change this to take api_name d
hukun
2013/11/11 10:23:03
Done
|
name = api['name'] |
@@ -39,13 +41,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): |
@@ -66,26 +75,63 @@ class APIListDataSource(object): |
def _GenerateAPIDict(self): |
documented_apis = self._cache.GetFromFileListing( |
PUBLIC_TEMPLATE_PATH).Get() |
- api_features = self._features_bundle.GetAPIFeatures().Get() |
def FilterAPIs(platform): |
- return (api for api in api_features.itervalues() |
+ return (api for api |
+ in self._features_bundle.GetAPIFeatures().Get().itervalues() |
if platform in api['platforms']) |
+ def GetChannelInfo(api_name): |
+ return self._availability_finder.GetApiAvailability(api_name) |
+ |
+ def GetApiDescription(api_name): |
+ try: |
+ model = self._api_models.GetModel(api_name).Get() |
+ return model.description if model else '' |
+ except FileNotFoundError: |
+ return '' |
+ |
def MakeDictForPlatform(platform): |
- platform_dict = { 'chrome': [], 'experimental': [], 'private': [] } |
+ platform_dict = { |
+ 'chrome': {'stable': [], 'beta': [], 'dev': [], 'trunk': []} |
+ } |
+ private_apis = [] |
+ experimental_apis = [] |
+ all_apis = [] |
+ |
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 |
+ category = _GetAPICategory(api, documented_apis[platform]) |
+ api_name = api['name'] |
+ if api_name in self._api_models.GetNames(): |
not at google - send to devlin
2013/11/10 01:39:57
Instead of the above 4 lines, you can have
for ap
hukun
2013/11/11 10:23:03
Need some other properties, e.g. platform, depende
|
+ api['description'] = GetApiDescription(api_name) |
+ 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): |