Skip to main content

Tabbed views for Sphinx

Project description

sphinx-tabs

Github-CI Coverage Status PyPI

Create tabbed content in Sphinx documentation when building HTML.

For example, see the [Raw] code of docs/index.rst which generates the following:

A live demo can be found here: https://sphinx-tabs.readthedocs.io

Tabs

Installation

pip install sphinx-tabs

To enable the extension in Sphinx, add the following to your conf.py:

extensions = ['sphinx_tabs.tabs']

If needed, there is a configuration option to allow additional builders to be considered compatible. For example, to add the linkcheck builder, add the following to your conf.py:

sphinx_tabs_valid_builders = ['linkcheck']

If you are using Read The Docs for building your documentation, the extension must be added as a requirement. Please add the following to requirements.txt at the root of the project:

sphinx-tabs

Contributing

We welcome all contributions! See the EBP Contributing Guide for general details.

The simplest way to run tests is to install pre-commit for linting and tox for unit tests and documentation build:

$ pre-commit run --all
$ tox -p

Basic Tabs

Basic tabs can be coded as follows:

.. tabs::

   .. tab:: Apples

      Apples are green, or sometimes red.

   .. tab:: Pears

      Pears are green.

   .. tab:: Oranges

      Oranges are orange.

Tabs

Grouped Tabs

Tabs can be grouped, so that changing the current tab in one area changes the current tab in the another area. For example:

.. tabs::

   .. group-tab:: Linux

      Linux Line 1

   .. group-tab:: Mac OSX

      Mac OSX Line 1

   .. group-tab:: Windows

      Windows Line 1

.. tabs::

   .. group-tab:: Linux

      Linux Line 1

   .. group-tab:: Mac OSX

      Mac OSX Line 1

   .. group-tab:: Windows

      Windows Line 1

Group Tabs

Code Tabs

Grouped tabs containing code areas with syntax highlighting can be created as follows:

.. tabs::

   .. code-tab:: c

         int main(const int argc, const char **argv) {
           return 0;
         }

   .. code-tab:: c++

         int main(const int argc, const char **argv) {
           return 0;
         }

   .. code-tab:: py

         def main():
             return

   .. code-tab:: java

         class Main {
             public static void main(String[] args) {
             }
         }

   .. code-tab:: julia

         function main()
         end

   .. code-tab:: fortran

         PROGRAM main
         END PROGRAM main

Code tabs also support custom lexers (added via sphinx conf.py).

By default, code tabs are labelled with the language name, though can be provided with custom labels like so:

.. tabs::

   .. code-tab:: c I love C

         int main(const int argc, const char **argv) {
           return 0;
         }

   .. code-tab:: py I love Python more

         def main():
             return

Code Tabs

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-tabs-1.3.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

sphinx_tabs-1.3.0-py3-none-any.whl (22.6 kB view details)

Uploaded Python 3

File details

Details for the file sphinx-tabs-1.3.0.tar.gz.

File metadata

  • Download URL: sphinx-tabs-1.3.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for sphinx-tabs-1.3.0.tar.gz
Algorithm Hash digest
SHA256 54132c8a57aa19bba6e17fe26eb94ea9df531708ff3f509b119313b32d0d5aff
MD5 0bdb8e8577d3ec12f5e4aa48bb3cfe5a
BLAKE2b-256 bb2e8fe859c2d03da4260c9df2028e78d1dba82187ce86f63fd27001fc9fbefd

See more details on using hashes here.

File details

Details for the file sphinx_tabs-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: sphinx_tabs-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for sphinx_tabs-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 537857f91f1b371f7b45eb8ac83001618b3e3178c78df073d2cc4558a8e66ef5
MD5 114c79a441bf13f111b4c6c801ea5e37
BLAKE2b-256 9d3f40fbd24188d99e62a1c8d57b265c660512dc07bfa5cc4dbd79bdc1eb5d29

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