Tabbed views for Sphinx

3.5.0 · active · verified Sat Apr 11

Sphinx Tabs is a Sphinx extension that provides directives for creating tabbed content in Sphinx documentation when building HTML. It is actively maintained, with version 3.5.0 currently available, and releases frequently address compatibility with new Sphinx and Docutils versions.

Warnings

Install

Imports

Quickstart

This quickstart guides you through setting up a basic Sphinx project, enabling the `sphinx-tabs` extension, and creating an example reStructuredText file with a tabbed interface. After building, you can view the tabbed content in the generated HTML documentation.

mkdir myproject
cd myproject
mkdir docs
cd docs
sphinx-quickstart  # Follow prompts, say 'y' to Separate source and build dirs
# In docs/conf.py:
# extensions = [
#     'sphinx.ext.autodoc',
#     'sphinx.ext.napoleon',
#     'sphinx_tabs.tabs',
# ]
# html_theme = 'alabaster' # Or any other Sphinx theme

# In docs/index.rst:
# .. _index:
#
# Welcome to My Sphinx Tabs Project's documentation!
# ==================================================
#
# .. tabs::
#
#     .. tab:: Python
#
#         .. code-block:: python
#
#             def hello_world():
#                 print("Hello, Python!")
#
#     .. tab:: Shell
#
#         .. code-block:: bash
#
#             echo "Hello, Shell!"
#
#     .. tab:: Markup
#
#         Hello from **reStructuredText**!
#
# This project demonstrates `sphinx-tabs` functionality.
#
# Indices and tables
# ==================
#
# * :ref:`genindex`
# * :ref:`modindex`
# * :ref:`search`

# Then build:
# make html
# Open _build/html/index.html

view raw JSON →