Skip to main content

Generate documentation from Python docstrings, powered by Cacao.

Project description

CacaoDocs

A documentation generator for Python projects, powered by Cacao.

CacaoDocs scans your Python source code, parses docstrings, and generates an interactive documentation app with WebSocket-driven reactivity. No static HTML — your docs are a live app.

Links

Installation

pip install cacaodocs

Quick Start

# Initialize config (optional)
cacaodocs init

# Build docs from your source directory
cacaodocs build ./src -o ./docs

# Serve the generated docs
cacaodocs serve ./docs

Doc Types

CacaoDocs introduces a doc type system — categories that change how docstrings are parsed and displayed. Types can be set explicitly with a Type: directive or auto-detected from decorators.

Built-in Types

Type Description Auto-detected from
function Regular functions and methods Default for all functions
api REST API endpoints @app.get, @router.post, @app.route, etc.
class Python classes Class definitions
page Markdown documentation .md files
config Settings and environment variables Type: config directive
event Webhooks, signals, pub/sub Type: event directive

Function (default)

Standard Google-style docstrings work out of the box:

def hash_password(password: str, salt: str = None) -> str:
    """Hash a password using bcrypt.

    Args:
        password (str): The plaintext password.
        salt (str): Optional salt. Generated if not provided.

    Returns:
        str: The hashed password string.

    Raises:
        ValueError: If password is empty or too short.

    Examples:
        >>> hash_password("mysecretpass")
        '$2b$12$...'
    """

API Endpoints

API endpoints are auto-detected from Flask, FastAPI, and Django REST decorators. You can also use additional API-specific sections:

@app.get("/users/{user_id}")
def get_user(user_id: int):
    """Get a user by ID.

    Path Params:
        user_id (int): The user's unique identifier.

    Query Params:
        include (str): Comma-separated fields to include.

    Response (200):
        id (int): The user ID.
        name (str): Full name.
        email (str): Email address.

    Response (404):
        detail (str): User not found.
    """

Supported frameworks for auto-detection:

  • FastAPI: @app.get, @app.post, @router.put, @router.delete, etc.
  • Flask: @app.route, @blueprint.route
  • Django REST: @api_view

The HTTP method and route path are extracted automatically from the decorator.

Config

Document application settings with type, default values, required flags, and environment variable mappings:

def load_settings():
    """Application settings.

    Type: config

    Fields:
        DEBUG (bool, default=False): Enable debug mode.
        SECRET_KEY (str, required, env=APP_SECRET): Secret key for signing.
        DATABASE_URL (str, required, env=DATABASE_URL): PostgreSQL connection string.
        PORT (int, default=8000): Server port.
    """

Event

Document webhooks, signals, and event handlers:

def on_user_signup(data: dict):
    """User signup event.

    Type: event

    Trigger: When a new user completes registration.

    Payload:
        user_id (int): The new user ID.
        email (str): The user's email.
        plan (str): Selected subscription plan.
    """

Custom Types

Define your own doc types in cacao.yaml:

doc_types:
  cli_command:
    label: "CLI Command"
    icon: "terminal"
    sections:
      - name: "Usage"
        format: code
      - name: "Options"
        format: args
      - name: "Flags"
        format: args

  database_model:
    label: "Model"
    icon: "database"
    sections:
      - name: "Fields"
        format: args
      - name: "Indexes"
      - name: "Relations"

Then use them in your docstrings:

def deploy():
    """Deploy the application.

    Type: cli_command

    Usage:
        deploy --env production --tag v1.2.3

    Options:
        env (str): Target environment.
        tag (str): Version tag to deploy.
    """

Configuration

Create a cacao.yaml in your project root:

title: "My Project"
description: "API Documentation"
version: "1.0.0"
theme: "dark"
github_url: "https://github.com/username/repo"

exclude_patterns:
  - "__pycache__"
  - ".venv"
  - "node_modules"

Features

  • Doc Types — Function, API, Class, Page, Config, Event, and Custom types
  • Auto-Detection — Flask/FastAPI/Django endpoints detected from decorators
  • Call Map — Visualize function call relationships across your codebase
  • Interactive App — Generated docs are a live Cacao app, not static HTML
  • Google-style Docstrings — Extended with API, config, and event sections
  • Custom Types — Define your own doc types via cacao.yaml

Contributing

Contributions are welcome — issues, feature requests, and pull requests.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cacaodocs-0.1.17.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cacaodocs-0.1.17-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file cacaodocs-0.1.17.tar.gz.

File metadata

  • Download URL: cacaodocs-0.1.17.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cacaodocs-0.1.17.tar.gz
Algorithm Hash digest
SHA256 1e5f4093518bae31f72631c07e9fcfd3e0739aaa61d606d622e6d34b2ce57316
MD5 d2a9e8c235acd945e9c5c29dfad09cbc
BLAKE2b-256 827db7d565db70d3a5edf2411047d4d69112e41f78652ced42125f7e2d1d5c9c

See more details on using hashes here.

File details

Details for the file cacaodocs-0.1.17-py3-none-any.whl.

File metadata

  • Download URL: cacaodocs-0.1.17-py3-none-any.whl
  • Upload date:
  • Size: 26.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for cacaodocs-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 d5651c85a7f11481ba8708367700638b0ff56a3ae90832667b1897a3e1c8ad01
MD5 344744ba0736c7dc4820e1bff053029c
BLAKE2b-256 02fb517a3d8f1ac51bac244c925de2af9c95e749bafe12ef19f699d32743a0e1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page