Microdocs

PyPI Test Python Version License: MIT

Transform your Markdown files into a self-contained HTML documentation site.

Microdocs is a Python tool that converts Markdown files (like README.md and CHANGELOG.md) into a beautiful, single-page HTML documentation site with navigation, table of contents, and syntax highlighting.

✨ Zero Configuration Required - Just point it at your Markdown files and get a beautiful documentation site. No config files, no setup, no dependencies to install.

Features

  • Simple & Fast - Convert multiple Markdown files to HTML with a single command
  • Self-Contained - Generates a single HTML file with all styles embedded (only tocbot loaded from CDN)
  • Beautiful UI - Modern, clean design with Tailwind CSS and Alpine.js
  • Smart Navigation - Single-page app with tab-based navigation between sections
  • Automatic Table of Contents - Generated with tocbot with active heading tracking
  • Dark Mode - Automatic system preference detection with manual toggle
  • Syntax Highlighting - Code blocks with Pygments highlighting for both light and dark themes
  • Responsive Design - Optimized layouts for mobile and desktop
  • Zero Configuration - Works out of the box with sensible defaults
  • Customizable - Use your own HTML templates and CSS styles

Examples

See Microdocs in action with these live documentation sites:

Both sites are generated from Markdown files using Microdocs with the default template.

Installation

uvx microdocs

Using pip

pip install microdocs

Quick Start

Convert your README and CHANGELOG to HTML:

uvx microdocs README.md CHANGELOG.md

This creates index.html in your current directory. Open it in your browser!

Usage Examples

Basic Usage

# Convert a single file
uvx microdocs README.md

# Convert multiple files
uvx microdocs README.md CHANGELOG.md CONTRIBUTING.md

# Specify output file
uvx microdocs README.md -o docs/index.html

# Set custom title
uvx microdocs README.md --title "My Project Docs"

# Add repository link
uvx microdocs README.md --repo-url https://github.com/user/repo

Advanced Usage

# Use custom template
uvx microdocs README.md -t custom-template.html

# Combine options
uvx microdocs README.md CHANGELOG.md \
  -o dist/index.html \
  --title "My Project" \
  --repo-url https://github.com/user/repo \
  -t templates/custom.html

GitHub Actions

Automatically deploy your documentation to GitHub Pages:

- name: Build and deploy documentation
  uses: bartTC/microdocs@v1
  with:
    files: |
      README.md
      CHANGELOG.md
    title: 'My Project'

See full GitHub Actions documentation →

Template System

Microdocs uses Jinja2 templates. The default template includes:

  • Responsive Layout - Two-column design with main content and TOC sidebar
  • Page Navigation - Tab-like navigation between sections
  • Sticky TOC - Table of contents that follows you as you scroll
  • Dark Mode Ready - Styles work well in light and dark themes

Template Variables

Your custom templates have access to:

  • {{ title }} - Document title
  • {{ sections }} - List of sections with:
  • id - Section identifier (from filename)
  • name - Section display name
  • html - Converted HTML content
  • {{ inlined_css }} - CSS content from companion .css file
  • {{ repo_url }} - Repository URL (if provided)
  • {{ build_timestamp }} - Build timestamp in UTC format

Creating Custom Templates

  1. Create an HTML file with Jinja2 template syntax
  2. Optionally create a companion CSS file (same name with .css extension)
  3. Use it with the --template option

Example minimal template:

<!DOCTYPE html>
<html>
<head>
    <title>{{ title }}</title>
    <style>{{ inlined_css }}</style>
</head>
<body>
    <h1>{{ title }}</h1>
    {% for section in sections %}
        <section id="{{ section.id }}">
            <h2>{{ section.name }}</h2>
            {{ section.html|safe }}
        </section>
    {% endfor %}
</body>
</html>

File Support

  • Markdown files (.md, .markdown) - Full markdown processing with extensions
  • Plain text files - Displayed with preserved formatting

Microdocs GitHub Action

Deploy beautiful documentation to GitHub Pages with a single step.

Quick Start

Deploy your documentation to GitHub Pages with a single action:

---
name: Deploy Documentation

"on":
  push:
    branches: [main]

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - uses: actions/checkout@v4

      - name: Build and deploy documentation
        uses: bartTC/microdocs@v1
        with:
          files: |
            README.md
            CHANGELOG.md
          title: 'My Project'

That's it!

  • The action automatically deploys to GitHub Pages by default
  • Repository URL is automatically set from your GitHub context
  • Just enable GitHub Pages (Settings → Pages → Source: GitHub Actions) and push to main

Setup Instructions

  1. Create .github/workflows/deploy-docs.yml with the example above
  2. Enable GitHub Pages:
  3. Go to SettingsPages
  4. Under Source, select GitHub Actions
  5. Push to main - your docs will deploy automatically!

