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 3c21bd464c352ccc437d59139652d814251d4bdf..a1aa78234c5e9c21a9b6454ef151e5f3df0e3bbd 100644 |
--- a/chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
+++ b/chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
@@ -32,7 +32,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 |
not at google - send to devlin
2012/08/01 10:09:19
see example I mentioned
chebert
2012/08/01 18:04:33
Done.
|
clean_json = copy.deepcopy(json) |
_RemoveNoDocs(clean_json) |
try: |
@@ -74,12 +75,18 @@ 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.error(e) |
raise |
+ def _FilterSamples(self, samples, api_name): |
+ api_search = '.' + api_name + '.' |
+ return [sample for sample in samples |
+ if any(api_search in api['name'] for api in sample['api_calls'])] |
+ |
def _GenerateType(self, type_): |
type_dict = { |
'name': self._StripPrefix(type_.name), |