added docs strings
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
2026-01-21 01:00:12 +05:30
parent 81e8a8cd49
commit b6e5114532
17 changed files with 563 additions and 25 deletions

View File

@@ -1,25 +1,66 @@
"""
This module defines the Module class, which represents a Python module or package
in the doc-forge documentation model. It acts as a container for top-level
documented objects.
"""
from typing import Dict, Iterable, Optional
from docforge.model.object import DocObject
class Module:
"""Represents a documented Python module."""
"""
Represents a documented Python module or package.
Attributes:
path: Dotted import path of the module.
docstring: Module-level docstring content.
members: Dictionary mapping object names to their DocObject representations.
"""
def __init__(
self,
path: str,
docstring: Optional[str] = None,
) -> None:
"""
Initialize a new Module.
Args:
path: The dotted path of the module.
docstring: The module's docstring, if any.
"""
self.path = path
self.docstring = docstring
self.members: Dict[str, DocObject] = {}
def add_object(self, obj: DocObject) -> None:
"""
Add a documented object to the module.
Args:
obj: The object to add.
"""
self.members[obj.name] = obj
def get_object(self, name: str) -> DocObject:
"""
Retrieve a member object by name.
Args:
name: The name of the object.
Returns:
The requested DocObject.
"""
return self.members[name]
def get_all_objects(self) -> Iterable[DocObject]:
"""
Get all top-level objects in the module.
Returns:
An iterable of DocObject instances.
"""
return self.members.values()