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

Unified Diff: chrome/common/extensions/docs/server2/handlebar_dict_generator.py

Issue 10830115: Injection stuff. (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 a1aa78234c5e9c21a9b6454ef151e5f3df0e3bbd..b1eac2fe82621c5680c6d4b0ca7551893ad68651 100644
--- a/chrome/common/extensions/docs/server2/handlebar_dict_generator.py
+++ b/chrome/common/extensions/docs/server2/handlebar_dict_generator.py
@@ -32,8 +32,7 @@ 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, samples):
- self._samples = samples
+ def __init__(self, json):
clean_json = copy.deepcopy(json)
_RemoveNoDocs(clean_json)
try:
@@ -68,22 +67,18 @@ class HandlebarDictGenerator(object):
{ 'href': ref_dict['href'], 'text': ref_dict['text'], 'rest': rest })
return ''.join(formatted_description)
- def Generate(self):
- 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),
- 'samples': self._FilterSamples(self._samples, self._namespace.name)
- }
- except Exception as e:
- logging.error(e)
- raise
+ def Generate(self, samples):
+ 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),
+ 'samples': self._FilterSamples(samples),
+ }
- def _FilterSamples(self, samples, api_name):
- api_search = '.' + api_name + '.'
+ def _FilterSamples(self, samples):
+ api_search = '.' + self._namespace.name + '.'
return [sample for sample in samples
if any(api_search in api['name'] for api in sample['api_calls'])]
« no previous file with comments | « chrome/common/extensions/docs/server2/api_data_source.py ('k') | chrome/common/extensions/docs/server2/handler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698