Module inari.collectors¶
collectors - Store module members, and build markdown documents from docstrings.
Classes¶
BaseCollector¶
class BaseCollector(self, abs_path: str = "", name_to_path: Optional[dict[str, str]] = None)
Base class for collecting objects with docstrings.
Attributes
- name_to_path (
dict[str, str]): Mapping of{"module.name.class": "module/name#class"}. - doc (
str): Docstrings of the object. - abs_path (
str): Absolute path of the object. 
Args
- abs_path (
str): Absolute path of the object. - name_to_path (
dict[str, str]): Mapping of name and path. 
Methods¶
def doc_str(self) -> str
Create documents from its contents.
Returns
str: Created from docstrings and annotations.
ClassCollector¶
class ClassCollector(self, cls: type, abs_path: str, name_to_path: dict[str, str])
Class with methods and properties. Attribute docs should be written in class docstring like this:
Attributes
- cls (
type): Target class. - variables (
list[VariableCollector]): Class properties. - methods (
list[FunctionCollector]): Methods of the class. - hash_ (
str): Used for HTML id. 
Args
- cls (
type): Class to make documents. - abs_path (
str): SeeBaseCollector. - name_to_path (
dict[str, str]): SeeBaseCollector. 
Base classes¶
Methods¶
def doc_str(self) -> str
Create documents from its contents.
Returns
str: Created from docstrings and annotations.
def init_methods(self) -> None
def init_variables(self) -> None
FunctionCollector¶
class FunctionCollector(self, f: Callable[..., Any], name_to_path: dict[str, str], abs_path: str)
Functions and methods.
Attributes
- function (
Callable[..., Any]): Target function. - hash_ (
str): Used for HTML id. 
Args
- f (
Callable[..., Any]): Target function. - abs_path (
str): SeeBaseCollector. - name_to_path (
dict[str, str]): SeeBaseCollector. 
Base classes¶
Methods¶
def doc_str(self) -> str
Create documents from its contents.
Returns
str: Created from docstrings and annotations.
ModuleCollector¶
class ModuleCollector(
    self,
    mod: ModuleType,
    out_dir: Union[str, os.PathLike[str]],
    name_to_path: Optional[dict[str, str]] = None,
    out_name: Optional[str] = None,
    enable_yaml_header: bool = False,)
Module docs, submodules, classes, functions, and variables.
Attributes
- mod (
ModuleType): Module to make documents. - submodules (
dict[str, ModuleCollector]): key-value pair of paths and submodules, wrapped byModuleCollector. - variables (
list[VariableCollector]): list of module-level variables, wrapped byVariableCollector. - classes (
list[ClassCollector]): list of public classes, wrapped byClassCollector. - functions (
list[FunctionCollector]): list of public functions, wrapped byFunctionCollector. - out_dir (
pathlib.Path): Output directly. - filename (
str): Output filename, likeindex.md,submodule.md. - relpaths (
dict[str, tuple[str, str]]): Store relational paths. Seeinari.collectors.ModuleCollector.make_relpaths. - enable_yaml_header (
bool): a flag for deciding whether to include yaml header. 
Args
- mod (
ModuleType): Module to make documents. - out_dir (
Union[str, Path]): Output directory. - name_to_path (
dict): SeeBaseCollector. - out_name (
str): Output file name. - enable_yaml_header (
bool): a flag for deciding whether to include yaml header. 
Base classes¶
Methods¶
def doc_str(self) -> str
Create documents from its contents.
Returns
str: Created from docstrings and annotations.
def init_classes(self) -> None
Find public classes defined in the module.
def init_functions(self) -> None
Find public functions in the module.
def init_submodules(self) -> None
Find submodules.
def init_vars(self) -> None
Find variables having docstrings.
def make_links(self, doc: str) -> str
Create internal link on back-quoted name.
To ignore this, append a space like "foo.bar " .
def make_relpaths(self) -> None
Create mapping between object name to relative path.
`ful.path.to.mod.cls` -> [`cls`](../../mod.md#cls)
def make_yaml_header(self) -> str
Make yaml header from given values.
def remove_old_submodules(self) -> None
Remove documents and collectors of deleted modules.
def write(self) -> None
Write documents to files. Directories are created automatically.
VariableCollector¶
class VariableCollector(
    self,
    var: object,
    name_to_path: dict[str, str],
    abs_path: str,
    name: Optional[str] = None,
    doc: Optional[str] = None,)
Module variables and class properties.
Attributes
- var: Module-level object or class property, not module/class/function.
 - name (
str): Name of the object. 
Args
- var (
object): Target object. - name_to_path (
dict[str, str]): SeeBaseCollector. - abs_path (
str): SeeBaseCollector. - name (
str): Fallback ofvar.__name__. - doc (
str): Fallback ofinspect.getdoc(var). 
Base classes¶
Methods¶
def doc_str(self) -> str
Create documents from its contents.
Returns
str: Created from docstrings and annotations.
Functions¶
is_var¶
def is_var(obj: object) -> bool
Utility for filtering unexpected objects.