Index: tools/json_schema_compiler/js_util.py |
diff --git a/tools/json_schema_compiler/js_util.py b/tools/json_schema_compiler/js_util.py |
index 2549aefa2fae4966eee2c0f1fe4fef67667b82a7..740b2fc84586e444f8733b59d9eb54a7df578737 100644 |
--- a/tools/json_schema_compiler/js_util.py |
+++ b/tools/json_schema_compiler/js_util.py |
@@ -101,6 +101,18 @@ class JsUtil(object): |
c.Eblock(' */') |
+ def AppendTypeJsDoc(self, c, namespace_name, js_type, optional): |
Dan Beam
2017/01/11 23:04:26
s/optional/nullable/
optional means {type=} in JS
dmazzoni
2017/01/11 23:23:57
Done.
|
+ """Appends the documentation for a type as a Code. |
+ """ |
+ c.Append('@type {') |
+ js_type_str = self._TypeToJsType(namespace_name, js_type).Render() |
+ if optional: |
+ if js_type_str[0] == '!': |
Dan Beam
2017/01/11 23:04:26
when does a nullable param have a !Type? these ar
dmazzoni
2017/01/11 23:23:57
Exactly, but _TypeToJsType, below, always adds '!'
|
+ js_type_str = js_type_str[1:] |
+ js_type_str = '?' + js_type_str |
+ c.Append(js_type_str, new_line=False) |
+ c.Append('}', new_line=False) |
+ |
def _FunctionToJsFunction(self, namespace_name, function): |
"""Converts a model.Function to a JS type (i.e., function([params])...)""" |
c = Code() |