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 4efe5ca81af90f7df7d0c29154ed590b916abf2f..7bccbdf3ad293add22e90dda7678466ce0cd88bb 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,7 @@ import posixpath |
from svn_constants import PUBLIC_TEMPLATE_PATH |
import docs_server_utils as utils |
+from file_system import FileNotFoundError |
def _GetAPICategory(api, documented_apis): |
name = api['name'] |
@@ -39,13 +40,23 @@ 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 _GetApiFeatures(self): |
+ return self._features_bundle.GetAPIFeatures() |
def _CollectDocumentedAPIs(self, base_dir, files): |
def GetDocumentedAPIsForPlatform(names, platform): |
@@ -66,26 +77,66 @@ class APIListDataSource(object): |
def _GenerateAPIDict(self): |
documented_apis = self._cache.GetFromFileListing( |
PUBLIC_TEMPLATE_PATH).Get() |
- api_features = self._features_bundle.GetAPIFeatures() |
def FilterAPIs(platform): |
- return (api for api in api_features.itervalues() |
+ return (api for api |
+ in self._features_bundle.GetAPIFeatures().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() |
+ if model: |
+ return model.description |
+ else: |
+ return '' |
not at google - send to devlin
2013/11/07 23:52:18
you can also write this more concisely:
model = s
hukun
2013/11/08 06:23:39
I did filter the api by _api_models.GetName() befo
not at google - send to devlin
2013/11/10 01:39:57
Oh because they have [nodoc]. Right. That is a pro
|
+ except FileNotFoundError: |
+ return '' |
+ |
def MakeDictForPlatform(platform): |
- platform_dict = { 'chrome': [], 'experimental': [], 'private': [] } |
+ platform_dict = { |
+ 'chrome': {'stable': [],'beta': [], 'dev': [],'trunk': []} |
not at google - send to devlin
2013/11/07 23:52:18
some of these commas need spaces after them
hukun
2013/11/08 06:23:39
Done
|
+ } |
+ private_apis = [] |
+ experimental_apis = [] |
+ all_apis = [] |
+ |
for api in FilterAPIs(platform): |
not at google - send to devlin
2013/11/10 01:39:57
See comment above. Just loop over self._api_models
|
- 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(): |
+ 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): |