| 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 elif property_.type_ == model.PropertyType.ENUM: | 160 elif property_.type_ == model.PropertyType.ENUM: |
| 161 dst_dict['enum_values'] = [] | 161 dst_dict['enum_values'] = [] |
| 162 for enum_value in property_.enum_values: | 162 for enum_value in property_.enum_values: |
| 163 dst_dict['enum_values'].append({'name': enum_value}) | 163 dst_dict['enum_values'].append({'name': enum_value}) |
| 164 if len(dst_dict['enum_values']) > 0: | 164 if len(dst_dict['enum_values']) > 0: |
| 165 dst_dict['enum_values'][-1]['last'] = True | 165 dst_dict['enum_values'][-1]['last'] = True |
| 166 elif property_.instance_of: | 166 elif property_.instance_of: |
| 167 dst_dict['simple_type'] = property_.instance_of.lower() | 167 dst_dict['simple_type'] = property_.instance_of.lower() |
| 168 else: | 168 else: |
| 169 dst_dict['simple_type'] = property_.type_.name.lower() | 169 dst_dict['simple_type'] = property_.type_.name.lower() |
| OLD | NEW |