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

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

Issue 10835012: Extension Docs Server: Include a list of samples used in the api reference page. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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_data_source.py
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index d4ea2a2cea1b3930a8a76d06d89e94c51b1a0d16..60d7f0800c4f2326d9f51f9e6fe94c8a3c9efe07 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -16,24 +16,20 @@ class APIDataSource(object):
"""This class fetches and loads JSON APIs from the FileSystem passed in with
|cache_builder|, so the APIs can be plugged into templates.
"""
- def __init__(self, cache_builder, base_path):
+ class Factory(object):
+ def __init__(self, cache_builder, base_path):
+ self._cache_builder = cache_builder
+ self._base_path = base_path
+
+ def Create(self, samples):
+ return APIDataSource(self._cache_builder, self._base_path, samples)
+
+ def __init__(self, cache_builder, base_path, samples):
+ self._permissions_cache = cache_builder.build(self._LoadPermissions)
self._json_cache = cache_builder.build(self._LoadJsonAPI)
self._idl_cache = cache_builder.build(self._LoadIdlAPI)
- self._permissions_cache = cache_builder.build(self._LoadPermissions)
self._base_path = base_path
-
- def _LoadJsonAPI(self, api):
- generator = HandlebarDictGenerator(
- json.loads(json_comment_eater.Nom(api))[0])
- return generator.Generate()
-
- def _LoadIdlAPI(self, api):
- idl = idl_parser.IDLParser().ParseData(api)
- generator = HandlebarDictGenerator(idl_schema.IDLSchema(idl).process()[0])
- return generator.Generate()
-
- def _LoadPermissions(self, perms_json):
- return json.loads(json_comment_eater.Nom(perms_json))
+ self._samples = samples
def _GetFeature(self, path):
# Remove 'experimental_' from path name to match the keys in
@@ -49,6 +45,20 @@ class APIDataSource(object):
except Exception:
return None
+ def _LoadPermissions(self, perms_json):
+ return json.loads(json_comment_eater.Nom(perms_json))
+
+ def _LoadJsonAPI(self, api):
+ generator = HandlebarDictGenerator(
+ json.loads(json_comment_eater.Nom(api))[0], self._samples)
+ return generator.Generate()
+
+ def _LoadIdlAPI(self, api):
+ idl = idl_parser.IDLParser().ParseData(api)
+ generator = HandlebarDictGenerator(
+ idl_schema.IDLSchema(idl).process()[0], self._samples)
+ return generator.Generate()
+
def _AddPermissionsDict(self, api_dict, path):
return_dict = { 'permissions': self._GetFeature(path) }
return_dict.update(api_dict)

Powered by Google App Engine
This is Rietveld 408576698