Sphinx Confluence Builder
Sphinx extension to build Confluence® compatible markup format files and optionally publish them to a Confluence instance. It supports both Confluence Cloud and Data Center deployments. The current version is 3.1.0, with regular updates typically following Sphinx and Confluence API changes.
Warnings
- breaking The default editor for Confluence Cloud switched from 'v1' to 'v2' in version 3.0. Users with custom configurations relying on 'v1' might experience rendering issues.
- breaking All deprecated configuration options from 2.x and older versions were completely removed in version 3.0. This includes the `confluence_editor` option being deprecated.
- breaking Support for Python 3.9 was dropped starting with version 2.16 (with v2.15 being the final release to support it).
- deprecated The `confluence_asset_force_standalone` option was removed in version 2.15 as assets are now always standalone. Page-specific editor overrides were also deprecated in version 2.14.
- gotcha It is never recommended to store sensitive authentication information (API tokens or raw passwords) directly in a committed repository.
Install
-
pip install sphinxcontrib-confluencebuilder
Imports
- sphinxcontrib.confluencebuilder
extensions = ['sphinxcontrib.confluencebuilder'] # in conf.py
Quickstart
import os
# --- In conf.py ---
# Add 'sphinxcontrib.confluencebuilder' to your extensions list
extensions = [
'sphinxcontrib.confluencebuilder'
]
# --- Essential Confluence Publishing Configuration ---
# Ensure these are set to enable publishing to Confluence
confluence_publish = True
confluence_space_key = os.environ.get('CONFLUENCE_SPACE_KEY', 'MYSPACE') # Use your Confluence space key
confluence_parent_page = os.environ.get('CONFLUENCE_PARENT_PAGE', 'MyDocumentation') # Top-level page under which docs will be published
confluence_server_url = os.environ.get('CONFLUENCE_SERVER_URL', 'https://example.atlassian.net/wiki/') # Your Confluence URL
confluence_server_user = os.environ.get('CONFLUENCE_SERVER_USER', 'myuser@example.com') # Your Confluence username (email for Cloud)
# Using an API token is highly recommended instead of a password.
# Store securely, e.g., in an environment variable.
# For Confluence Cloud, use confluence_publish_token for API tokens.
# For Data Center, confluence_server_pass can be used for password or PAT.
confluence_publish_token = os.environ.get('CONFLUENCE_PUBLISH_TOKEN', '')
# Optional: Enable dry run to check what would be published without actually publishing
# confluence_publish_dryrun = True
# --- To build and publish from your project root (after conf.py is setup) ---
# Run in your terminal:
# sphinx-build -M confluence . _build -E -a
# or
# python -m sphinx -M confluence . _build -E -a