Skip to main content

This Sphinx extension allows for the `feature-flag` directive to hide/show content based on build-time flags.

Project description

Sphinx Extension: Feature Flags

PyPI PyPI - License

Description

This Sphinx extension allows for the feature-flag directive to show (if True) or fallback (if False and using the :fallback: option).

Setup

  1. Add the following to your conf.py:

    import sys, os
    
    sys.path.append(os.path.abspath(os.path.join('_extensions', 'sphinx_feature_flags')))
    extensions = ['sphinx_feature_flags']
    
    feature_flags = {
        'production-stage': False,  # Example
    }
    

Usage

In any .rst file, wrap the feature-flag directive around any block:

```rst
.. feature-flag:: dev-debug-mode

   This only shows if production-stage = True; it can be an entire toctree, too!

.. feature-flag:: dev-debug-mode
   :fallback:

   This only shows if production-stage = False.
```

Requirements

  • Python>=3.6
  • Sphinx>=1.8

This may work with older versions, but has not been tested.

Entry Point

See setup(app) definition at sphinx_feature_flags.py.

Tested in

  • Windows 11 via PowerShell 7
  • Ubuntu 22.04 via ReadTheDocs (RTD) CI

Notes

  • __init__.py is required for both external pathing and to treat the directory as a pkg

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_feature_flags-1.0.7.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

sphinx_feature_flags-1.0.7-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_feature_flags-1.0.7.tar.gz.

File metadata

  • Download URL: sphinx_feature_flags-1.0.7.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.16

File hashes

Hashes for sphinx_feature_flags-1.0.7.tar.gz
Algorithm Hash digest
SHA256 a6fae7beb360022911461fb3d8b0b102b0214de8b1feb36b2a6561fe86e59d6c
MD5 9cfa2a3dcc278b982f1485bd1f309d92
BLAKE2b-256 da20852b18166b96e07838a712f9fc33d0f63894ce7d17ed40ecf421f0c6dfb9

See more details on using hashes here.

File details

Details for the file sphinx_feature_flags-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_feature_flags-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cdb79c993a38107d24e9a655262870ece7a6458276012b7b2d461eef0250e422
MD5 8120f21126843709ed5a8e935321a369
BLAKE2b-256 945474ab2b2e1283e0801e6df5bd51293e5d2484b112fae4cbc50804fd31700d

See more details on using hashes here.

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