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 90858cd50740f8e64f94a11c25ffaa8548953f5f..0e0804b0326bb9469f25986d9e66541439bd422d 100644 |
--- a/chrome/common/extensions/docs/server2/api_data_source.py |
+++ b/chrome/common/extensions/docs/server2/api_data_source.py |
@@ -16,19 +16,31 @@ 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._samples = samples |
self._json_cache = cache_builder.build(self._LoadJsonAPI) |
self._idl_cache = cache_builder.build(self._LoadIdlAPI) |
not at google - send to devlin
2012/07/30 12:23:03
This means that on every construction (via the Fac
chebert
2012/07/31 22:41:33
The issue I am having with this is that the APIDat
not at google - send to devlin
2012/08/01 10:09:19
Ah sorry, looks like I confused myself, and you in
|
self._base_path = base_path |
def _LoadJsonAPI(self, api): |
generator = HandlebarDictGenerator( |
- json.loads(json_comment_eater.Nom(api))[0]) |
+ 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]) |
+ generator = HandlebarDictGenerator(idl_schema.IDLSchema(idl).process()[0], |
+ self._samples) |
return generator.Generate() |
def __getitem__(self, key): |