Index: chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
diff --git a/chrome/common/extensions/docs/server2/handlebar_dict_generator.py b/chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
index 456aa831bf2084e5e55c8ab15c0b292694b26406..6b55c6a1b00e9a6fc6e384e3bc5de542394c65fe 100644 |
--- a/chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
+++ b/chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
@@ -44,7 +44,8 @@ class HandlebarDictGenerator(object): |
"""Uses a Model from the JSON Schema Compiler and generates a dict that |
a Handlebar template can use for a data source. |
""" |
- def __init__(self, json): |
+ def __init__(self, json, samples): |
+ self._samples = samples |
clean_json = copy.deepcopy(json) |
_RemoveNoDocs(clean_json) |
try: |
@@ -59,11 +60,21 @@ class HandlebarDictGenerator(object): |
'types': map(self._GenerateType, self._namespace.types.values()), |
'functions': self._GenerateFunctions(self._namespace.functions), |
'events': map(self._GenerateEvent, self._namespace.events.values()), |
- 'properties': self._GenerateProperties(self._namespace.properties) |
+ 'properties': self._GenerateProperties(self._namespace.properties), |
+ 'samples': self._FilterSamples(self._samples, self._namespace.name) |
} |
except Exception as e: |
logging.info(e) |
+ def _FilterSamples(self, samples, api_name): |
+ return_samples = [] |
+ for sample in samples: |
+ for api in sample['api_calls']: |
+ if api_name == api['name'].split('.', 2)[1]: |
chebert
2012/07/26 20:36:39
not sure if this is "safe"
cduvall
2012/07/26 22:04:24
I would just do:
if api_name in api['name']:
chebert
2012/07/26 22:30:52
Done.
|
+ return_samples.append(sample) |
+ break |
+ return return_samples |
+ |
def _GenerateType(self, type_): |
type_dict = { |
'name': type_.name, |