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

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

Issue 10689117: Extensions Docs Server: Support APIs with properties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b6f1ffd6f9a7c3a16b1519138657a0f3bd7e0859..418549f9bc6a421419fa0fcf8e6393714422b264 100644
--- a/chrome/common/extensions/docs/server2/handlebar_dict_generator.py
+++ b/chrome/common/extensions/docs/server2/handlebar_dict_generator.py
@@ -34,6 +34,12 @@ def _GetLinkToRefType(namespace_name, ref_type):
"text": text
})
+def _FormatValue(value):
+ """Inserts commas every three digits for integer values. It is magic.
not at google - send to devlin 2012/07/09 23:05:34 haha
+ """
+ s = str(value)
+ return ','.join([s[max(0, i - 3):i] for i in range(len(s), 0, -3)][::-1])
+
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.
@@ -51,7 +57,8 @@ class HandlebarDictGenerator(object):
return {
'name': self._namespace.name,
'types': self._GenerateTypes(self._namespace.types),
- 'functions': self._GenerateFunctions(self._namespace.functions)
+ 'functions': self._GenerateFunctions(self._namespace.functions),
+ 'properties': self._GenerateProperties(self._namespace.properties)
}
except Exception as e:
logging.info(e)
@@ -98,6 +105,7 @@ class HandlebarDictGenerator(object):
return {}
callback_dict = {
'name': 'callback',
+ 'description': callback.description,
'simple_type': {'type': 'function'},
'optional': callback.optional,
'parameters': []
@@ -119,14 +127,20 @@ class HandlebarDictGenerator(object):
'name': property_.name,
'optional': property_.optional,
'description': property_.description,
- 'properties': self._GenerateProperties(property_.properties)
+ 'properties': self._GenerateProperties(property_.properties),
+ 'functions': self._GenerateFunctions(property_.functions)
}
self._RenderTypeInformation(property_, property_dict)
return property_dict
def _RenderTypeInformation(self, property_, dst_dict):
dst_dict['type'] = property_.type_.name.lower()
- if property_.type_ == model.PropertyType.CHOICES:
+ if isinstance(property_, model.Property) and property_.has_value:
not at google - send to devlin 2012/07/09 23:05:34 Oh, property_ isn't a Property? Oops. I guess that
cduvall 2012/07/09 23:22:58 Done.
+ if isinstance(property_.value, int):
+ dst_dict['value'] = _FormatValue(property_.value)
+ else:
+ dst_dict['value'] = property_.value
+ elif property_.type_ == model.PropertyType.CHOICES:
dst_dict['choices'] = []
for choice_name in property_.choices:
dst_dict['choices'].append(self._GenerateProperty(
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/handlebar_dict_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698