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.1.0.tar.gz (8.5 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.1.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_gated_content-0.1.0.tar.gz
  • Upload date:
  • Size: 8.5 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.1.0.tar.gz
Algorithm Hash digest
SHA256 4dd719e67a3cf4ddcd3f6c65154e40d220d4767a8117cf152df827b007855442
MD5 fd44d99f8931e4fa174534a2c312bc33
BLAKE2b-256 2002e6c140250ba26f8b55450eed1a225613c9f6c894ed901f0ed266d8ee5994

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for sphinx_gated_content-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cdbeca8d11fd29cbf4da2d21eb27c811a443d31f7b683e95a9783d0611fd74e
MD5 ba091e466554eb686474cf875b27d726
BLAKE2b-256 03a2b6e778c3fc0613995c38bf001516035e2411ccae6f073e1d415987919d04

See more details on using hashes here.

Provenance

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