Generate description line(s) for this member
(propname, properties, is_optional, indent, print_type=True, prefix=None)
| 148 | |
| 149 | |
| 150 | def output_member(propname, properties, is_optional, indent, print_type=True, prefix=None): |
| 151 | """Generate description line(s) for this member""" |
| 152 | # Skip hidden properties |
| 153 | if 'hidden' in properties and properties['hidden']: |
| 154 | return |
| 155 | |
| 156 | if ('type' not in properties and 'properties' not in properties and 'oneOf' not in properties and 'untyped' not in properties): |
| 157 | return |
| 158 | |
| 159 | if prefix is None: |
| 160 | prefix = '- ' + fmt_propname(propname) if propname is not None else '-' |
| 161 | output(indent + prefix) |
| 162 | |
| 163 | # We make them explicitly note if they don't want a type! |
| 164 | is_untyped = 'untyped' in properties |
| 165 | |
| 166 | if not is_untyped and print_type: |
| 167 | output_type(properties, is_optional) |
| 168 | |
| 169 | output_range(properties) |
| 170 | |
| 171 | if 'description' in properties: |
| 172 | output(': ') |
| 173 | outputs(properties['description'], '\n ') |
| 174 | |
| 175 | if 'default' in properties: |
| 176 | output(' The default is {}.'.format(esc_underscores(properties['default']) if isinstance(properties['default'], str) else properties['default'])) |
| 177 | |
| 178 | if 'deprecated' in properties: |
| 179 | output(' **deprecated in {}, removed after {}**'.format(properties['deprecated'][0], properties['deprecated'][1] if len(properties['deprecated']) > 1 else deprecated_to_deleted(properties['deprecated'][0]))) |
| 180 | |
| 181 | if 'added' in properties and properties['added'] != 'pre-v0.10.1': |
| 182 | output(' *(added {})*'.format(properties['added'])) |
| 183 | |
| 184 | if 'oneOf' in properties and isinstance(properties['oneOf'], list): |
| 185 | output(':\n') |
| 186 | output_members(properties, indent + ' ') |
| 187 | elif not is_untyped and properties.get('type') == 'object': |
| 188 | output(':\n') |
| 189 | output_members(properties, indent + ' ') |
| 190 | elif not is_untyped and properties.get('type') == 'array': |
| 191 | output(':\n') |
| 192 | output_array(properties['items'], indent + ' ') |
| 193 | else: |
| 194 | output('\n') |
| 195 | |
| 196 | |
| 197 | def output_array(items, indent): |
no test coverage detected