MkDocs plugin to export to Confluence
Project description
MkDocs Confluence Plugin
Version: 1.26.0
Python: >=3.7
A MkDocs plugin that automatically publishes your documentation to Confluence, with advanced navigation matching and semantic page resolution.
Features
- Automatic publishing - Seamlessly export your MkDocs documentation to Confluence
- Navigation matching - Matching between MkDocs navigation and documentation pages, including:
- Support for complex nested navigation structures
- Context-aware matching for pages in subdirectories
- Semantic matching with abbreviation expansion (e.g., "ADRs" → "Architecture Design Records")
- Fuzzy matching as fallback for edge cases
- YAML front matter title recognition
- Flexible configuration - Extensive configuration options for Confluence integration
- Dry-run mode - Test your configuration without publishing
- Debug mode - Detailed logging for troubleshooting
- Footer support - Optional GitHub edit links and auto-generation notices
- Folder structure preservation - Maintains your documentation hierarchy in Confluence
Installation
Install from Source
pip install .
Development Installation
For development with optional dependencies:
pip install -e ".[dev]"
Build from Source
Using modern Python build tools:
python -m build
pip install dist/mkdocs_confluence_plugin-*.whl
Additional MkDocs Plugins (Optional)
Install additional MkDocs plugins as needed for your documentation:
# Popular MkDocs plugins for enhanced documentation
pip install mkdocs-material mkdocs-awesome-nav
pip install mkdocs-build-plantuml-plugin mkdocs-git-revision-date-localized-plugin
Python Requirements
- Python: >=3.7
- Build System: setuptools>=61, wheel, build
Dependencies
Core Dependencies (from pyproject.toml)
- mkdocs - The static site generator this plugin extends
- atlassian-python-api - Confluence API client
- md2cf - Markdown to Confluence markup converter
- mistune - Markdown parser
- requests - HTTP library for API calls
- pyyaml==6.0 - YAML parsing library
- mime - MIME type detection
Testing Dependencies
- pytest==8.0.0 - Testing framework
- pytest-mock==3.12.0 - Mocking utilities for tests
- coverage==7.5 - Code coverage analysis
- pre-commit - Git hook management
Development Dependencies (Optional)
Install with: pip install -e ".[dev]"
- black - Code formatting
- mkdocs - For local testing
- pytest - Testing framework
- coverage - Coverage reporting
- md2cf - Markdown conversion
- atlassian-python-api - Confluence integration
Recommended MkDocs Plugins
These plugins work well with the Confluence plugin but are installed separately:
- mkdocs-awesome-nav - Advanced navigation management with
.nav.ymlfiles - mkdocs-material - Modern Material Design theme
- mkdocs-build-plantuml-plugin - PlantUML diagram support
- mkdocs-git-revision-date-localized-plugin - Git-based page timestamps
Configuration
The plugin is automatically registered as a MkDocs plugin via the entry point:
confluence = "mkdocs_confluence_plugin.plugin:ConfluencePlugin"
Add the plugin to your mkdocs.yml configuration:
plugins:
- awesome-nav:
filename: ".nav.yml"
- confluence:
host_url: https://your-domain.atlassian.net/wiki/rest/api/content
space: YOUR_SPACE_KEY
parent_page_name: 'Documentation Root'
git_base_url: "https://github.com/your-org/your-repo/blob/main"
enable_footer: true
enabled_if_env: MKDOCS_TO_CONFLUENCE
dryrun: false
debug: true
verbose: true
Configuration Options
| Option | Description | Default | Required |
|---|---|---|---|
host_url |
Confluence API endpoint URL | ✅ | |
space |
Confluence space key | ✅ | |
parent_page_name |
Parent page name in Confluence | ✅ | |
git_base_url |
Base URL for Git Server edit links | ||
enable_footer |
Add footer with edit links | false |
|
enabled_if_env |
Environment variable to enable plugin | ||
dryrun |
Test mode without publishing | false |
|
debug |
Enable debug logging | false |
|
verbose |
Enable verbose output | false |
Usage
Basic Usage
- Configure the plugin in your
mkdocs.yml - Set up environment variables for Confluence authentication:
export CONFLUENCE_USERNAME=your-email@domain.com export CONFLUENCE_PASSWORD=your-api-token export MKDOCS_TO_CONFLUENCE=1
- Build and publish your documentation:
mkdocs build
Using with mkdocs-awesome-nav
For complex navigation structures, use mkdocs-awesome-nav with a .nav.yml file:
# docs/.nav.yml
nav:
- Index: index.md
- Support:
- support/*.md
- support/**/*.md
- Technical-Practices:
- Architecture Design Records:
- technical-practices/architecture_design_records/*.md
- technical-practices/architecture_design_records/**/*.md
- Code-Maintainability:
- technical-practices/code-maintainability/*.md
- technical-practices/code-maintainability/**/*.md
- Continuous-Delivery:
- technical-practices/continuous-delivery/*.md
- technical-practices/continuous-delivery/**/*.md
- Monitoring-Observability:
- technical-practices/monitoring-observability/*.md
- technical-practices/monitoring-observability/**/*.md
- Template Files:
- template_files/*.md
- template_files/**/*.md
Environment Setup
Set up the required environment variables for Confluence authentication and plugin configuration:
# Required for Confluence authentication
export CONFLUENCE_USERNAME="your-email@domain.com"
export CONFLUENCE_PASSWORD="your-confluence-api-token"
# Plugin enablement
export MKDOCS_TO_CONFLUENCE=1
# Optional: Override configuration via environment variables
export host_url="https://your-domain.atlassian.net/rest/api/content"
export space_key="YOUR_SPACE_KEY"
export parent_page_name="Documentation Root"
export enable_footer="true"
export dryrun="false"
export debug="true"
export verbose="true"
Required Environment Variables:
CONFLUENCE_USERNAME- Your Confluence/Atlassian emailCONFLUENCE_PASSWORD- Your Confluence API token (not your login password)MKDOCS_TO_CONFLUENCE- Set to1ortrueto enable the plugin
Dry Run Mode
Test your configuration without publishing to Confluence:
plugins:
- confluence:
# ... other config ...
dryrun: true
debug: true
verbose: true
Testing
Run All Tests
Tests are configured via pyproject.toml with optimized settings:
# Run tests with project settings (maxfail=1, no warnings, quiet)
python -m pytest tests/
# Or run with verbose output
python -m pytest tests/ -v
Test Configuration (from pyproject.toml):
- Test directory:
tests/ - Max failures: 1 (stops after first failure)
- Warnings disabled for cleaner output
- Quiet mode by default
Run Specific Test Categories
# Navigation matching tests
python -m pytest tests/test_navigation_matching.py -v
# Similarity and semantic matching tests
python -m pytest tests/test_similarity.py -v
# Title-based matching tests
python -m pytest tests/test_title_based_matching.py -v
# Folder structure tests
python -m pytest tests/test_folder_titles.py -v
# Nested navigation tests
python -m pytest tests/test_nested_matching.py -v
Coverage Report
The project is configured for comprehensive coverage reporting with a minimum threshold:
# Generate coverage report (configured in pyproject.toml)
coverage run --source=src -m pytest -vv tests/
coverage report # Shows missing lines, fails if under 30% coverage
coverage html # Generate HTML report
Coverage Settings (from pyproject.toml):
- Branch coverage enabled
- Source directory:
src - Minimum coverage: 30%
- Shows missing lines in reports
Debug Scripts
The project includes debug scripts for troubleshooting navigation matching:
# Debug navigation matching step-by-step
python debug_step.py
# Debug word extraction and similarity
python debug_words.py
# Debug page collection logic
python debug_collect.py
# Debug navigation flattening
python debug_flatten.py
Code Quality
Code Formatting
We use Black for consistent code formatting:
black .
Linting
We use ruff for fast, comprehensive linting:
ruff check .
Pre-commit Hooks
Install pre-commit hooks for automatic code quality checks:
pre-commit install
Development
Local Development Setup
- Clone the repository
- Install the package with development dependencies:
pip install -e ".[dev]" - Install additional MkDocs plugins if needed:
pip install mkdocs-material mkdocs-awesome-nav - Set up environment variables:
export CONFLUENCE_USERNAME=your-email@domain.com export CONFLUENCE_PASSWORD=your-api-token export MKDOCS_TO_CONFLUENCE=1
- Run tests:
python -m pytest tests/
Build System
The project uses modern Python packaging with pyproject.toml:
# Build distribution packages
python -m build
# Install built package
pip install dist/mkdocs_confluence_plugin-*.whl
Build Configuration:
- Build system: setuptools>=61, wheel, build
- Package discovery: automatic from
src/directory - Entry point:
confluence = "mkdocs_confluence_plugin.plugin:ConfluencePlugin"
Versioning
The project uses semantic versioning with automated releases:
- Version managed in
pyproject.toml - Semantic release configured for automated version bumps
- Current version: 1.26.0
Testing Your Changes
- Run the full test suite:
python -m pytest tests/ -v - Test with a real MkDocs build:
mkdocs build -f mkdocs-test.yml - Use dry-run mode to test Confluence integration without publishing
Contributing
- Ensure all tests pass
- Format code with Black:
black . - Check linting with ruff:
ruff check . - Add tests for new functionality
- Update documentation as needed
Architecture
The plugin provides sophisticated navigation matching through:
- Semantic word extraction - Extracts meaningful words from navigation entries and page paths
- Abbreviation expansion - Recognizes and expands common abbreviations (e.g., "ADRs" → "Architecture Design Records")
- Context-aware matching - Uses folder context and parent page information for better matching
- Multi-stage matching - Title-based, semantic, and fuzzy matching with configurable thresholds
- Robust error handling - Graceful degradation and comprehensive logging
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mkdocs_confluence_plugin-1.27.12.tar.gz.
File metadata
- Download URL: mkdocs_confluence_plugin-1.27.12.tar.gz
- Upload date:
- Size: 33.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31c66694e5fd1305fb3958e2c9947bae1f7a6326fb90c71f5b99e81d999db1b5
|
|
| MD5 |
755690ada1f11ccb9ae326204570a7c5
|
|
| BLAKE2b-256 |
4a9368ae6731e9e4b1a877c6ca8055ee6d8004172f61582a2ef53f17b22822e3
|
File details
Details for the file mkdocs_confluence_plugin-1.27.12-py3-none-any.whl.
File metadata
- Download URL: mkdocs_confluence_plugin-1.27.12-py3-none-any.whl
- Upload date:
- Size: 20.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9c91ff5b6f0e2e050f97b98775d5856985e41be4afa52f4557624ba232bb669
|
|
| MD5 |
03416dc5fcd748d9d61481ce8b36b152
|
|
| BLAKE2b-256 |
f6bca036ae1d0299805f2bffc0406d5a3df84cd1063f3a65ad25fd8705d61a2e
|