Skip to content

Module

docforge.models.module

Summary

Documentation model representing a Python module or package.

This module defines the Module class used in the doc-forge documentation model. A Module acts as a container for top-level documented objects (classes, functions, variables, and other members) discovered during introspection.

Classes

Module

Module(path: str, docstring: Optional[str] = None)

Representation of a documented Python module or package.

A Module stores metadata about the module itself and maintains a collection of top-level documentation objects discovered during introspection.

Attributes:

Name Type Description
path str

Dotted import path of the module.

docstring Optional[str]

Module-level documentation string, if present.

members Dict[str, DocObject]

Mapping of object names to their corresponding DocObject representations.

Initialize a Module instance.

Parameters:

Name Type Description Default
path str

Dotted import path identifying the module.

required
docstring Optional[str]

Module-level documentation text, if available.

None
Functions
add_object
add_object(obj: DocObject) -> None

Add a documented object to the module.

Parameters:

Name Type Description Default
obj DocObject

Documentation object to register as a top-level member of the module.

required
get_all_objects
get_all_objects() -> Iterable[DocObject]

Return all top-level documentation objects in the module.

Returns:

Type Description
Iterable[DocObject]

Iterable[DocObject]: An iterable of DocObject instances representing the module's public members.

get_object
get_object(name: str) -> DocObject

Retrieve a documented object by name.

Parameters:

Name Type Description Default
name str

Name of the object to retrieve.

required

Returns:

Name Type Description
DocObject DocObject

The corresponding DocObject instance.

Raises:

Type Description
KeyError

If no object with the given name exists.