English tutorial instructions
💾 AI Summary (ChatGPT)
This project enhances MkDocs documentation with AI-driven features like automatic summary generation and intelligent reading statistics. It supports multiple AI services, multi-language summaries, content cleaning, and fallback mechanisms. The tool provides flexible configuration options and intelligent caching. Reading statistics include character counting, code detection, and reading time estimation. Smart features adapt to different environments, recognize languages, and detect content types. Installation involves direct download or Git clone methods. Configuration includes setting up hooks, local configurations, and choosing AI services.
🚀 Supercharge Your MkDocs Documentation with AI!
This project provides powerful MkDocs hooks that add AI-driven summary generation and intelligent reading statistics to your technical documentation and blogs.
🌐 Live Demo: https://wcowin.work/Mkdocs-AI-Summary/
✨ Features¶
🤖 AI Smart Summary¶
- Multi-AI Service Integration: Support for DeepSeek, OpenAI, Claude, Gemini and other mainstream AI services
- Automatic Summary Generation: Generate high-quality 80-120 word intelligent summaries
- Multi-Language Support: Support for Chinese, English, and bilingual summary generation
- Intelligent Content Cleaning: Automatically filter YAML frontmatter, HTML tags, code blocks and other formatting elements
- Fallback Summary Mechanism: Provides keyword-based local summaries when AI services are unavailable
- Intelligent Caching System: 7-day intelligent expiration, avoiding duplicate API calls
- Flexible Configuration: Support precise control at both folder and page levels
📊 Intelligent Reading Statistics (Optional)¶
- Accurate Character Counting: Specially optimized for Chinese and English content recognition
- Smart Code Detection: Recognizes 30+ programming languages and command-line code
- Reading Time Estimation: Intelligent calculation based on language characteristics (Chinese: 400 chars/min, English: 200 words/min)
- Beautiful Information Display: Uses MkDocs Material theme styled info boxes
🚀 Smart Features¶
- Environment Adaptive: Automatically recognizes CI/local environment, locally or deployment both configurable enable/disable
- Automatic Language Recognition: Supports 30+ programming and markup languages
- Content Type Detection: Distinguishes between code, configuration, command-line and other content types
- LRU Cache Optimization: Improves processing performance (Todo)
- Comprehensive Error Handling: Exception handling and logging (Todo)
📦 Quick Installation¶
Method 1: Direct Download (Recommended)¶
Step 1: Download Files
- Download the latest version from Releases page
- Or directly download ai_summary.py
file
Step 2: Create Directory and Place Files
Step 3: Configure MkDocs Theme and Override Path
Method 2: Git Clone¶
Dependencies Installation¶
🚀 Quick Start¶
1. Basic Configuration¶
Step 1: Configure Hooks Make sure ai_summary.py is placed in the docs/overrides/hooks directory, then:
Step 2: Local Configuration
Create a .env
file in the root directory to store API keys (remember to add to .gitignore
):
Check the directory tree structure here:
2. Configure AI Service¶
Choose AI Service Provider:
- 🌟 DeepSeek (Recommended): High cost-performance ratio, excellent Chinese performance
- 🔥 OpenAI: Powerful features, wide support
- ⚡ Claude: Clear logic, excellent text understanding
- 🧠 Gemini: Google's product, multi-language support
Get API Keys:
- DeepSeek - Register to get API key
- ChatAnywhere - Free OpenAI quota
Store the obtained API keys in the .env
file created in the previous step!!!
3. Set Parameters¶
Configure directories that need AI summaries in ai_summary.py
:
4. Local Run and Test¶
5. Deployment Configuration¶
Several Operation Modes:
1. Completely Disabled: No summary generation in both local and CI deployment
2. CI Deployment Only: Disabled locally, generate new summaries in CI deployment
3. Cache Mode: Summaries already generated locally, CI deployment uses cache (Recommended. The above configuration has default CI deployment cache mode, you can choose combinations yourself)
4. Fully Enabled: Both local and CI deployment run (more API consumption)
6. GitHub Secrets Configuration¶
Step 1: Set Repository Secrets
1. Go to GitHub repository → Settings → Secrets and variables → Actions
2. Click New repository secret to add:

Then deploy to GitHub Pages or other platforms.
If there are errors, you can ask ChatGPT or ask questions in Issues.
📖 Usage Guide¶
AI Summary Control¶
Method 1: Page-Level Control (Recommended)¶
In the YAML meta at the top of Markdown files:
Enable AI Summary:
Disable AI Summary:
Method 2: Folder-Level Control¶
🎨 Display Examples¶
AI Summary Display¶
Live Preview:
💰 Cost Information¶
- Single Request: Approximately $0.005-0.008 USD (medium to large documents)
- Monthly Estimate: About $1-5 USD for regular blogs
- Free Quota: Most AI service providers offer free credits for new users
⚙️ Advanced Configuration¶
Custom AI Service¶
Custom Prompts¶
Cache Configuration¶
🌍 Multi-Language Support¶
Language Configuration¶
Supported Languages¶
- Fully Supported: Chinese, English
- Partially Supported: Japanese, Korean, French, German
📊 Performance Optimization¶
Implemented Optimizations¶
- LRU Caching: Function-level caching improves performance
- Precompiled Regex: Faster text processing
- Smart Filtering: Reduces unnecessary API calls
- Content Hashing: Intelligent caching based on content changes
Performance Recommendations¶
- Use
ci_only_cache: true
to only use cache in CI environment - Set
enabled_folders
appropriately to avoid processing unnecessary files - Regularly clean expired cache files
🤝 Contributing Guide¶
How to Contribute¶
- Fork this repository
- Create feature branch
- Commit changes
- Push branch
- Create Pull Request
Development Environment¶
📝 Changelog¶
[v1.3.0] (2025-06-04) - Latest Version¶
Core Improvements¶
- Unified Cache Architecture
- Cache path unified to project root directory .ai_cache
- Local and CI environments use the same cache strategy
- Enhanced CI/CD support, Support CI cache-only mode, significantly reducing deployment time
- Smart recognition of 15+ deployment platforms (GitHub Actions, GitLab CI, etc.)
- Configurable fallback summary mechanism
[v1.2.0] (2025-06-03)¶
✨ Major New Features¶
- Multi-AI Service Support: Integration of DeepSeek, OpenAI, Gemini, Claude
- Environment Adaptive: Automatic recognition of CI/local environment
- Intelligent Caching System: Content hash caching, 7-day automatic expiration
- Security Configuration: GitHub Secrets integration, secure API key management
🔧 Technical Improvements¶
- Unified API Interface: Automatic adaptation to different AI service formats
- Enhanced Error Handling: Comprehensive exception handling mechanisms
- Performance Optimization: LRU caching and regex precompilation
[v1.0.0] (2025-06-01) - Initial Version¶
- 🤖 AI smart summary functionality
- 📖 Reading time statistics functionality
- 💾 Basic caching system
- 🎯 Basic configuration options
🐛 Issue Reporting¶
Encountered a problem? Please report it in Issues.
When reporting, please include: - MkDocs version - Python version - Complete error messages - Reproduction steps - Configuration files (remove sensitive information)
📄 License¶
This project is licensed under the MIT License.
🙏 Acknowledgments¶
Thanks to the following projects and services:
- MkDocs - Excellent static site generator
- Material for MkDocs - Beautiful theme
- DeepSeek - High cost-performance AI API service
- All contributors and users
🔗 Contact Author¶
Telegram¶
WeChat¶

⭐ Project Statistics¶
☕ Support the Project¶
If this project helps you, please give it a ⭐ Star!
📝 Making MkDocs documentation smarter