Skip to main content

Toggle page content and collapse admonitions in Sphinx.

Project description

sphinx-togglebutton

A small sphinx extension to make it possible to add a "toggle button" to sections of your page. This allows you to:

  • Collapse Sphinx admonitions (notes, warnings, etc) so that their content is hidden until users click a toggle button.
  • Collapse arbitrary chunks of content on your page with a collapse directive.

Demonstration of Sphinx Togglebutton

Installation

You can install sphinx-togglebutton with pip:

pip install sphinx-togglebutton

Usage

In your conf.py configuration file, add sphinx_togglebutton to your extensions list.

E.g.:

extensions = [
    ...
    'sphinx_togglebutton'
    ...
]

Now, whenever you wish for an admonition to be toggle-able, add the :class: dropdown parameter to the admonition directive that you use.

For example, this code would create a toggle-able "note" admonition that starts hidden:

.. note::
    :class: dropdown

    This is my note.

Clicking on the toggle button will toggle the item's visibility.

You may also show the content by default. To do so, add the dropdown class as well as a toggle-shown class, like so:

.. note::
    :class: dropdown, toggle-shown

    This is my note.

You can also use containers to add arbitrary toggle-able code. For example, here's a container with an image inside:

.. container:: toggle, toggle-hidden

    .. admonition:: Look at that, an image!

        .. image:: https://media.giphy.com/media/mW05nwEyXLP0Y/giphy.gif

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-togglebutton-0.3.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

sphinx_togglebutton-0.3.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file sphinx-togglebutton-0.3.0.tar.gz.

File metadata

  • Download URL: sphinx-togglebutton-0.3.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for sphinx-togglebutton-0.3.0.tar.gz
Algorithm Hash digest
SHA256 005594ceb82c3da382d7b3a20aa0ceabc79648fc14f85bbef1424d1409112831
MD5 11839c55d8922591eb93c84c7490a312
BLAKE2b-256 b22b4cbf190449d34545769a5c1fd1ffb69fba741d2d4166b27d8782fb54679e

See more details on using hashes here.

File details

Details for the file sphinx_togglebutton-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sphinx_togglebutton-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.12

File hashes

Hashes for sphinx_togglebutton-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6f37dc04fab6f07154c598973fcb4615171885d90a0e4575f80203c9ddef44a
MD5 f259706a1bc3fbec57093c054159d583
BLAKE2b-256 a441c7e98802f504c81abcad9f57bdf346b675086e0dab777575f2f41eed532b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page