Your documentation will be available at https://<username>.github.io/<repository>/

Inputs

Input Required Default Description
files Yes - Markdown files to process (one per line or space-separated)
title No Auto-detected Documentation title (extracted from first H1)
output No index.html Output HTML file path
template No Default template Path to custom HTML template
repo-url No Auto-detected Repository URL (defaults to current GitHub repo)
deploy No true Automatically deploy to GitHub Pages
artifact-dir No dist Directory for deployment artifacts

Usage Examples

Basic Deployment (Most Common)

- name: Build and deploy documentation
  uses: bartTC/microdocs@v1
  with:
    files: |
      README.md
      CHANGELOG.md
    title: 'My Project'

Multiple Files

You can specify files as a multiline list or space-separated:

# Multiline (recommended)
files: |
  README.md
  CHANGELOG.md
  CONTRIBUTING.md
  CODE_OF_CONDUCT.md

# Or space-separated
files: 'README.md CHANGELOG.md CONTRIBUTING.md'

Build Only (No Deployment)

To just build the documentation without deploying:

- name: Build documentation
  uses: bartTC/microdocs@v1
  with:
    files: 'README.md CHANGELOG.md'
    title: 'My Project Documentation'
    output: 'docs/index.html'
    deploy: false

Custom Template

Use your own HTML template:

- name: Build and deploy documentation
  uses: bartTC/microdocs@v1
  with:
    files: |
      README.md
      CHANGELOG.md
    template: 'templates/custom.html'

Custom Repository URL

Override the automatic repository URL:

- name: Build and deploy documentation
  uses: bartTC/microdocs@v1
  with:
    files: 'README.md'
    repo-url: 'https://github.com/myorg/myrepo'

Different Output Directory

Change where the HTML file is generated:

- name: Build and deploy documentation
  uses: bartTC/microdocs@v1
  with:
    files: 'README.md CHANGELOG.md'
    output: 'public/docs.html'

Custom Artifact Directory

Change the directory used for deployment artifacts:

- name: Build and deploy documentation
  uses: bartTC/microdocs@v1
  with:
    files: 'README.md'
    artifact-dir: '_site'

Complete Workflow Example

Here's a complete workflow with all options:

---
name: Deploy Documentation

"on":
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Build and deploy documentation
        uses: bartTC/microdocs@v1
        with:
          files: |
            README.md
            CHANGELOG.md
            CONTRIBUTING.md
          title: 'My Awesome Project'
          template: 'templates/custom.html'
          output: 'docs/index.html'

How It Works

The action performs these steps:

  1. Installs uv - Fast Python package installer
  2. Builds documentation - Converts Markdown files to HTML using microdocs
  3. Prepares artifacts (if deploy is true) - Copies the generated HTML to the artifact directory
  4. Configures GitHub Pages (if deploy is true) - Sets up GitHub Pages deployment
  5. Uploads artifacts (if deploy is true) - Uploads the HTML to GitHub Pages
  6. Deploys (if deploy is true) - Publishes to GitHub Pages

Requirements

  • Repository: Must be a GitHub repository
  • Branch: Typically deployed from main or master
  • Permissions: The workflow needs pages: write and id-token: write permissions
  • GitHub Pages: Must be enabled in repository settings with source set to "GitHub Actions"

Troubleshooting

"pages build and deployment" failing

Make sure you've enabled GitHub Pages in your repository settings: 1. Go to SettingsPages 2. Under Source, select GitHub Actions

Permission denied errors

Ensure your workflow has the correct permissions:

permissions:
  contents: read
  pages: write
  id-token: write

Files not found

Make sure the file paths are relative to your repository root:

# ✅ Correct
files: 'README.md'

# ❌ Wrong
files: '/README.md'

Custom template not found

Ensure the template path is relative to your repository root and the file exists:

# ✅ Correct
template: 'templates/custom.html'

More Information

Changelog

Version 1.1.0 (2025-01-13)

