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

Unified Diff: tools/json_schema_compiler/model.py

Issue 39113003: Docserver: Display enum value descriptions in API docs. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 2 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 | « tools/json_schema_compiler/idl_schema_test.py ('k') | tools/json_schema_compiler/test/idl_basics.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/model.py
diff --git a/tools/json_schema_compiler/model.py b/tools/json_schema_compiler/model.py
index 7507ae761ff7edc41770f9dc72c7ffead4197bca..3de975caebe2fe0ad7ef694c9d618fe6fd4d2432 100644
--- a/tools/json_schema_compiler/model.py
+++ b/tools/json_schema_compiler/model.py
@@ -141,7 +141,7 @@ class Type(object):
self.ref_type = json['$ref']
elif 'enum' in json and json_type == 'string':
self.property_type = PropertyType.ENUM
- self.enum_values = [value for value in json['enum']]
+ self.enum_values = [EnumValue(value) for value in json['enum']]
elif json_type == 'any':
self.property_type = PropertyType.ANY
elif json_type == 'binary':
@@ -343,6 +343,20 @@ class Property(object):
unix_name = property(GetUnixName, SetUnixName)
+class EnumValue(object):
+ """A single value from an enum.
+ Properties:
+ - |name| name of the property as in the json.
+ - |description| a description of the property (if provided)
+ """
+ def __init__(self, json):
+ if isinstance(json, dict):
+ self.name = json['name']
+ self.description = json.get('description')
+ else:
+ self.name = json
+ self.description = None
+
class _Enum(object):
"""Superclass for enum types with a "name" field, setting up repr/eq/ne.
Enums need to do this so that equality/non-equality work over pickling.
« no previous file with comments | « tools/json_schema_compiler/idl_schema_test.py ('k') | tools/json_schema_compiler/test/idl_basics.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698