def func(): """Internal link example. * [Section]() --- Imported object. * [](get_docstring) --- Imported object. * [Section.set_html]() --- Member of imported object. * [Section definition](Section) --- Alternative text. """ return Section(), get_docstring(None)
def test_function(add): doc = get_docstring(add) assert len(doc.sections) == 5 assert doc.sections[0].name == "" assert doc.sections[0].markdown.startswith("Returns $") assert doc.sections[1].name == "Parameters" assert doc.sections[1].items[0].name == "x" assert doc.sections[1].items[0].type.name == "int" assert doc.sections[1].items[1].name == "y" assert doc.sections[1].items[1].type.name == "int, optional"
def __post_init__(self): obj = get_origin(self.obj) self.sourcefile, self.lineno = get_sourcefile_and_lineno(obj) prefix, name = split_prefix_and_name(obj) qualname = get_qualname(obj) kind = self.get_kind() signature = get_signature(obj) self.object = Object( prefix=prefix, name=name, qualname=qualname, kind=kind, signature=signature, ) self.docstring = get_docstring(obj) self.obj = obj self.members = self.get_members() for member in self.members: member.parent = self
def test_attributes(): from mkapi.core.base import Base doc = get_docstring(Base) for item in doc['Attributes'].items[:3]: assert item.type.name == 'str' assert item.description