Added

  • Internal link rewriting - Automatically converts markdown file links to section navigation
  • Links to files that are included as sections (e.g., [CHANGELOG](CHANGELOG.md)) are rewritten to section anchors (#changelog)
  • Preserves external links and links to files that aren't sections
  • Centralized hash link monitoring with Alpine.js integration
  • Clicking any hash link now properly triggers section switching without page reloads
  • Added 4 tests for link rewriting functionality in test_builder.py

Version 1.0.0 (2025-11-13)

🎉 First stable release! Microdocs is now production-ready with comprehensive test coverage, CI/CD workflows, and a stable API.

Added

  • Comprehensive test suite with 57 tests covering all functionality
  • test_builder.py - Tests for low-level conversion and building functions (25 tests)
  • test_cli.py - Tests for CLI interface functionality (19 tests)
  • test_templates.py - Tests for template rendering and integration (13 tests)
  • Uses pytest functions with fixtures following best practices
  • All tests pass linting with ruff
  • Continuous Integration workflows
  • .github/workflows/test.yml - Runs tests across Python 3.11, 3.12, 3.13, 3.14
  • .github/workflows/lint.yml - Runs ruff check and format verification
  • Testing infrastructure
  • runtests.sh - Executable script to run tests across all Python versions
  • Comprehensive testing documentation in CLAUDE.md
  • README badges - Added PyPI version, test status, Python version support, and license badges

Changed

  • Development status upgraded from Beta to Production/Stable
  • Enhanced PyPI classifiers with better categorization for documentation and text processing

Deployment

# Using uv (recommended)
uvx microdocs@1.0 README.md CHANGELOG.md

# Using pip
pip install --upgrade microdocs

Version 0.3.0 (2025-11-13)

Added

  • GitHub Action for one-step documentation deployment
  • Composite action that builds and deploys documentation to GitHub Pages
  • Auto-detects repository URL from GitHub context
  • Configurable inputs: files, title, output, template, repo-url, deploy, artifact-dir
  • Deploy enabled by default for seamless GitHub Pages deployment
  • Can be used for build-only workflows with deploy: false
  • Uses uvx for zero-installation execution
  • Comprehensive documentation in ACTION.md
  • Local testing workflow - Test action locally with act tool
  • Testing guide (TESTING.md) - Complete guide for testing the action locally with act

Fixed

  • Dark mode typography - Improved readability in dark mode
  • Blockquotes now use readable light gray text instead of dark blue
  • Table borders use softer medium gray instead of harsh light colors
  • Table headers properly use light gray text for better visibility
  • All fixes properly scoped within @utility prose block in Tailwind CSS

Deployment

# Using uv (recommended)
uvx microdocs@0.3 README.md CHANGELOG.md

# Using pip
pip install --upgrade microdocs

Version 0.2.0 (2025-11-13)

Fixed

  • Package distribution - Templates are now properly included in the package
  • Moved templates/ directory into microdocs/templates/
  • Fixed template path resolution in builder
  • uvx microdocs now works correctly without local installation

Changed

  • Typography improvements
  • Updated to Roboto Slab for headlines (professional serif font)
  • Roboto for body text (clean and readable)
  • IBM Plex Mono for code (excellent readability and character distinction)
  • Code formatting - Removed decorative backticks from inline code tags for cleaner appearance
  • Output handling - Changed from print() to sys.stdout.write() for better stream control

Added

  • GitHub Actions workflow for automatic deployment to GitHub Pages
  • Complete example showing how to use Microdocs in CI/CD
  • Comprehensive documentation and comments
  • Uses uvx microdocs@latest for zero-installation deployment
  • Step-by-step setup instructions included
  • Demonstrates best practices for deploying documentation

Deployment

# Using uv (recommended)
uvx microdocs@0.2 README.md CHANGELOG.md

# Using pip
pip install --upgrade microdocs

Version 0.1.0 (2025-11-13)

Initial release of Microdocs - a Python tool that transforms Markdown files into beautiful, self-contained HTML documentation sites.

Features

  • Markdown to HTML conversion with full markdown extension support
  • Tables, fenced code blocks, syntax highlighting
  • Extra features (abbreviations, definition lists)
  • Automatic heading ID generation
  • Single-page application with tab-based navigation
  • Smooth transitions between sections
  • Sticky header with desktop and mobile layouts
  • No page reloads when switching sections
  • Automatic table of contents
  • Generated with tocbot
  • Active heading tracking on scroll
  • Nested heading support (H1-H6)
  • Automatically hidden when no headings present
  • Beautiful UI with Tailwind CSS and Alpine.js
  • Modern, clean design inspired by GitHub
  • Responsive mobile and desktop layouts
  • Smooth scrolling and transitions
  • Dark mode support
  • Automatic detection of system preference
  • Manual toggle with persistent localStorage
  • Optimized syntax highlighting for both themes
  • Self-contained output
  • Single HTML file with embedded CSS
  • No external dependencies at runtime
  • Easy to deploy anywhere
  • Customizable
  • Custom HTML templates with Jinja2
  • Custom CSS styling
  • Optional repository link in header
  • Custom documentation title
  • Developer-friendly
  • Clean, well-documented Python code
  • Type hints throughout
  • Comprehensive docstrings
  • Ruff linting with "ALL" rules enabled
  • Footer with attribution
  • Build timestamp (UTC)
  • Link to Microdocs project

Installation

# Using uv (recommended)
uvx microdocs

# Using pip
pip install microdocs

Usage

# Convert markdown files to HTML
microdocs README.md CHANGELOG.md -o docs/index.html

# With custom title and repository link
microdocs README.md --title "My Docs" --repo-url https://github.com/user/repo