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."

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.

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.2.0.tar.gz (9.2 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.2.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_gated_content-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 98aebf5b9add4cd56f4b834c34d285e69b18456a927e5f3e8a57d0df16cf4237
MD5 06b9b7d6b311366d5e2a91b673a08b71
BLAKE2b-256 03d9aa482b068ee32ebe2cda31e04b06f627161b6f28f1dfa61dcc1662b0eb59

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_gated_content-0.2.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_gated_content-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ef63e2eb93728e54f3c567c6d705b1d567192a041edae3e73689ac8379b6aa90
MD5 03ad663e83f0aeb27fe19d8fe011bbae
BLAKE2b-256 497bc1d959a98d266110f0d69218429e64182cdde509070779a2e373879d54e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_gated_content-0.2.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