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

Unified Diff: chrome/common/extensions/docs/server2/handlebar_dict_generator.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: fixed the tests 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/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..f58fb3ff9fb6564cae2eeec8c9eaf4f0b5ce042c 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 + '.' in api['name']:
+ return_samples.append(sample)
+ break
+ return return_samples
not at google - send to devlin 2012/07/30 12:23:03 Perhaps a list comprehension would be more concise
chebert 2012/07/31 22:41:33 Done.
+
def _GenerateType(self, type_):
type_dict = {
'name': type_.name,

Powered by Google App Engine
This is Rietveld 408576698