Standardized documentation configuration and tooling for FairDM-powered research data portals.
fairdm-docs is a reusable Sphinx configuration package that provides:
- Simple CLI tool - Build, preview, and validate documentation with
fairdm-docscommand - Zero-config documentation - Automatically extracts project metadata from
pyproject.toml(PEP 621) - Live preview server - Real-time documentation updates with
fairdm-docs build --live - Link validation - Check for broken links with
fairdm-docs check - Smart defaults - Missing optional fields don't block builds, sensible defaults provided
- Flexible theming - Pre-configured support for Sphinx Book Theme and PyData Sphinx Theme
- Django model documentation - Custom directives for auto-documenting Sample and Measurement models
- Modern features - MyST Markdown, math support, code copy buttons, social sharing, and more
- Developer-friendly - Works out of the box, easy to customize when needed
Add fairdm-docs to your development dependencies:
poetry add --group dev git+https://github.com/FAIR-DM/fairdm-docsOr with a specific theme:
poetry add --group dev "git+https://github.com/FAIR-DM/fairdm-docs[pydata-sphinx-theme]"The simplest way to get started - no configuration files needed!
Prerequisites: Ensure you have a pyproject.toml with at least a [project] section containing name:
[project]
name = "my-project"
version = "0.1.0" # Optional1. Create documentation structure:
your-project/
├── docs/
│ ├── index.md # Required: main documentation file
│ ├── conf.py # Optional: advanced customization
│ └── _static/ # Optional: custom CSS/images
│ └── brand/ # Optional: logo.svg and icon.svg
├── pyproject.toml # Required: project metadata
└── ...
2. Build documentation:
poetry run fairdm-docs buildThat's it! Documentation will be built to docs/_build/html/.
For live preview during development:
poetry run fairdm-docs build --liveThis automatically:
- Reads project metadata from
pyproject.toml - Uses sensible defaults for everything
- Opens a browser with live-reloading
Configure behavior via pyproject.toml:
[tool.fairdm.docs]
source_dir = "docs" # Documentation source (default: "docs")
build_dir = "docs/_build/html" # Output directory (default: "docs/_build/html")
port = 5000 # Live server port (default: 5000)
verbosity = "full" # Options: "full", "quiet", "errors-only"
django = false # Enable Django integration (default: false)Then build as before:
poetry run fairdm-docs buildFor advanced users who need to override Sphinx settings directly, create a docs/conf.py:
from fairdm_docs.conf import *
# Override specific settings
project = "My Custom Project Name" # Override name from pyproject.toml
html_theme = "pydata_sphinx_theme" # Change theme
# Add custom extensions
extensions.extend([
"sphinx.ext.graphviz",
"sphinxcontrib.mermaid",
])
# Customize theme options
html_theme_options.update({
"show_toc_level": 2,
"navbar_align": "left",
})Configuration precedence (highest to lowest):
- Settings in
docs/conf.py(if file exists) [tool.fairdm.docs]inpyproject.toml- Package defaults
Minimum requirements:
pyproject.tomlwith[project]section containingnamedocs/index.mdwith some content
The package automatically extracts metadata from the PEP 621 standard [project] section in your pyproject.toml:
Required fields:
name- Project name (used for documentation title)
Optional fields (with sensible defaults if missing):
version- Project version (default: "0.0.0")authors- Author names for copyright (default: ["Unknown"])description- Short description for meta tagsurls.homepage- Homepage URLurls.repository- Repository URL for GitHub integration
Example pyproject.toml:
[project]
name = "my-research-portal"
version = "1.0.0"
description = "A research data management portal"
authors = [
{name = "Jane Doe", email = "jane@example.com"},
{name = "John Smith"}
]
[project.urls]
homepage = "https://github.com/myorg/my-portal" # or Homepage (case-insensitive)
repository = "https://github.com/myorg/my-portal" # or RepositoryCase-insensitive handling: URL keys like Homepage/homepage and Repository/repository are automatically normalized.
Configure documentation settings in your pyproject.toml without writing Python code:
[tool.fairdm.docs]
theme = "pydata_sphinx_theme" # or "sphinx_book_theme"Configuration precedence:
- Your
docs/conf.pyoverrides (highest priority) [tool.fairdm.docs]in pyproject.toml- Package defaults (lowest priority)
Legacy format note: This package requires PEP 621 [project] section. Projects using only [tool.poetry] metadata must migrate. See Migration Guide below.
The package automatically extracts the following from your pyproject.toml:
- Project name and version
- Authors and copyright
- Homepage URL (for repository links)
- Package description
The following Sphinx extensions are enabled by default:
- sphinx.ext.autodoc - API documentation from docstrings
- autodoc2 - Modern API documentation with MyST rendering
- myst-parser - Markdown support with rich features
- sphinx-copybutton - Copy buttons on code blocks
- sphinx-design - UI components (cards, tabs, grids)
- sphinxext-opengraph - Social media preview cards
- sphinxcontrib-bibtex - Citations and bibliographies
- sphinx-comments - Utterances-based documentation comments
The following MyST extensions are enabled:
- Math equations (amsmath, dollarmath)
- Admonitions and callouts
- Definition lists
- Task lists
- Tables
- HTML elements
- Smart quotes and replacements
The package automatically detects project branding with a fallback chain:
- Checks for
docs/_static/brand/logo.svganddocs/_static/brand/icon.svgin your project - Falls back to default FairDM branding in
fairdm_docs/_static/
To use custom branding, simply place your logo and icon files in docs/_static/brand/.
For FairDM portals, use the autodoc-model directive to document models:
# My Sample Types
```{autodoc-model} myapp.MySample
This generates complete documentation including:
- Model metadata (verbose name, description, keywords)
- Field listings with types, help text, and validators
- Relationships and constraints
- Custom methods
- Automatically ordered based on model configuration
The extension uses Jinja2 templates located in `fairdm_docs/_templates/model.md.jinja` and auto-generates documentation files for all registered models in the `data_models/` directory during the build process.
## Customization
**Note:** These customization options require creating a `docs/conf.py` file (see [Quick Start Option 3](#option-3-advanced-customization)). For simple configuration changes, use `[tool.fairdm.docs]` in `pyproject.toml` instead.
### Override Theme Options
```python
# docs/conf.py
from fairdm_docs.conf import *
html_theme_options.update({
"show_toc_level": 2,
"navbar_align": "left",
"show_nav_level": 1,
})
# docs/conf.py
from fairdm_docs.conf import *
extensions.extend([
"sphinx.ext.graphviz",
"sphinxcontrib.mermaid",
])# docs/conf.py
from fairdm_docs.conf import *
html_css_files = [
"custom.css",
]# docs/conf.py
from fairdm_docs.conf import *
comments_config = {} # Disable UtterancesThe package supports multiple Sphinx themes via poetry extras:
# Sphinx Book Theme (default, always installed)
poetry add --group dev git+https://github.com/FAIR-DM/fairdm-docs
# PyData Sphinx Theme
poetry add --group dev "git+https://github.com/FAIR-DM/fairdm-docs[pydata-sphinx-theme]"To change themes:
# docs/conf.py
from fairdm_docs.conf import *
html_theme = "pydata_sphinx_theme"For best results, your project should have:
pyproject.tomlwith PEP 621[project]section at project rootdocs/directory at project root (sibling topyproject.toml)docs/_static/brand/for custom logo/icon (optional)- GitHub repository for Utterances comments and edit links
Migration note: Projects using only [tool.poetry] metadata must add the [project] section. See Migration Guide below.
The fairdm-docs command-line tool provides a simplified interface for building documentation with sensible defaults.
fairdm-docs buildThis command:
- Reads configuration from
[tool.fairdm.docs]inpyproject.toml(optional) - Uses the package's built-in Sphinx configuration
- Builds HTML documentation to
docs/_build/htmlby default - Works without any configuration in
pyproject.toml
Start a live-reloading preview server for real-time documentation development:
fairdm-docs build --liveThis command:
- Starts a web server on
http://localhost:5000(configurable) - Automatically opens your documentation in a browser
- Watches for file changes and rebuilds automatically
- Hot-reloads the browser when changes are detected
- Press
Ctrl+Cto stop the server
Port Configuration: If port 5000 is already in use, configure a different port:
[tool.fairdm.docs]
port = 8080 # Use any available portThe server will then start on http://localhost:8080.
Validate your documentation for broken links before publishing:
fairdm-docs checkThis command:
- Checks all internal and external links in your documentation
- Reports broken links with file locations and line numbers
- Exits with code 0 if all links are valid
- Exits with code 1 if broken links are found (useful for CI/CD)
Example output when broken links are found:
🔍 Checking documentation for broken links...
❌ Found 2 broken link(s):
docs/api.md:42: [broken] https://nowhere.invalid/: Connection failed
docs/guide.md:15: [broken] https://example.broken/: 404 Not Found
CI/CD Integration: Use in your continuous integration pipeline:
# Example GitHub Actions workflow
- name: Check documentation links
run: poetry run fairdm-docs checkAdd configuration to your pyproject.toml:
[tool.fairdm.docs]
source_dir = "docs" # Source directory (default: "docs")
build_dir = "docs/_build/html" # Output directory (default: "docs/_build/html")
port = 5000 # Port for live server (default: 5000)
verbosity = "full" # Output verbosity: "full", "quiet", or "errors-only"
django = false # Enable Django integration (default: false)By default, Django is disabled to allow documentation builds without Django installed. Enable it when documenting Django models:
[tool.fairdm.docs]
django = true # Enables Django model auto-documentation extensionsWhen django = true:
- Django is imported and configured automatically
autodoc-modelsextension is enabled for documenting Django models- Requires Django to be installed:
poetry add Django
When django = false (default):
- No Django dependency required
- Works in non-Django projects
- Suitable for pure documentation sites
Zero-config build (no pyproject.toml changes needed):
cd your-project
fairdm-docs buildLive preview for development:
fairdm-docs build --live # Opens browser, auto-reloads on changesCustom output directory:
[tool.fairdm.docs]
build_dir = "build/html"Custom port for live server:
[tool.fairdm.docs]
port = 8080Quiet mode for CI/CD:
[tool.fairdm.docs]
verbosity = "quiet"Django project:
[tool.fairdm.docs]
django = true
source_dir = "documentation"| Sphinx Config | Source | Example |
|---|---|---|
project |
project.name |
"fairdm" |
version |
project.version |
"0.1.0" |
copyright |
project.authors |
"2026, Sam" |
html_theme_options["repository_url"] |
project.urls.repository |
"github.com/org/repo" |
Note: URL keys are case-insensitive (e.g., homepage, Homepage, HOMEPAGE all work).
| Config | Default Value |
|---|---|
language |
"en" |
html_theme |
"sphinx_book_theme" |
master_doc |
"index" |
autodoc2_render_plugin |
"myst" |
Breaking change: Version 0.2.0+ requires PEP 621 [project] section in your pyproject.toml.
[tool.poetry]
name = "my-fairdm-portal"
version = "1.0.0"
description = "My research data portal"
authors = ["Your Name <you@example.com>"][project]
name = "my-fairdm-portal"
version = "1.0.0"
description = "My research data portal"
authors = [
{name = "Your Name", email = "you@example.com"}
]
[project.urls]
Homepage = "https://my-portal.org"
Repository = "https://github.com/myorg/my-portal"Cause: Django integration is enabled but Django is not installed.
Solution: Either install Django or disable the integration:
[tool.fairdm.docs]
django = false # Disable Django integrationOr install Django:
poetry add Django # If using Poetry
pip install Django # If using pipCause: Another service is using port 5000 (default live server port).
Solution: Configure a different port:
[tool.fairdm.docs]
port = 8080 # Or any available portCause: sphinx-autobuild is not installed (required for --live flag).
Solution: Install sphinx-autobuild:
poetry add --group dev sphinx-autobuild
# or
pip install sphinx-autobuildCause: Documentation source directory doesn't exist.
Solution: Create the directory and add at least an index.md:
mkdir docs
echo "# My Documentation" > docs/index.mdOr configure a different source directory:
[tool.fairdm.docs]
source_dir = "documentation" # Use your actual docs directoryCause: fairdm-docs cannot locate your project's pyproject.toml file.
How it searches:
- Starts from the documentation source directory (usually
docs/) - Searches upward through parent directories until it finds
pyproject.toml - Stops at the filesystem root if not found
Solution:
- Ensure
pyproject.tomlexists in your project root directory - Run
fairdm-docs buildfrom within your project (or any subdirectory) - Verify the file is named exactly
pyproject.toml(lowercase, no typos)
cd /path/to/your/project
fairdm-docs buildCause: Invalid values in [tool.fairdm.docs] configuration.
Solution: Check error message for specific field and valid values:
port: Must be between 1 and 65535verbosity: Must be "full", "quiet", or "errors-only"source_dirandbuild_dir: Must be valid directory paths
If you encounter issues not covered here:
- Check the GitHub Issues
- Review the examples/ directory for working configurations
- Open a new issue with details about your setup and error message
- Add [project] section to
pyproject.tomlwith requirednamefield - Copy metadata from
[tool.poetry]to[project](use PEP 621 format for authors) - Move URLs to
[project.urls]table (keys are case-insensitive) - Keep [tool.poetry] if you're still using Poetry for dependency management (both sections can coexist)
- Test build: Run
fairdm-docs buildto verify
PEP 621 is the Python packaging standard for project metadata. This migration:
- Aligns with community standards
- Supports build backends beyond Poetry
- Enables case-insensitive URL key handling
- Simplifies metadata extraction logic
Issues and pull requests are welcome! Please see CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License - see LICENSE file for details.
Built for the FairDM ecosystem to standardize documentation across research data portals.