CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pdoc

API Documentation for Python Projects with focus on simplicity and automatic HTML generation from docstrings

Pending
Overview
Eval results
Files

main-api.mddocs/

Main Documentation Generation API

Core functionality for generating documentation from Python modules using the primary pdoc() function with flexible output options.

Capabilities

Primary Documentation Function

The main entry point for generating documentation from Python modules, supporting both HTML string output and file-based output to directories.

def pdoc(*modules: Path | str, output_directory: Path | None = None) -> str | None:
    """
    Render the documentation for a list of modules.

    Parameters:
    - modules: Module names (str) or file paths (Path) to document
    - output_directory: Directory path for HTML output. If None, returns HTML string for first module

    Returns:
    - str: HTML documentation for first module if output_directory is None
    - None: if output_directory is specified (writes files to disk)
    
    Notes:
    - Rendering options configured via pdoc.render.configure()
    - Creates index.html and search.js when output_directory specified
    - All specified modules documented together for cross-linking
    """

Usage Examples

Generate HTML string for single module:

import pdoc

# Get HTML documentation as string
html_docs = pdoc.pdoc("my_package")
print(html_docs)  # HTML content for my_package

Save documentation to files:

import pdoc
from pathlib import Path

# Write HTML files to docs directory
pdoc.pdoc("my_package", "subpackage", output_directory=Path("./docs"))
# Creates: docs/my_package.html, docs/subpackage/*.html, docs/index.html, docs/search.js

Configure rendering before generation:

import pdoc

# Configure rendering options
pdoc.render.configure(
    docformat="google",
    show_source=True,
    math=True,
    mermaid=True
)

# Generate with custom settings
pdoc.pdoc("my_package", output_directory=Path("./api-docs"))

Module Access

Direct access to pdoc's sub-modules for advanced usage.

from pdoc import doc, extract, render

The main pdoc module exposes three key sub-modules:

  • doc: Documentation object model
  • extract: Module loading and discovery
  • render: HTML template rendering

Integration Patterns

Custom Processing Pipeline

import pdoc

# Configure rendering options
pdoc.render.configure(
    docformat="google",
    show_source=True,
    template_directory="./custom_templates"
)

# Process multiple related packages
modules = ["core_package", "extensions", "utils"]
pdoc.pdoc(*modules, output_directory="./complete_docs")

Web Development Workflow

import pdoc
from pathlib import Path

def generate_docs():
    """Generate documentation for development"""
    pdoc.render.configure(
        docformat="markdown",
        show_source=True,
        math=True
    )
    
    return pdoc.pdoc("my_project")  # Returns HTML for preview

# Use with web framework
html_content = generate_docs()

Install with Tessl CLI

npx tessl i tessl/pypi-pdoc

docs

ast-processing.md

cli-interface.md

doc-objects.md

docstring-processing.md

html-rendering.md

index.md

main-api.md

module-extraction.md

search.md

web-server.md

tile.json