Documentation System Reference
Complete reference for Babylon’s documentation build system.
For conceptual overview, see Documentation Engine.
Build Commands
Command |
Description |
|---|---|
|
Build HTML documentation to |
|
Live-reload server at |
|
Build both PDF books via XeLaTeX |
|
Build single PDF ( |
|
Run doctest examples in Python code |
|
Remove build artifacts including |
Direct Sphinx Commands
# HTML build
poetry run sphinx-build -b html docs docs/_build/html
# LaTeX source generation
poetry run sphinx-build -b latex docs docs/_build/latex
# PDF compilation (after LaTeX generation)
cd docs/_build/latex && make all-pdf
# Check documentation coverage
poetry run sphinx-build -b coverage docs docs/_build/coverage
# Check for broken links
poetry run sphinx-build -b linkcheck docs docs/_build/linkcheck
Sphinx Extensions
Core Extensions
Extension |
Purpose |
|---|---|
|
Extract docstrings from Python modules |
|
Generate API stub pages automatically |
|
Parse Google/NumPy style docstrings |
|
Add links to highlighted source code |
|
Cross-reference external Sphinx docs |
|
Support |
|
Track documentation coverage |
|
Run doctest blocks in documentation |
Third-Party Extensions
Extension |
Purpose |
|---|---|
|
Include type hints in autodoc output |
|
Parse MyST Markdown files |
|
Render Mermaid diagrams |
MyST Extensions
Enabled in myst_enable_extensions:
myst_enable_extensions = [
"colon_fence", # ::: directive syntax
"deflist", # Definition lists
"fieldlist", # Field lists
"replacements", # Typography replacements
"smartquotes", # Smart quote conversion
"substitution", # Substitution references
"strikethrough", # ~~deleted~~ syntax
"linkify", # Auto-link URLs
"tasklist", # - [ ] checkbox syntax
"attrs_inline", # {#id .class} attributes
"dollarmath", # $math$ and $$math$$
"html_admonition", # HTML-style admonitions
"html_image", # HTML-style images
]
Intersphinx Mappings
External documentation cross-references:
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"pydantic": ("https://docs.pydantic.dev/latest/", None),
"networkx": ("https://networkx.org/documentation/stable/", None),
}
Usage examples:
:py:class:`list`→ Python list class:class:`pydantic.BaseModel`→ Pydantic BaseModel:func:`networkx.betweenness_centrality`→ NetworkX function
PDF Configuration
LaTeX Documents
Two books are generated:
latex_documents = [
# (source, filename, title, author, documentclass)
(
"docs-pdf-index",
"babylon-docs.tex",
"Babylon: The Fall of America",
"Persephone Raskova",
"manual",
),
(
"commentary/index",
"babylon-commentary.tex",
"Babylon: The Fall of America\\\\{\\large Design Philosophy ...}",
"Persephone Raskova",
"manual",
),
]
LaTeX Elements
latex_elements = {
"papersize": "letterpaper",
"pointsize": "11pt",
"extraclassoptions": "openany", # No blank pages before chapters
"fncychap": r"\usepackage[Sonny]{fncychap}",
"printindex": r"\footnotesize\raggedright\printindex",
"preamble": "...", # See Bunker Constructivism Theme below
}
Bunker Constructivism Theme
Complete LaTeX preamble for PDF styling:
% Typography (xelatex fontspec)
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\setsansfont{TeX Gyre Heros}
\setmonofont{TeX Gyre Cursor}
% Color definitions
\usepackage{xcolor}
\definecolor{PhosphorBurn}{HTML}{D40000}
\definecolor{WetConcrete}{HTML}{1A1A1A}
\definecolor{TerminalGlare}{HTML}{F5F5F5}
\definecolor{ExposedCircuitry}{HTML}{FFD700}
\definecolor{ThermalWarning}{HTML}{8B0000}
\definecolor{TheChassis}{HTML}{404040}
\definecolor{TheDust}{HTML}{C0C0C0}
% Hyperlink styling
\hypersetup{
colorlinks=true,
linkcolor=ThermalWarning,
urlcolor=PhosphorBurn,
citecolor=TheChassis,
}
% Section heading colors
\usepackage{sectsty}
\chapterfont{\color{PhosphorBurn}}
\sectionfont{\color{ThermalWarning}}
\subsectionfont{\color{TheChassis}}
% Code block styling
\usepackage{mdframed}
\surroundwithmdframed[
backgroundcolor=WetConcrete,
fontcolor=TerminalGlare,
linecolor=TheChassis,
linewidth=1pt,
]{Verbatim}
Autodoc Configuration
autodoc_default_options = {
"members": True,
"member-order": "bysource",
"special-members": "__init__",
"undoc-members": True,
"exclude-members": "__weakref__",
"show-inheritance": True,
}
autodoc_preserve_defaults = True
autodoc_typehints = "description"
autodoc_typehints_format = "short"
Napoleon (Docstring) Configuration
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = True
napoleon_use_admonition_for_examples = True
napoleon_use_admonition_for_notes = True
napoleon_use_param = True
napoleon_use_rtype = True
napoleon_attr_annotations = True
napoleon_preprocess_types = True
Mermaid Configuration
mermaid_version = "11.4.1"
mermaid_init_config = {
"startOnLoad": True,
"theme": "neutral",
}
# Enable mermaid fences in MyST
myst_fence_as_directive = ["mermaid"]
File Exclusions
Files excluded from documentation build:
exclude_patterns = [
"_build",
"Thumbs.db",
".DS_Store",
# Legacy markdown files not in toctree
"AESTHETICS.md",
"AI_COMMS.md",
"CHANGELOG.md",
# ... (orphan files from migration)
]
Output Artifacts
Build Locations
Path |
Contents |
|---|---|
|
HTML documentation site |
|
LaTeX source and PDF files |
|
Main documentation (~600 pages) |
|
Commentary book (~15 pages) |
|
Documentation coverage report |
|
Broken link report |
Generated Files
The autosummary extension generates stub files in:
docs/api/_autosummary/
├── babylon.ai.rst
├── babylon.config.rst
├── babylon.engine.rst
├── babylon.models.rst
└── ... (all public modules)
These files are auto-generated and should not be manually edited.
Known Limitations
Box-Drawing Characters
The TeX Gyre Cursor font lacks box-drawing characters (└, ─).
ASCII art tree structures in code blocks will show missing character
warnings but render with placeholder glyphs.
Mermaid in PDF
Mermaid diagrams render in HTML but not in PDF. The PDF shows placeholder text. For critical diagrams, use ASCII art or embed static images.
Emoji Support
Emoji characters (🟣, ✅) require font fallback configuration not currently implemented. They appear in HTML but may be missing in PDF.
See Also
Documentation Engine - Conceptual overview
Visual Design Guidelines - Visual design source
Design System Reference - Complete design tokens