Skip to main content

Sphinx extension for adding alternative code-blocks as selectable tabs

Project description

This is a Sphinx extension that adds a directive code-tabs that creates a navbar above several alternative code blocks, allowing the user to switch between them.

Installation

pip install sphinx_code_tabs

To enable the extension in sphinx, simply add the package name in your conf.py to the list of extensions:

extensions = [
    ...
    'sphinx_code_tabs',
]

Usage

The code-tabs directive declares a notebook of code block alternatives. The individual tabs must be created with the code-tab directive which derives from code-block and accepts all of its arguments.

For example:

.. code-tabs::

    .. code-tab:: bash
        :title: bash

        echo "Hello, World!"

    .. code-tab:: c
        :title: C/C++
        :emphasize-lines: 2

        #include <stdio.h>
        int main() { printf("Hello, world!\n"); }

    .. code-tab:: python
        :title: python

        print("Hello, world!")

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_code_tabs-0.0.1.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

sphinx_code_tabs-0.0.1-py3-none-any.whl (5.2 kB view hashes)

Uploaded Python 3

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