Sphinx Confluence Builder

3.1.0 · active · verified Wed Apr 15

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

Install

Imports

Quickstart

To quickly get started, add `sphinxcontrib.confluencebuilder` to the `extensions` list in your Sphinx project's `conf.py`. Then, configure the essential publishing options, including your Confluence server URL, space key, and authentication credentials (preferably an API token via environment variable). Finally, execute Sphinx with the `confluence` builder to generate and publish your documentation.

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

view raw JSON →