Update docs build script and README for current workflow
Make -W (warnings as errors) opt-in via --strict flag instead of default, and update README to reflect uv-based workflow and current directory structure.
This commit is contained in:
@@ -1,108 +1,60 @@
|
|||||||
# Pipecat Documentation
|
# Pipecat API Documentation
|
||||||
|
|
||||||
This directory contains the source files for auto-generating Pipecat's server API reference documentation.
|
This directory contains the source files for auto-generating Pipecat's API reference documentation.
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
1. Install documentation dependencies:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Make the build scripts executable:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
chmod +x build-docs.sh rtd-test.py
|
|
||||||
```
|
|
||||||
|
|
||||||
## Building Documentation
|
## Building Documentation
|
||||||
|
|
||||||
From this directory, you can build the documentation in several ways:
|
From this directory:
|
||||||
|
|
||||||
### Local Build
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Using the build script (automatically opens docs when done)
|
# Build docs (warnings shown but don't fail the build)
|
||||||
./build-docs.sh
|
cd docs/api && uv run ./build-docs.sh
|
||||||
|
|
||||||
# Or directly with sphinx-build
|
# Build with strict mode (warnings treated as errors)
|
||||||
sphinx-build -b html . _build/html -W --keep-going
|
cd docs/api && uv run ./build-docs.sh --strict
|
||||||
```
|
```
|
||||||
|
|
||||||
### ReadTheDocs Test Build
|
The build script will:
|
||||||
|
|
||||||
To test the documentation build process exactly as it would run on ReadTheDocs:
|
1. Install documentation dependencies via `uv sync --group docs`
|
||||||
|
2. Clean previous build output
|
||||||
```bash
|
3. Run `sphinx-build` to generate HTML documentation
|
||||||
./rtd-test.py
|
4. Open the result in your browser (macOS)
|
||||||
```
|
|
||||||
|
|
||||||
This script:
|
|
||||||
|
|
||||||
- Creates a fresh virtual environment
|
|
||||||
- Installs all dependencies as specified in requirements files
|
|
||||||
- Handles conflicting dependencies (like grpcio versions for Riva)
|
|
||||||
- Builds the documentation in an isolated environment
|
|
||||||
- Provides detailed logging of the build process
|
|
||||||
|
|
||||||
Use this script to verify your documentation will build correctly on ReadTheDocs before pushing changes.
|
|
||||||
|
|
||||||
## Viewing Documentation
|
|
||||||
|
|
||||||
The built documentation will be available at `_build/html/index.html`. To open:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# On MacOS
|
|
||||||
open _build/html/index.html
|
|
||||||
|
|
||||||
# On Linux
|
|
||||||
xdg-open _build/html/index.html
|
|
||||||
|
|
||||||
# On Windows
|
|
||||||
start _build/html/index.html
|
|
||||||
```
|
|
||||||
|
|
||||||
## Directory Structure
|
## Directory Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
.
|
.
|
||||||
├── api/ # Auto-generated API documentation
|
├── api/ # Auto-generated API documentation (created during build)
|
||||||
├── _build/ # Built documentation
|
├── _build/ # Built documentation output
|
||||||
├── _static/ # Static files (images, css, etc.)
|
├── conf.py # Sphinx configuration (mock imports, extensions, etc.)
|
||||||
├── conf.py # Sphinx configuration
|
|
||||||
├── index.rst # Main documentation entry point
|
├── index.rst # Main documentation entry point
|
||||||
├── requirements-base.txt # Base documentation dependencies
|
|
||||||
├── requirements-riva.txt # Riva-specific dependencies
|
|
||||||
├── build-docs.sh # Local build script
|
├── build-docs.sh # Local build script
|
||||||
└── rtd-test.py # ReadTheDocs test build script
|
└── rtd-test.sh # ReadTheDocs test build script (uses pip, not uv)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Notes
|
## How It Works
|
||||||
|
|
||||||
- Documentation is auto-generated from Python docstrings
|
- `conf.py` runs `sphinx-apidoc` during Sphinx's `setup()` phase to generate `.rst` files from Python source
|
||||||
- Service modules are automatically detected and included
|
- Sphinx autodoc imports each module to extract docstrings
|
||||||
- The build process matches our ReadTheDocs configuration
|
- Modules with unavailable dependencies are listed in `autodoc_mock_imports` in `conf.py`
|
||||||
- Warnings are treated as errors (-W flag) to maintain consistency
|
- Napoleon extension converts Google-style docstrings to reStructuredText
|
||||||
- The --keep-going flag ensures all errors are reported
|
|
||||||
- Dependencies are split into multiple requirements files to handle version conflicts
|
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
If you encounter missing service modules:
|
**Module not appearing in docs:**
|
||||||
|
|
||||||
1. Verify the service is installed with its extras: `pip install pipecat-ai[service-name]`
|
1. Check the build output for `autodoc: failed to import` warnings
|
||||||
2. Check the build logs for import errors
|
2. If the module has an unresolvable import dependency, add it to `autodoc_mock_imports` in `conf.py`
|
||||||
3. Ensure the service module is properly initialized in the package
|
3. Verify the module is importable: `uv run python -c "import pipecat.module.name"`
|
||||||
4. Run `./rtd-test.py` to test in an isolated environment matching ReadTheDocs
|
|
||||||
|
|
||||||
For dependency conflicts:
|
**Duplicate object warnings:**
|
||||||
|
|
||||||
1. Check the requirements files for version specifications
|
These come from re-export modules or Sphinx discovering the same class through multiple import paths. Usually cosmetic.
|
||||||
2. Use `rtd-test.py` to verify dependency resolution
|
|
||||||
3. Consider adding service-specific requirements files if needed
|
|
||||||
|
|
||||||
For more information:
|
**Docstring formatting warnings:**
|
||||||
|
|
||||||
- [ReadTheDocs Configuration](.readthedocs.yaml)
|
Docstrings use reStructuredText, not Markdown. Common issues:
|
||||||
- [Sphinx Documentation](https://www.sphinx-doc.org/)
|
- Use `Example::` with indented code blocks, not `` ```python ``
|
||||||
|
- Ensure blank lines between directive content and subsequent sections
|
||||||
|
- Use `Parameters:` (not `Attributes:`) for dataclass field documentation to avoid duplicate entries
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Usage: ./build-docs.sh [--strict]
|
||||||
|
# --strict: Treat warnings as errors (default: warnings only)
|
||||||
|
|
||||||
|
SPHINX_OPTS=""
|
||||||
|
if [ "$1" = "--strict" ]; then
|
||||||
|
SPHINX_OPTS="-W --keep-going"
|
||||||
|
fi
|
||||||
|
|
||||||
# Build docs using uv
|
# Build docs using uv
|
||||||
echo "Installing dependencies with uv..."
|
echo "Installing dependencies with uv..."
|
||||||
uv sync --group docs --all-extras --no-extra gstreamer --no-extra local_smart_turn --no-extra moondream --no-extra mlx-whisper
|
uv sync --group docs --all-extras --no-extra gstreamer --no-extra local_smart_turn --no-extra moondream --no-extra mlx-whisper
|
||||||
@@ -14,8 +22,7 @@ fi
|
|||||||
rm -rf _build
|
rm -rf _build
|
||||||
|
|
||||||
echo "Building documentation..."
|
echo "Building documentation..."
|
||||||
# Build docs matching ReadTheDocs configuration
|
uv run sphinx-build -b html -d _build/doctrees . _build/html $SPHINX_OPTS
|
||||||
uv run sphinx-build -b html -d _build/doctrees . _build/html -W --keep-going
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "Documentation built successfully!"
|
echo "Documentation built successfully!"
|
||||||
|
|||||||
Reference in New Issue
Block a user