def transform_members(node: Node, mode: str, filters: Optional[List[str]] = None): def is_member(kind): if mode in ["method", "function"]: return mode in kind or kind == "generator" else: return mode in kind and "method" not in kind members = [ member for member in node.members if is_member(member.object.kind) ] if not members: return name = mode[0].upper() + mode[1:] + ("es" if mode == "class" else "s") section = Section(name) for member in members: object = member.object kind = object.kind type = get_type(member) if member.docstring and "" in member.docstring: description = member.docstring[""].markdown if "\n\n" in description: description = description.split("\n\n")[0] else: description = "" item = Item(object.name, type, Inline(description), kind) item.markdown, url = "", "" if filters and ("link" in filters or "all" in filters): url = "#" + object.id elif filters and "apilink" in filters: url = "../" + node.object.id + "#" + object.id signature: Dict[str, Any] = {} if object.kind not in ["class", "dataclass"]: args = [item.name for item in object.signature.parameters.items] signature["arguments"] = args else: signature["arguments"] = None item.html = renderer.render_object_member(object.name, url, signature) if filters and "sourcelink" in filters: source_link_from_section_item(item, object) section.items.append(item) node.docstring.set_section(section)
def transform_members(node: Node, mode: str, filters: Optional[List[str]] = None): def is_member(kind): if mode in ["method", "function"]: return mode in kind or kind == "generator" else: return mode in kind and 'method' not in kind members = [ member for member in node.members if is_member(member.object.kind) ] if not members: return name = mode[0].upper() + mode[1:] + ("es" if mode == "class" else "s") section = Section(name) for member in members: object = member.object kind = object.kind type = get_type(member) section_ = member.docstring[""] if section_: markdown = section_.markdown if "\n\n" in markdown: markdown = markdown.split("\n\n")[0] item = Item(name, markdown, type=type, kind=kind) item.markdown, url, signature = "", "", "" if filters and "link" in filters: url = "#" + object.id if object.kind not in ["class", "dataclass"]: signature = "(" + ",".join( object.signature.parameters.keys()) + ")" item.html = renderer.render_object_member(object.name, url, signature) section.items.append(item) node.docstring[name] = section