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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98aebf5b9add4cd56f4b834c34d285e69b18456a927e5f3e8a57d0df16cf4237
|
|
| MD5 |
06b9b7d6b311366d5e2a91b673a08b71
|
|
| BLAKE2b-256 |
03d9aa482b068ee32ebe2cda31e04b06f627161b6f28f1dfa61dcc1662b0eb59
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_gated_content-0.2.0.tar.gz -
Subject digest:
98aebf5b9add4cd56f4b834c34d285e69b18456a927e5f3e8a57d0df16cf4237 - Sigstore transparency entry: 1781685856
- Sigstore integration time:
-
Permalink:
accelerat-team/sphinx-gated-content@9bd371c535c210b686a4b6364209c76571ab27a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/accelerat-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9bd371c535c210b686a4b6364209c76571ab27a8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_gated_content-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sphinx_gated_content-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef63e2eb93728e54f3c567c6d705b1d567192a041edae3e73689ac8379b6aa90
|
|
| MD5 |
03ad663e83f0aeb27fe19d8fe011bbae
|
|
| BLAKE2b-256 |
497bc1d959a98d266110f0d69218429e64182cdde509070779a2e373879d54e0
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_gated_content-0.2.0-py3-none-any.whl -
Subject digest:
ef63e2eb93728e54f3c567c6d705b1d567192a041edae3e73689ac8379b6aa90 - Sigstore transparency entry: 1781685983
- Sigstore integration time:
-
Permalink:
accelerat-team/sphinx-gated-content@9bd371c535c210b686a4b6364209c76571ab27a8 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/accelerat-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9bd371c535c210b686a4b6364209c76571ab27a8 -
Trigger Event:
push
-
Statement type: