Skip to content

mkds_pyfile_parser

Attributes:

Name Type Description
modulename str

the name of the module without the .py extension

content dict

a dictionnary with two keys : functions and classes, each of wich containing a list of the classes and functions in the module with the format : "module.fooclass" or "module.foofunction". content doesn't registers classes internal functions.

Methods

docs.mkds_pyfile_parser.__init__(self, path) special

Constructor method of the class.

Parameters:

Name Type Description Default
path str

The full path to a python file that has been parsed.

required

Returns:

Type Description
mkds_pyfile_parser

An instance of this class.

docs.mkds_pyfile_parser.is_empty(self)

Returns:

Type Description
bool

DESCRIPTION.

docs.mkds_pyfile_parser.visit(self, generic_arg = None)

Takes as argument the output of ast.parse(). Itself takes as argument the str returned by reading a whole .py file. This method is the way we visit every node of the file and on the way, we register the classes and functions names.

Returns:

Type Description
NoneType

Returns None. Use to be able to fill content with the classes and methods of the file.

Examples:

parser = mkds_pyfile_parser(filepath)
parser.visit()
print(parser.content)

Tip

To explude functions/classes from being returned and lead to the creation of a mkdoctrings entry, use the balise : EXCLUDE_FUNC_OR_CLASS_FROM_MKDOCSTRINGS anywhere in the doctring of your function/class. In the same way, a whole module can be excluded by including the balise <EXCLUDE_MODULE_FROM_MKDOCSTRINGS> (with angle brackets) anywhere in the boilerplate at the top of your module.

Back to top