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.9.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.9-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_feature_flags-1.0.9.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.9.tar.gz
Algorithm Hash digest
SHA256 1f0c7450d5f19abda016deb0e8a928d81c601b368775f32f0258e4ec98605721
MD5 e07183df7222989ee9db1f171ca8de8a
BLAKE2b-256 6c8026a78a8d4e8e0a7d959f73d0034814057322dd9450632ccb1deaf7a26129

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sphinx_feature_flags-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 e1f601afe98cb4ed1686ecafdf545dafa5ebf0ecb58a85f41b4acb15b374877c
MD5 7b69e06fc97ced5a6bcdeda0d0fc62db
BLAKE2b-256 f6fae361a1acd20b46a31286a53e5138afd0df8dcccf7bd1f1ef3d01cf563eb6

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