Skip to main content

Latest Version License: Unlicense Documentation

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.

This can be used to e.g. show a snippet in multiple languages, display instructions for alternative platforms, or (in the future) switch between source and output.

Screenshot (usernames were changed)

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

By enabling the extension you get access to the code-tabs directive that 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:

.. 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!")

Planned changes

This project has just started. Planned features for the next releases (this might initially include backward-incompatible changes!):

  • prerender navbar, and CSS “hidden” classes, so that the layout doesn’t change during page reload

  • add mechanism to group several tab widgets together, so that the selection is kept in sync (which means users interested in a specific language won’t have to change the language on each snippet individually in a longer article)

  • adopt “caption” attribute rather using our own “title”

  • reuse “code-block” rather than introducing our own “code-tab” (?)

  • allow tabs other than code-blocks (maybe)

Metadata

Release files for helveg-sphinx-code-tabs 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for helveg-sphinx-code-tabs 0.2.0
File Size Uploaded Provenance Actions
helveg--sphinx-code-tabs-0.2.0.tar.gz 5.9 kB Without provenance Details for helveg--sphinx-code-tabs-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for helveg-sphinx-code-tabs 0.2.0
File Interpreter ABI Platform Actions
helveg_sphinx_code_tabs-0.2.0-py3-none-any.whl Python 3 none any Details for helveg_sphinx_code_tabs-0.2.0-py3-none-any.whl

Total release size: 11.9 kB

Release files / helveg--sphinx-code-tabs-0.2.0.tar.gz

Download URL helveg--sphinx-code-tabs-0.2.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
de4a6ec9f5dc1c79e04c1ed9a2d612757eca21b36e3e5beeea8dabb9586d3bb3
BLAKE2b-256 checksum
How to use checksums
41959d65055388c87f1aaf76f110c49b878cd97d926e413c9eb686f981274228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.10

Release files / helveg_sphinx_code_tabs-0.2.0-py3-none-any.whl

Download URL helveg_sphinx_code_tabs-0.2.0-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba3f025701f83857acc84f3e826007340b1d2f1cdbe1c51bef56e78ab75431c6
BLAKE2b-256 checksum
How to use checksums
d9db7f49bef643efed39a93a4e4e38008bc56321694814a25bb7351940b1a969
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.10

Security for helveg-sphinx-code-tabs 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page