Architecture¶
This page describes the internal structure and design of mkdocs-void.
Project Structure¶
mkdocs-void/
βββ void/ # Python package
β βββ __init__.py # Version (0.2.0)
β βββ plugins/
β β βββ void_plugin.py # MkDocs plugin
β βββ templates/
β β βββ base.html # Root HTML template
β β βββ main.html # Content wrapper
β β βββ 404.html # Error page
β β βββ mkdocs_theme.yml # Theme registration
β β βββ partials/ # Reusable HTML partials
β β βββ assets/ # CSS, JS, images
β βββ extensions/ # Reserved
β βββ utilities/ # Reserved
βββ docs/ # Documentation source (Markdown)
βββ logo/ # Project logo
βββ tools/
β βββ build.js # SCSS β CSS build pipeline
β βββ screenshots_gen.py # Screenshot generator
βββ Screenshots/ # Generated screenshots
βββ mkdocs.yml # MkDocs site config
βββ pyproject.toml # Python package config
βββ package.json # Node.js dependencies
βββ requirements.txt # Python dependencies
Components¶
Theme Templates¶
The theme is built from Jinja2 templates:
| Template | Purpose |
|---|---|
base.html |
Root HTML skeleton, loads CSS/JS, defines blocks |
main.html |
Extends base, wraps page content |
404.html |
Glass-styled error page |
partials/header.html |
Sticky header with logo, title, search, repo link |
partials/nav.html |
Sidebar navigation with recursive macro |
partials/content.html |
Renders page.content |
partials/toc.html |
Auto-generated table of contents |
partials/footer.html |
Previous/next links and copyright |
partials/palette.html |
Dark/light mode radio toggle |
partials/search.html |
Full-screen search modal |
partials/progress.html |
Reading progress bar |
partials/javascripts/palette.html |
FOUC prevention (inline early-apply) |
Plugin¶
void_plugin.py is a lightweight MkDocs plugin that:
- Sets theme defaults (language, palette, fonts, glass options) if not configured
- Ensures the
voidkey inthemealways has all required sub-options
It hooks into on_config and modifies the config before templates render.
CSS Architecture¶
The stylesheet is organized in layers:
- Design Tokens β CSS custom properties on
:rootfor colors, spacing, typography, glass, shadows, z-index, transitions - Light Mode Overrides β Token overrides scoped to
[data-md-color-scheme="default"] - Glass Intensity Variants β
light/medium/heavyvia[data-md-void-glass]attribute - Base Resets β Box-sizing, font smoothing, reduced motion
- Dot Matrix Overlay β Radial gradient pattern
- Glass Components β
.void-glass,.void-card - Typography β Display, labels, body, inline code
- Components (
components.scss) β Layout, header, nav, content area, TOC, footer, search, tabs, admonitions, code blocks, tables, scroll utilities, mobile responsive, print styles, MkDocs compatibility - Tabs β
pymdownx.tabbedwithalternate_style, keyboard nav (Arrow keys), localStorage persistence - Task Lists β Custom checkboxes with localStorage persistence
- Mermaid Diagrams β
.void-diagramglass card, loading spinner, error states - Notes Panel β
.void-notes-panel, inline composer, item list, mobile bottom-sheet - UI Primitives β
.void-btn,.void-card,.void-form
JavaScript¶
void.js is a single vanilla ES6+ file (no dependencies) that handles:
- Theme initialization β Reads saved color scheme from localStorage
- Color scheme toggling β Switches
data-md-color-schemeattribute - Palette icon visibility β Shows only the opposite scheme icon
- Mobile navigation β Drawer open/close with overlay
- Search β Loads search index, performs client-side search, renders results, keyboard navigation
- Table of contents tracking β Intersection Observer for active section highlighting
- Scroll behaviors β Header scroll-aware glass, back-to-top button, reading progress
- Code copy buttons β Clipboard API with feedback
- Anchor link headings β Auto-generated anchor links for headings
- Keyboard shortcuts β
/for search,?for help,Escto close - Help modal β Displays available keyboard shortcuts
- Nav toggle β Expands/collapses navigation sections via CSS class
initTabsβ Keyboard navigation (Arrow keys),aria-selectedtoggling, localStorage tab persistenceinitTaskListsβ Checkbox change β localStorage save, restore checked state on loadinitHighlightingβ highlight.js CDN loader,hljs.highlightAll(), theme-aware light/dark swapinitMermaidβ Lazy CDN loader (mermaid@10.9.8), themed rendering, dark/light re-render on scheme changeinitNotesβ Inline note composer, localStorage persistence (3-day TTL), export to MD/JSONinitSidebarToggleβ Sidebar collapse/expand via keyboard shortcutinitUIExamplesβ Button press feedback and form submit validation for interactive component docs; also exposeswindow.voidToastinitMathβ Lazy KaTeX CDN loader (katex@0.16.9), renderspymdownx.arithmatexoutput, strips\(\)/\[\]delimiters
Build Pipeline¶
tools/build.js compiles SCSS to CSS:
npm run buildβ Production (compressed, no sourcemaps)npm run devβ Development (expanded, inline sourcemaps)npm run startβ Watch mode (rebuilds on SCSS changes via chokidar)
CDN Dependencies¶
| Library | Version | Purpose | Loading Strategy |
|---|---|---|---|
| highlight.js | 11.9.0 | Syntax highlighting for code blocks | Lazy β fetched only when <code> blocks are present |
| Mermaid.js | 10.9.8 | Diagram rendering | Lazy β fetched only when .void-diagram fences are present |
| KaTeX | 0.16.9 | Math typesetting (pymdownx.arithmatex) |
Lazy β fetched only when .arithmatex/.math is present |
Both are deferred and conditionally injected by their respective init* functions β no requests on pages without the relevant content.
Design Token System¶
All visual properties are defined as CSS custom properties:
:root {
--void-ink: #000000; /* Background */
--void-text-primary: #ffffff; /* Primary text */
--void-accent: #ff3030; /* Nothing Red */
--void-glass-bg: rgba(255, 255, 255, 0.08); /* Glass fill */
--void-glass-blur: 20px; /* Blur radius */
--void-font-display: 'Space Grotesk';
--void-font-mono: 'Space Mono';
/* ... */
}
Data Flow¶
graph TD
A[Markdown Files] --> B[MkDocs]
B --> C[void_plugin.py]
C --> D[HTML Templates]
D --> E[base.html]
E --> F[Header]
E --> G[Nav]
E --> H[Content]
E --> I[TOC]
E --> J[Footer]
E --> K[Search]
E --> L[CSS]
E --> M[JavaScript]
M --> M1[initTheme]
M --> M2[initTabs]
M --> M3[initTaskLists]
M --> M4[initMermaid]
M --> M5[initNotes]
M --> M6[initHighlighting]
M --> M7[initSidebarToggle]
CDNs[CDN: highlight.js / Mermaid] -.->|lazy load| M6
CDNs -.->|lazy load| M4
M5 --> Notes[Notes Panel]
M5 -.->|localStorage| NL[(notes store)]
M6 -.->|theme swap| HLJS[hljs theme]
N[SCSS Files] --> O[build.js]
O --> P[void.css]
¶
graph TD
A[Markdown Files] --> B[MkDocs]
B --> C[void_plugin.py]
C --> D[HTML Templates]
D --> E[base.html]
E --> F[Header]
E --> G[Nav]
E --> H[Content]
E --> I[TOC]
E --> J[Footer]
E --> K[Search]
E --> L[CSS]
E --> M[JavaScript]
M --> M1[initTheme]
M --> M2[initTabs]
M --> M3[initTaskLists]
M --> M4[initMermaid]
M --> M5[initNotes]
M --> M6[initHighlighting]
M --> M7[initSidebarToggle]
CDNs[CDN: highlight.js / Mermaid] -.->|lazy load| M6
CDNs -.->|lazy load| M4
M5 --> Notes[Notes Panel]
M5 -.->|localStorage| NL[(notes store)]
M6 -.->|theme swap| HLJS[hljs theme]
N[SCSS Files] --> O[build.js]
O --> P[void.css]