
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
mkapidocs
Advanced tools
Automated documentation setup tool for Python projects using MkDocs with GitHub Pages or GitLab Pages. Intelligently detects project features (C/C++ code, Typer CLI, private registries) and generates comprehensive MkDocs documentation with Material theme, API references, CI/CD workflows, and docstring linting configuration.
Automated documentation setup tool for Python projects using MkDocs with GitHub Pages or GitLab Pages deployment.
mkapidocs is a Python package that sets up comprehensive MkDocs documentation for Python repositories with auto-detection of features like C/C++ code and Typer CLI interfaces.
mkapidocs automatically:
Install uv if not already installed:
curl -LsSf https://astral.sh/uv/install.sh | sh
The Python project you want to generate documentation for must have:
pyproject.toml file with project metadata (name, description, version, etc.)uv add --dev mkapidocs
See Installation Guide for more options.
# Show help
mkapidocs --help
# Show version
mkapidocs version
# Show package information
mkapidocs info
Initialize or update documentation for a Python project:
# Auto-detect CI provider from git remote or filesystem (current directory)
mkapidocs setup
# Specify a path explicitly
mkapidocs setup /path/to/your/project
# Explicitly use GitHub Actions
mkapidocs setup /path/to/your/project --provider github
# Explicitly use GitLab CI
mkapidocs setup /path/to/your/project --provider gitlab
# Explicitly specify the Pages URL (useful for enterprise GitLab)
mkapidocs setup /path/to/your/project --site-url https://mygroup.pages.gitlab.example.com/myproject
Provider Auto-Detection:
github or gitlab word in the domain (supports enterprise instances).gitlab-ci.yml, .gitlab/, or .github/ directories--provider flag)Site URL Detection (GitLab):
For GitLab projects, mkapidocs can query the GitLab GraphQL API to get the actual Pages URL:
# Set GITLAB_TOKEN for API-based URL detection (requires read_api scope)
GITLAB_TOKEN=glpat-xxx mkapidocs setup /path/to/project
--site-url to explicitly specify the URL and bypass all detectionExample with real paths:
# Setup docs for a project in your home directory
mkapidocs setup ~/repos/my-python-project
# Setup docs for a project in the current directory (default)
mkapidocs setup
# Setup docs with explicit provider
mkapidocs setup ~/repos/my-project --provider gitlab
# Enterprise GitLab with explicit URL
mkapidocs setup ~/repos/my-project --site-url https://team.pages.gitlab.corp.com/my-project
Important: The setup command is non-destructive and safe to run multiple times:
After running setup, you'll see a table showing exactly what was added, updated, or preserved.
This command:
Build static documentation site:
# Build documentation (output to site/ directory)
mkapidocs build /path/to/your/project
# Build with strict mode (warnings as errors)
mkapidocs build /path/to/your/project --strict
# Build to custom output directory
mkapidocs build /path/to/your/project --output-dir /path/to/output
Example:
# Build docs for project in current directory (default)
mkapidocs build
# Build docs with strict checking
mkapidocs build ~/repos/my-project --strict
# Build to custom directory
mkapidocs build ~/repos/my-project --output-dir ~/docs-build
Start local documentation server with live reload:
# Serve on default address (127.0.0.1:8000)
mkapidocs serve /path/to/your/project
# Serve on custom host and port
mkapidocs serve /path/to/your/project --host 0.0.0.0 --port 8080
Example:
# Serve docs locally (current directory)
mkapidocs serve
# Access at http://127.0.0.1:8000
# Press Ctrl+C to stop
# Serve on all interfaces for network access
mkapidocs serve ~/repos/my-project --host 0.0.0.0 --port 9000
For projects with Typer CLI applications, mkapidocs uses the mkdocs-typer2 plugin to generate CLI documentation. This requires importing your CLI module, which means all your project's dependencies must be available.
Recommended approach: Add mkapidocs as a dev dependency in your project:
uv add --dev mkapidocs
Then run build/serve from within your project:
uv run mkapidocs build .
uv run mkapidocs serve .
This ensures mkdocs-typer2 can import your CLI module with all dependencies available, resulting in complete CLI documentation with all commands, arguments, and docstrings.
After running setup, your project will have:
your-project/
├── mkdocs.yml # MkDocs configuration
├── docs/
│ ├── index.md # Homepage (preserved on re-run)
│ ├── about.md # Auto-generated from README.md
│ ├── install.md # Installation guide (preserved on re-run)
│ ├── quick-start-guide.md # Quick start
│ ├── contributing.md # Contributing guide
│ ├── publishing.md # Publishing guide
│ └── generated/ # Auto-generated content (always regenerated)
│ ├── gen_ref_pages.py # API reference generation script
│ ├── index-features.md # Feature list
│ ├── install-registry.md # Private registry instructions (if detected)
│ ├── python-api.md # Python API reference
│ ├── c-api.md # C API reference (if C code detected)
│ └── cli-api.md # CLI reference (if Typer detected)
└── .github/ # For GitHub provider
└── workflows/
└── pages.yml # GitHub Pages workflow
# OR
└── .gitlab/ # For GitLab provider
└── workflows/
└── pages.gitlab-ci.yml # GitLab Pages workflow
Preserved on re-run: index.md, install.md, and user customizations in mkdocs.yml
Always regenerated: Everything in docs/generated/ directory
The script auto-detects:
C/C++ Code: Looks for .c, .h, .cpp, .hpp files in source/ directory
Typer CLI: Checks for typer dependency in pyproject.toml
Private Registry: Checks for [tool.uv.index] in pyproject.toml
Git Remote: Extracts Pages URL from git remote
The script configures MkDocs with:
# 1. Add mkapidocs to your project
cd ~/repos/my-awesome-project
uv add --dev mkapidocs
# 2. Setup documentation
uv run mkapidocs setup
# 3. Preview locally
uv run mkapidocs serve
# Visit http://127.0.0.1:8000
# 4. Build for production
uv run mkapidocs build --strict
# 5. Commit and push (CI will auto-deploy)
git add .
git commit -m "Add MkDocs documentation"
git push
mkapidocs can automatically regenerate documentation on every commit using pre-commit hooks. This keeps your docs in sync with code changes without manual intervention.
Add to your project's .pre-commit-config.yaml:
repos:
- repo: https://github.com/Jamie-BitFlight/mkapidocs
rev: v1.0.0 # Use latest version tag
hooks:
- id: mkapidocs-regen
This hook:
pyproject.toml, or mkdocs.yml changemkapidocs setup to regenerate documentation# Install pre-commit if not already installed
uv tool install pre-commit
# Install the hooks
pre-commit install
# Test it
pre-commit run --all-files
When you commit changes to Python files:
mkapidocs setupdocs/generated/ contentNote: The hook ID is mkapidocs-regen for backward compatibility, but it runs the setup command (which is non-destructive).
After running setup with GitHub provider and pushing to GitHub, the .github/workflows/pages.yml workflow will:
mkapidocs build . --strictThe documentation will be available at: https://your-username.github.io/repo-name/
Note: Enable GitHub Pages in your repository settings and configure it to deploy from GitHub Actions.
After running setup with GitLab provider and pushing to GitLab, the pages job in .gitlab/workflows/pages.gitlab-ci.yml will:
ghcr.io/astral-sh/uv:python3.11 imageuv run mkapidocs build . --strictThe documentation will be available at: https://your-username.gitlab.io/repo-name/
Note: If you already have a pages job in your root .gitlab-ci.yml, mkapidocs will skip creating a new workflow and warn you to update your existing job.
After setup, you can customize:
After customizing mkdocs.yml, you can safely run setup again:
mkapidocs setup /path/to/your/project
The smart merge system will:
extra, custom extensions, etc.)Your customizations are safe!
mkapidocs/
├── packages/
│ └── mkapidocs/ # Main package
│ ├── __init__.py
│ ├── cli.py # Typer CLI application
│ └── ...
├── tests/ # Test suite
├── pyproject.toml # Package configuration
└── README.md
If CLI documentation shows headers but no commands, ensure mkapidocs is installed as a dev dependency in your target project:
cd /path/to/your/project
uv add --dev mkapidocs
uv run mkapidocs build .
This allows mkdocs-typer2 to import your CLI module with all dependencies available.
The build and serve commands require mkdocs.yml to exist. Run setup first:
mkapidocs setup /path/to/project
If git remote is not configured or the provider cannot be determined:
# Explicitly specify the provider
mkapidocs setup /path/to/project --provider github
mkapidocs setup /path/to/project --provider gitlab
The script automatically detects source paths from pyproject.toml and adds them to PYTHONPATH. This allows mkdocstrings to import your package for API documentation generation.
Ensure your target project's pyproject.toml has correct build configuration:
# For Hatch (recommended)
[tool.hatch.build.targets.wheel]
packages = ["packages/mypackage"]
# Or with sources mapping
sources = {"packages/mypackage" = "mypackage"}
# For setuptools
[tool.setuptools.packages.find]
where = ["src"]
If your package is in a non-standard location, the build command may fail to import it. Verify your build configuration matches your actual package structure.
If you use pre-commit with the check-yaml hook, it may fail on mkdocs.yml with an error like:
could not determine a constructor for the tag 'tag:yaml.org,2002:python/name:mermaid2.fence_mermaid_custom'
This happens because mkapidocs generates mkdocs.yml with Python-specific YAML tags (!!python/name:) for the mermaid2 plugin. Add the --unsafe flag to allow these tags:
# In your .pre-commit-config.yaml
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
args: [--unsafe] # Allow Python tags in mkdocs.yml
Unlicense
FAQs
Automated documentation setup tool for Python projects using MkDocs with GitHub Pages or GitLab Pages. Intelligently detects project features (C/C++ code, Typer CLI, private registries) and generates comprehensive MkDocs documentation with Material theme, API references, CI/CD workflows, and docstring linting configuration.
We found that mkapidocs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.