API Documentation Specialist
Auto-generate API documentation from source code and specs.
Stop writing API docs by hand. Generate documentation from Python docstrings, CLI help text, and OpenAPI specs—kept in sync automatically.
Tip
Duration: ~60 min | Prerequisite: Python codebase or API spec to document
Track Contents
Section 1: Page Not Found
Could not find page:docs/extending/autodoc/_index
Content Collections
Validate frontmatter with typed schemas
Content Collections
Define typed schemas for your content to ensure consistency and catch errors early.
Do I Need This?
No. Collections are optional. Your site works fine without them.
Use collections when:
- You want typos caught at build time, not in production
- Multiple people edit content and need guardrails
- You want consistent frontmatter across content types
Quick Setup
bengal collections init
This createscollections.pyat your project root. Edit it to uncomment what you need:
1 2 3 4 5 6 | |
Done. Build as normal—validation happens automatically.
Built-in Schemas
Bengal provides schemas for common content types:
| Schema | Required Fields | Optional Fields |
|---|---|---|
BlogPost |
title, date | author, tags, draft, description, image |
DocPage |
title | weight, category, tags, toc, deprecated |
APIReference |
title, endpoint | method, version, auth_required, rate_limit |
Tutorial |
title | difficulty, duration, prerequisites, series |
Changelog |
title, date | version, breaking, summary |
Import any of these:
from bengal.collections import BlogPost, DocPage, APIReference
Custom Schemas
Define your own using Python dataclasses:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Validation Modes
By default, validation warns but doesn't fail builds:
⚠ content/blog/my-post.md
└─ date: Required field 'date' is missing
Strict Mode
To fail builds on validation errors, add tobengal.toml:
1 2 | |
Lenient Mode (Extra Fields)
To allow fields not in your schema:
1 2 3 4 5 | |
CLI Commands
1 2 3 4 5 6 7 8 | |
Migration Tips
Existing site with inconsistent frontmatter?
- Start with
strict=Falseto allow extra fields - Run
bengal collections validateto find issues - Fix content or adjust schema
- Switch to
strict=Truewhen ready
Transform legacy field names:
1 2 3 4 5 6 7 8 9 10 11 12 | |
Remote Content
Collections work with remote content too. Use a loader instead of a directory:
1 2 3 4 5 6 7 8 9 | |
See Content Sources for GitHub, Notion, REST API loaders.
Seealso
- Content Sources — GitHub, Notion, REST API loaders
Deployment
Deploy your Bengal site to production
Deploy Your Site
Bengal generates static HTML, CSS, and JavaScript files. This means you can host your site anywhere that serves static files (e.g., GitHub Pages, Netlify, Vercel, AWS S3, Nginx).
The Production Build
When you are ready to ship, run the build command:
bengal build --environment production
This command:
- Loads configuration from
config/environments/production.yaml(if it exists) - Minifies assets (if enabled)
- Generates the
public/directory with your complete site
Common Build Flags
| Flag | Description | Use Case |
|---|---|---|
--environment production |
Loads production config overrides. | Always use for shipping. |
--strict |
Fails the build on warnings (e.g., broken links). | Highly Recommended for CI/CD. |
--clean-output |
Cleans thepublic/directory before building. |
Recommended to avoid stale files. |
--verbose |
Shows detailed logs. | Useful for debugging CI failures. |
Example full command for CI:
bengal build --environment production --strict --clean-output
GitHub Pages
Deploy using GitHub Actions. Create.github/workflows/deploy.yml:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
Netlify
Create anetlify.tomlin your repository root:
1 2 3 4 5 6 | |
Vercel
Configure your project:
- Build Command:
bengal build --environment production - Output Directory:
public - Ensure your
requirements.txtincludesbengal.
Environment Variables
Bengal allows you to inject environment variables into your configuration using{{ env.VAR_NAME }}syntax in your YAML/TOML config files.
config/environments/production.yaml:
1 2 3 | |
Then setAPI_KEYandANALYTICS_IDin your hosting provider's dashboard.
Pre-Deployment Checklist
Before you merge to main or deploy:
- Run
bengal config doctor: Checks for common configuration issues. - Run
bengal build --strictlocally: Ensures no broken links or missing templates. - Check
config/environments/production.yaml: Ensure yourbaseurlis set to your production domain.
1 2 3 | |
Seealso
- Automate with GitHub Actions — Full CI/CD tutorial
- Configuration — Environment-specific settings
- Performance — Optimize build times