Skip to content
Architecture
Github.com

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 void key in theme always 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:

  1. Design Tokens β€” CSS custom properties on :root for colors, spacing, typography, glass, shadows, z-index, transitions
  2. Light Mode Overrides β€” Token overrides scoped to [data-md-color-scheme="default"]
  3. Glass Intensity Variants β€” light/medium/heavy via [data-md-void-glass] attribute
  4. Base Resets β€” Box-sizing, font smoothing, reduced motion
  5. Dot Matrix Overlay β€” Radial gradient pattern
  6. Glass Components β€” .void-glass, .void-card
  7. Typography β€” Display, labels, body, inline code
  8. Components (components.scss) β€” Layout, header, nav, content area, TOC, footer, search, tabs, admonitions, code blocks, tables, scroll utilities, mobile responsive, print styles, MkDocs compatibility
  9. Tabs β€” pymdownx.tabbed with alternate_style, keyboard nav (Arrow keys), localStorage persistence
  10. Task Lists β€” Custom checkboxes with localStorage persistence
  11. Mermaid Diagrams β€” .void-diagram glass card, loading spinner, error states
  12. Notes Panel β€” .void-notes-panel, inline composer, item list, mobile bottom-sheet
  13. UI Primitives β€” .void-btn, .void-card, .void-form

JavaScript

void.js is a single vanilla ES6+ file (no dependencies) that handles:

  1. Theme initialization β€” Reads saved color scheme from localStorage
  2. Color scheme toggling β€” Switches data-md-color-scheme attribute
  3. Palette icon visibility β€” Shows only the opposite scheme icon
  4. Mobile navigation β€” Drawer open/close with overlay
  5. Search β€” Loads search index, performs client-side search, renders results, keyboard navigation
  6. Table of contents tracking β€” Intersection Observer for active section highlighting
  7. Scroll behaviors β€” Header scroll-aware glass, back-to-top button, reading progress
  8. Code copy buttons β€” Clipboard API with feedback
  9. Anchor link headings β€” Auto-generated anchor links for headings
  10. Keyboard shortcuts β€” / for search, ? for help, Esc to close
  11. Help modal β€” Displays available keyboard shortcuts
  12. Nav toggle β€” Expands/collapses navigation sections via CSS class
  13. initTabs β€” Keyboard navigation (Arrow keys), aria-selected toggling, localStorage tab persistence
  14. initTaskLists β€” Checkbox change β†’ localStorage save, restore checked state on load
  15. initHighlighting β€” highlight.js CDN loader, hljs.highlightAll(), theme-aware light/dark swap
  16. initMermaid β€” Lazy CDN loader (mermaid@10.9.8), themed rendering, dark/light re-render on scheme change
  17. initNotes β€” Inline note composer, localStorage persistence (3-day TTL), export to MD/JSON
  18. initSidebarToggle β€” Sidebar collapse/expand via keyboard shortcut
  19. initUIExamples β€” Button press feedback and form submit validation for interactive component docs; also exposes window.voidToast
  20. initMath β€” Lazy KaTeX CDN loader (katex@0.16.9), renders pymdownx.arithmatex output, strips \(\)/\[\] delimiters

Build Pipeline

tools/build.js compiles SCSS to CSS:

void.scss β†’ sass.compile() β†’ postcss(autoprefixer + cssnano) β†’ void.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';
  /* ... */
}
Override any token in a custom stylesheet to theme the entire site without touching component code.

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]

Back to README