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,3 +1,8 @@
"""
Main entry point for the doc-forge CLI. This module defines the core command
group and the 'tree', 'generate', 'build', and 'serve' commands.
"""
from pathlib import Path
from typing import Sequence, Optional
@@ -10,7 +15,10 @@ from docforge.cli.mkdocs import mkdocs_cmd
@click.group()
def cli() -> None:
"""doc-forge command-line interface."""
"""
doc-forge CLI: A tool for introspecting Python projects and generating
documentation.
"""
pass
@@ -35,7 +43,13 @@ def tree(
modules: Sequence[str],
project_name: Optional[str],
) -> None:
"""Show introspection tree."""
"""
Visualize the project structure including modules and their members.
Args:
modules: List of module paths to introspect.
project_name: Optional project name override.
"""
loader = GriffeLoader()
project = loader.load_project(list(modules), project_name)
@@ -49,6 +63,9 @@ def tree(
def _print_object(obj, indent: str) -> None:
"""
Recursive helper to print doc objects.
"""
click.echo(f"{indent}├── {obj.name}")
for member in obj.get_all_members():
_print_object(member, indent + "")
@@ -78,7 +95,14 @@ def generate(
project_name: Optional[str],
docs_dir: Path,
) -> None:
"""Generate documentation source files using MkDocs renderer."""
"""
Generate Markdown source files for the specified module.
Args:
module: The primary module path to document.
project_name: Optional project name override.
docs_dir: Directory where documentation sources will be written.
"""
loader = GriffeLoader()
discovered_paths = discover_module_paths(
module,
@@ -105,7 +129,12 @@ def generate(
default=Path("mkdocs.yml"),
)
def build(mkdocs_yml: Path) -> None:
"""Build documentation using MkDocs."""
"""
Build the documentation site using MkDocs.
Args:
mkdocs_yml: Path to the mkdocs.yml configuration file.
"""
if not mkdocs_yml.exists():
raise click.ClickException(f"mkdocs.yml not found: {mkdocs_yml}")
@@ -128,7 +157,12 @@ def build(mkdocs_yml: Path) -> None:
default=Path("mkdocs.yml"),
)
def serve(mkdocs_yml: Path) -> None:
"""Serve documentation using MkDocs."""
"""
Serve the documentation site with live-reload using MkDocs.
Args:
mkdocs_yml: Path to the mkdocs.yml configuration file.
"""
if not mkdocs_yml.exists():
raise click.ClickException(f"mkdocs.yml not found: {mkdocs_yml}")
@@ -147,6 +181,9 @@ def serve(mkdocs_yml: Path) -> None:
# ---------------------------------------------------------------------
def main() -> None:
"""
CLI Entry point.
"""
cli()