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.8.tar.gz (3.3 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.8-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_feature_flags-1.0.8.tar.gz
  • Upload date:
  • Size: 3.3 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.8.tar.gz
Algorithm Hash digest
SHA256 f65685358eab5a0d7e06a2f45d197d593b9cf9b502d8b532f1d1fcf7cdcf744f
MD5 dd14094f9696947195acc4aefa2382bd
BLAKE2b-256 4e190f17e41030fd3ce85c2a4695465617daee7780b376958fcedc4b814cdc6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sphinx_feature_flags-1.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2b41f17b52feed3f0d45531878094017802900693d438b3c84fb70b91547a832
MD5 661a153609ff7f1f982003591daf24fb
BLAKE2b-256 5ec20a0c87c8c7915c2aeecbc0e46713dd7b7b1022666b02a79e169ca3ed960a

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