- Rename docforge.loader → docforge.loaders and docforge.model → docforge.models - Update all imports, type stubs, CLI, tests, and documentation references - Align MkDocs navigation and docforge.nav.yml with new package structure - Adjust module docstrings and comments for consistency with pluralized naming
68 lines
1.6 KiB
Python
68 lines
1.6 KiB
Python
"""
|
|
This module defines the Project class, the top-level container for a documented
|
|
project. It aggregates multiple Module instances into a single named entity.
|
|
"""
|
|
|
|
from typing import Dict, Iterable
|
|
|
|
from docforge.models.module import Module
|
|
|
|
|
|
class Project:
|
|
"""
|
|
Represents a documentation project, serving as a container for modules.
|
|
|
|
Attributes:
|
|
name: Name of the project.
|
|
modules: Dictionary mapping module paths to Module instances.
|
|
"""
|
|
|
|
def __init__(self, name: str) -> None:
|
|
"""
|
|
Initialize a new Project.
|
|
|
|
Args:
|
|
name: The name of the project.
|
|
"""
|
|
self.name = name
|
|
self.modules: Dict[str, Module] = {}
|
|
|
|
def add_module(self, module: Module) -> None:
|
|
"""
|
|
Add a module to the project.
|
|
|
|
Args:
|
|
module: The module to add.
|
|
"""
|
|
self.modules[module.path] = module
|
|
|
|
def get_module(self, path: str) -> Module:
|
|
"""
|
|
Retrieve a module by its dotted path.
|
|
|
|
Args:
|
|
path: The dotted path of the module (e.g., 'pkg.mod').
|
|
|
|
Returns:
|
|
The requested Module.
|
|
"""
|
|
return self.modules[path]
|
|
|
|
def get_all_modules(self) -> Iterable[Module]:
|
|
"""
|
|
Get all modules in the project.
|
|
|
|
Returns:
|
|
An iterable of Module objects.
|
|
"""
|
|
return self.modules.values()
|
|
|
|
def get_module_list(self) -> list[str]:
|
|
"""
|
|
Get the list of all module dotted paths.
|
|
|
|
Returns:
|
|
A list of module paths.
|
|
"""
|
|
return list(self.modules.keys())
|