Automate Technical Documentation with AI and MkDocs
Job to be done: Automate the generation and enhancement of technical documentation using AI and static site generators
🇳🇬 Ways to use this in Nigeria
Ideas to get you started, adapt to your situation.
- 9-5 employee
As a software engineer, automatically generate and update API documentation for new features, ensuring developers always have current references without manual effort.
- Student
As a final-year computer science student, transform your project's README and code comments into a full, structured documentation website for your open-source contribution or academic submission.
What this is, in plain English
This entry describes an advanced workflow that uses artificial intelligence (AI) to automatically generate and improve technical documentation. Instead of manually writing every page, this system can analyze existing code or basic documentation, identify gaps, and then create new, structured pages. It also enhances these pages with visual elements like diagrams and ensures everything is consistent and correct.
This is not a simple copy-paste recipe because it involves building a custom automation system. The author developed a sophisticated process that combines various tools and scripting to achieve these results. It requires technical skills to set up, configure, and adapt to your specific documentation needs.
The core idea is to transform minimal documentation (like a single README file) into a comprehensive, well-structured website. It handles tasks like breaking down long pages into smaller, focused subpages, adding diagrams, and ensuring all generated content is valid.
What you can use it for
- Generate structured documentation: Automatically create a full documentation website from a few initial files or even a codebase.
- Improve readability: Break down long, complex pages into smaller, easier-to-digest sections for better user experience.
- Add visual aids: Automatically insert diagrams, callouts, and annotations to explain complex concepts more clearly.
- Ensure consistency: Validate that all documentation pages follow a consistent structure and style.
- Automate updates: Keep documentation up-to-date by automatically detecting changes and generating new content.
Tools you need
- MkDocs Material (freemium): A theme for MkDocs, a static site generator that turns plain text files into a website.
- Mermaid (free): A JavaScript-based tool for creating diagrams and flowcharts using simple text definitions.
- GitHub (freemium): A platform for version control and collaborative software development, used here for hosting the documentation and the workflow itself.
- jq (free): A lightweight and flexible command-line JSON processor, used for handling data in scripts.
How it actually works
This workflow is a sophisticated automation pipeline, not a series of manual steps. The author’s full workflow YAML (a configuration file for automation) is available on GitHub, which is the true source of truth for how it operates. To explore it:
- Find the workflow on GitHub: The original blog post links to the author’s GitHub repository where the full workflow is available. You would need to navigate to this repository to see the actual scripts and configuration files.
- Understand the Setup Phase: The workflow begins by analyzing the features of a codebase, detecting gaps in existing documentation, and creating “stub” (placeholder) pages. It then analyzes the size and complexity of existing pages and automatically splits oversized ones into focused subpages. Finally, it discovers all markdown files, including newly split ones.
- Examine the Map Phase: For each documentation page, the system analyzes it for “drift” (inconsistencies or outdated information) and fixes any issues. It then enhances the page with visual features like Mermaid diagrams, admonitions (styled callout blocks), and annotations (numbered callouts on code).
- Review the Reduce Phase: This final phase performs a holistic check. It validates the entire documentation site with a “strict build” (meaning it checks for errors that would stop the site from building). It also checks for structural and feature consistency and validates all Mermaid diagrams using an official renderer, automatically fixing any problems found.
- Study the page splitting logic: The author highlights “Intelligent Page Splitting” as a key innovation. This involves analyzing page structure based on line count, section depth, topic cohesion, and heading boundaries to automatically break large files into smaller, more manageable ones. The excerpt mentions using
findandjqfor exhaustive page discovery, which implies command-line scripting to locate and process files.
Words you’ll see, explained
- AI automation: Using artificial intelligence to perform tasks automatically, in this case, generating and improving documentation.
- Static site generator: A tool that takes content (like markdown files) and templates, then generates a complete, ready-to-host website without needing a database or server-side processing.
- MkDocs: A popular static site generator written in Python, used for building project documentation.
- Mermaid: A tool that lets you create diagrams and flowcharts using simple text commands, which are then rendered as images.
- Admonitions: Special styled blocks in documentation (like “Note”, “Warning”, “Tip”) that draw attention to specific information.
- Annotations: Numbered callouts or highlights within code blocks or text to explain specific parts.
- Page splitting: The process of automatically breaking down a single, long documentation page into multiple smaller, more focused subpages.
- Drift: In documentation, this refers to inconsistencies or outdated information that has diverged from the current state of the project or codebase.
- YAML: (YAML Ain’t Markup Language) A human-friendly data serialization standard often used for configuration files, like defining automation workflows.
- jq: A command-line tool used for processing JSON data, often used in scripts to filter, transform, and extract information from structured data.
Original source
This advanced documentation automation workflow was developed by ankitg12 and shared on the Hackernews platform. The author detailed how they evolved their system to transform the documentation for the popular command-line tool, ripgrep, into a comprehensive website using AI and MkDocs.
Notes & variations
- Do you even need this?: For simpler documentation needs, you might not need such a complex AI-driven automation system. Manually writing markdown files and using a static site generator like MkDocs (without the AI automation) is a much simpler and more accessible approach for many small projects or personal documentation. Tools like Notion or Google Docs can also serve as simpler, collaborative documentation platforms.
- Free-tier limits: While MkDocs, Mermaid, and
jqare free, GitHub’s free tier has limits on private repositories and GitHub Actions (the automation runner). For very large or complex projects, you might hit these limits and need a paid GitHub plan. - Common pitfall: A major challenge with highly automated documentation is ensuring accuracy and relevance. Without careful validation and human oversight, AI-generated content can become outdated or incorrect, leading to “documentation drift” that is harder to detect and fix than if it were manually written. Always build in strong validation steps.