def _add_member_documentation(self, section, shape, name=None, is_top_level_param=False, is_required=False, **kwargs): py_type = self._get_special_py_type_name(shape) if py_type is None: py_type = py_type_name(shape.type_name) if is_top_level_param: type_section = section.add_new_section('param-type') type_section.write(':type %s: %s' % (name, py_type)) end_type_section = type_section.add_new_section('end-param-type') end_type_section.style.new_line() name_section = section.add_new_section('param-name') name_section.write(':param %s: ' % name) else: name_section = section.add_new_section('param-name') name_section.write('- ') if name is not None: name_section.style.bold('%s ' % name) type_section = section.add_new_section('param-type') self._document_non_top_level_param_type(type_section, shape) if is_required: is_required_section = section.add_new_section('is-required') is_required_section.style.indent() is_required_section.style.bold('[REQUIRED] ') if shape.documentation: documentation_section = section.add_new_section( 'param-documentation') documentation_section.style.indent() documentation_section.include_doc_string(shape.documentation) self._add_special_trait_documentation(documentation_section, shape) end_param_section = section.add_new_section('end-param') end_param_section.style.new_paragraph()
def _document_non_top_level_param_type(self, type_section, shape): special_py_type = self._get_special_py_type_name(shape) py_type = py_type_name(shape.type_name) type_format = '(%s) -- ' if special_py_type is not None: # Special type can reference a linked class. # Italicizing it blows away the link. type_section.write(type_format % special_py_type) else: type_section.style.italics(type_format % py_type)
def _add_member_documentation(self, section, shape, name=None, is_top_level_param=False, is_required=False, **kwargs): py_type = self._get_special_py_type_name(shape) if py_type is None: py_type = py_type_name(shape.type_name) if is_top_level_param: type_section = section.add_new_section('param-type') type_section.write(':type %s: %s' % (name, py_type)) end_type_section = type_section.add_new_section('end-param-type') end_type_section.style.new_line() name_section = section.add_new_section('param-name') name_section.write(':param %s: ' % name) else: name_section = section.add_new_section('param-name') name_section.write('- ') if name is not None: name_section.style.bold('%s ' % name) type_section = section.add_new_section('param-type') self._document_non_top_level_param_type(type_section, shape) if is_required: is_required_section = section.add_new_section('is-required') is_required_section.style.indent() is_required_section.style.bold('[REQUIRED] ') if shape.documentation: documentation_section = section.add_new_section( 'param-documentation') documentation_section.style.indent() if getattr(shape, 'is_tagged_union', False): tagged_union_docs = section.add_new_section( 'param-tagged-union-docs') note = ( '.. note::' ' This is a Tagged Union structure. Only one of the ' ' following top level keys can be set: %s. ') tagged_union_members_str = ', '.join( ['``%s``' % key for key in shape.members.keys()]) tagged_union_docs.write(note % (tagged_union_members_str)) documentation_section.include_doc_string(shape.documentation) self._add_special_trait_documentation(documentation_section, shape) end_param_section = section.add_new_section('end-param') end_param_section.style.new_paragraph()
def test_double(self): self.assertEqual('float', py_type_name('double'))
def test_float(self): self.assertEqual('float', py_type_name('float'))
def test_long(self): self.assertEqual('integer', py_type_name('long'))
def test_integer(self): self.assertEqual('integer', py_type_name('integer'))
def test_timestamp(self): self.assertEqual('datetime', py_type_name('timestamp'))
def test_blob(self): self.assertEqual('bytes', py_type_name('blob'))
def test_character(self): self.assertEqual('string', py_type_name('character'))
def test_string(self): self.assertEqual('string', py_type_name('string'))
def test_map(self): self.assertEqual('dict', py_type_name('map'))
def test_list(self): self.assertEqual('list', py_type_name('list'))
def test_structure(self): self.assertEqual('dict', py_type_name('structure'))