OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 | 8 |
9 import third_party.json_schema_compiler.model as model | 9 import third_party.json_schema_compiler.model as model |
10 | 10 |
11 def _RemoveNoDocs(item): | 11 def _RemoveNoDocs(item): |
12 if type(item) == dict: | 12 if type(item) == dict: |
13 if item.get('nodoc', False): | 13 if item.get('nodoc', False): |
14 return True | 14 return True |
15 for key, value in item.items(): | 15 for key, value in item.items(): |
16 if _RemoveNoDocs(value): | 16 if _RemoveNoDocs(value): |
17 del item[key] | 17 del item[key] |
18 elif type(item) == list: | 18 elif type(item) == list: |
19 for i in item: | 19 for i in item: |
20 if _RemoveNoDocs(i): | 20 if _RemoveNoDocs(i): |
21 item.remove(i) | 21 item.remove(i) |
22 return False | 22 return False |
23 | 23 |
24 def _GetLinkToRefType(namespace_name, ref_type): | 24 def _GetLinkToRefType(namespace_name, ref_type): |
25 terms = ref_type.split('.') | 25 terms = ref_type.split('.') |
26 if len(terms) > 1: | 26 if len(terms) > 1: |
27 text = '.'.join(terms[1:]) | 27 text = terms[-1] |
28 href = terms[0] + '.html' + '#type-' + text | 28 href = '.'.join(terms[:-1]) + '.html' + '#type-' + text |
29 else: | 29 else: |
30 href = namespace_name + '.html' + '#type-' +ref_type | 30 href = namespace_name + '.html' + '#type-' +ref_type |
31 text = ref_type | 31 text = ref_type |
32 return ({ | 32 return ({ |
33 "href": href, | 33 "href": href, |
34 "text": text | 34 "text": text |
35 }) | 35 }) |
36 | 36 |
37 def _FormatValue(value): | 37 def _FormatValue(value): |
38 """Inserts commas every three digits for integer values. It is magic. | 38 """Inserts commas every three digits for integer values. It is magic. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 elif property_.type_ == model.PropertyType.ARRAY: | 152 elif property_.type_ == model.PropertyType.ARRAY: |
153 dst_dict['array'] = self._GenerateProperty(property_.item_type) | 153 dst_dict['array'] = self._GenerateProperty(property_.item_type) |
154 elif property_.type_ == model.PropertyType.ENUM: | 154 elif property_.type_ == model.PropertyType.ENUM: |
155 dst_dict['enum_values'] = [] | 155 dst_dict['enum_values'] = [] |
156 for enum_value in property_.enum_values: | 156 for enum_value in property_.enum_values: |
157 dst_dict['enum_values'].append({'name': enum_value}) | 157 dst_dict['enum_values'].append({'name': enum_value}) |
158 if len(dst_dict['enum_values']) > 0: | 158 if len(dst_dict['enum_values']) > 0: |
159 dst_dict['enum_values'][-1]['last'] = True | 159 dst_dict['enum_values'][-1]['last'] = True |
160 else: | 160 else: |
161 dst_dict['simple_type'] = {'simple_type': property_.type_.name.lower()} | 161 dst_dict['simple_type'] = {'simple_type': property_.type_.name.lower()} |
OLD | NEW |