Skip to main content

Build public and gated versions of Sphinx documentation.

Project description

sphinx-gated-content

Build public and gated versions of your Sphinx documentation from the same source tree.

sphinx-gated-content allows you to mark pages as private and generate two different documentation builds:

Build Visible content
Public Public pages + placeholders for gated pages
Gated All pages, including gated content

This is useful for:

  • Subscription-based documentation
  • Freemium products
  • Internal vs public documentation
  • Community vs enterprise documentation
  • Documentation previews

How it works

Mark a page as private:

:private: true

Advanced API
============

This content is subscription-only.

Then choose which build to generate.

Public build

Private pages remain visible in the navigation but:

  • display a lock icon (🔒)
  • show a placeholder page instead of the real content
  • are removed from the search index

Gated build

All pages are rendered normally.

No content is removed or replaced.

Installation

pip install sphinx-gated-content

Quick Start

Enable the extension in your conf.py:

import os

extensions = [
    "sphinx_gated_content",
]

gated_content_public_build = (
    os.getenv("SPHINX_GATED_PUBLIC", "1") == "1"
)

Generate a public build

SPHINX_GATED_PUBLIC=1 \
python -m sphinx -b html docs docs/_build/public

Generate a gated build

SPHINX_GATED_PUBLIC=0 \
python -m sphinx -b html docs docs/_build/gated

Configuration

gated_content_public_build = True
gated_content_private_metadata_key = "private"
gated_content_lock_icon = "🔒"
gated_content_placeholder = "This page is available with a subscription."

# Prevent copying source files in public builds
html_copy_source = not gated_content_public_build

Supported Themes

Currently tested with:

  • Alabaster
  • Read the Docs Theme (sphinx_rtd_theme)
  • Shibuya

Security

sphinx-gated-content removes gated page content from public HTML builds and excludes it from the generated search index.

Additionally, it automatically:

  • Removes the _sources folder (contains original source files)
  • Filters objects.inv to remove references to private pages

You should still verify any additional build outputs you publish, such as:

  • PDFs
  • EPUB files
  • downloadable source archives
  • custom builders
  • static assets generated by third-party extensions

Development

Create a virtual environment:

python -m venv .venv
source .venv/bin/activate

Install dependencies:

python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -e .

Run tests:

python -m pytest

Build the documentation:

python -m sphinx -b html docs docs/_build/html

License

MIT

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

sphinx_gated_content-0.3.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sphinx_gated_content-0.3.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_gated_content-0.3.0.tar.gz.

File metadata

  • Download URL: sphinx_gated_content-0.3.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sphinx_gated_content-0.3.0.tar.gz
Algorithm Hash digest
SHA256 aa072ef4bb1b126c24ade80a56a64f4b3d7c77c955916ee288fa9cd90c5dccfe
MD5 4d2b5364b942cc746dbd201e7e8ace37
BLAKE2b-256 dfb4b47d8a68ed7d75cd97bac5de4af7566dfc0467ebe39486c19e798c6ff469

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_gated_content-0.3.0.tar.gz:

Publisher: publish.yml on accelerat-team/sphinx-gated-content

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_gated_content-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_gated_content-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f33c739be464fa8b64953abdd14330ba8b52471d0d403b43d200582d2a6a7069
MD5 1a6b1994a4485ed58ac1237bedf33f37
BLAKE2b-256 b0036849fceb0ddf595822c9e243abdb9afba5b66ccbede463b1d48c0a487799

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_gated_content-0.3.0-py3-none-any.whl:

Publisher: publish.yml on accelerat-team/sphinx-gated-content

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page