Chromium Code Reviews| 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..bc59e7a1a17ab9ce0850771c90222d1d4693bfc7 100644 |
| --- a/chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
| +++ b/chrome/common/extensions/docs/server2/handlebar_dict_generator.py |
| @@ -34,6 +34,11 @@ def _GetLinkToRefType(namespace_name, ref_type): |
| "text": text |
| }) |
| +def _FormatValue(value): |
| + s = str(value) |
| + return ('<code>%s</code>' % |
|
not at google - send to devlin
2012/07/09 11:01:20
All HTML should be the concern of the templates, n
cduvall
2012/07/09 17:50:40
Done.
|
| + ','.join([s[max(0, i - 3):i] for i in range(len(s), 0, -3)][::-1])) |
|
not at google - send to devlin
2012/07/09 11:01:20
wow this is voodoo...
|
| + |
| 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 +56,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 +104,7 @@ class HandlebarDictGenerator(object): |
| return {} |
| callback_dict = { |
| 'name': 'callback', |
| + 'description': callback.description, |
| 'simple_type': {'type': 'function'}, |
| 'optional': callback.optional, |
| 'parameters': [] |
| @@ -119,11 +126,17 @@ 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) |
| + self._RenderValue(property_.value, property_dict) |
| return property_dict |
| + def _RenderValue(self, value, dst_dict): |
| + if 'simple_type' in dst_dict and isinstance(value, int): |
| + dst_dict['simple_type']['type'] = _FormatValue(value) |
|
not at google - send to devlin
2012/07/09 11:01:20
I think just incorporate this into _RenderTypeInfo
cduvall
2012/07/09 17:50:40
Done.
|
| + |
| def _RenderTypeInformation(self, property_, dst_dict): |
| dst_dict['type'] = property_.type_.name.lower() |
| if property_.type_ == model.PropertyType.CHOICES: |
|
not at google - send to devlin
2012/07/09 11:01:20
here:
if property_.has_value:
if isinstance(pro
cduvall
2012/07/09 17:50:40
Done.
|