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

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: . 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 3c21bd464c352ccc437d59139652d814251d4bdf..d00f0382ee70ea3fbc98eb44f38c52c33c15331d 100644
--- a/chrome/common/extensions/docs/server2/handlebar_dict_generator.py
+++ b/chrome/common/extensions/docs/server2/handlebar_dict_generator.py
@@ -67,14 +67,15 @@ class HandlebarDictGenerator(object):
{ 'href': ref_dict['href'], 'text': ref_dict['text'], 'rest': rest })
return ''.join(formatted_description)
- def Generate(self):
+ def Generate(self, samples):
try:
return {
'name': self._namespace.name,
'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(samples),
}
except Exception as e:
logging.error(e)
@@ -141,6 +142,11 @@ class HandlebarDictGenerator(object):
def _GenerateProperties(self, properties):
return map(self._GenerateProperty, properties.values())
+ def _FilterSamples(self, samples):
not at google - send to devlin 2012/08/01 20:56:32 Perhaps pass the filtered results directly into Ge
chebert 2012/08/02 18:40:23 Done.
+ api_search = '.' + self._namespace.name + '.'
+ return [sample for sample in samples
+ if any(api_search in api['name'] for api in sample['api_calls'])]
+
def _GenerateProperty(self, property_):
property_dict = {
'name': self._StripPrefix(property_.name),

Powered by Google App Engine
This is Rietveld 408576698