2.8. Tabbed Content

Attention

Only practicable and usable for HTML builder.

PyPI Package

https://pypi.org/project/sphinx-tabs/

Documentation

https://sphinx-tabs.readthedocs.io/

Git Repository

https://github.com/executablebooks/sphinx-tabs

Create tabbed content in Sphinx documentation when building HTML.

Features
  1. Basic and nested tabs.

  2. Grouped Tabs.

  3. Code Tabs.

.. tabs::
.. tab::

For more details, see Simple Tabs in the extension demonstration and the README.md in the extension Git repository.

The example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
.. tabs::

   .. tab:: **Apples**

      Apples are green, or sometimes red.

   .. tab:: **Pears**

      Pears are green.

   .. tab:: **Oranges**

      Oranges are orange.
Which gives

Apples are green, or sometimes red.

Pears are green.

Oranges are orange.

Nested tabs are also possible.

The example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
.. tabs::

   .. tab:: Stars

      .. tabs::

         .. tab:: The Sun

            The closest star to us.

         .. tab:: Proxima Centauri

            The second closest star to us.

         .. tab:: Polaris

            The North Star.

   .. tab:: Moons

      .. tabs::

         .. tab:: The Moon

            Orbits the Earth

         .. tab:: Titan

            Orbits Jupiter
Which gives

The closest star to us.

The second closest star to us.

The North Star.

Orbits the Earth

Orbits Jupiter

.. group-tab::

Also tabs can stick together in groups.

The example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
.. rubric:: operating systems

.. tabs::

   .. group-tab:: Linux

      **Linux** is Unix-like, but was developed without any Unix code.
      The Linux kernel originated in 1991, as a project of Linus
      Torvalds, while a university student in Finland.

   .. group-tab:: Mac OS X

      **Mac OS X** is a line of open core graphical operating systems
      developed, marketed, and sold by Apple Inc.

   .. group-tab:: Microsoft Windows

      **Microsoft Windows** is a family of proprietary operating systems
      designed by Microsoft Corporation and primarily targeted to
      Intel architecture based computers.

.. rubric:: integrated development environments

.. tabs::

   .. group-tab:: Linux

      **There is no dedicated or default integrated development
      environment (IDE)** on *Linux*. `Here is a list`_ of IDEs
      which will run natively on *Linux*.

   .. group-tab:: Mac OS X

      **Xcode** is an integrated development environment (IDE) for
      *Mac OS X* containing a suite of software development tools
      developed by Apple Inc.

   .. group-tab:: Microsoft Windows

      **Microsoft Visual Studio** is an integrated development
      environment (IDE) from Microsoft Corporation. It is used to
      develop computer programs uses Microsoft software development
      platforms such as *Windows API*, *Windows Forms*, *Windows
      Presentation Foundation*, *Windows Store* and *Microsoft
      Silverlight*.

.. _`Here is a list`:
   https://en.wikipedia.org/wiki/Category:Linux_integrated_development_environments
Which gives

operating systems

Linux is Unix-like, but was developed without any Unix code. The Linux kernel originated in 1991, as a project of Linus Torvalds, while a university student in Finland.

Mac OS X is a line of open core graphical operating systems developed, marketed, and sold by Apple Inc.

Microsoft Windows is a family of proprietary operating systems designed by Microsoft Corporation and primarily targeted to Intel architecture based computers.

integrated development environments

There is no dedicated or default integrated development environment (IDE) on Linux. Here is a list of IDEs which will run natively on Linux.

Xcode is an integrated development environment (IDE) for Mac OS X containing a suite of software development tools developed by Apple Inc.

Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft Corporation. It is used to develop computer programs uses Microsoft software development platforms such as Windows API, Windows Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight.

.. code-tab::

Similar to grouped tabs they can contain code areas with syntax highlighting.

The example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
.. rubric:: main entry function

.. 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:: python

         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

.. rubric:: programming languages

.. tabs::

   .. code-tab:: c

         C Main Function

   .. code-tab:: c++

         C++ Main Function

   .. code-tab:: python

         Python Main Function

   .. code-tab:: java

         Java Main Function

   .. code-tab:: julia

         Julia Main Function

   .. code-tab:: fortran

         Fortran Main Function
Which gives

main entry function

int main(const int argc, const char **argv) {
    return 0;
}
int main(const int argc, const char **argv) {
    return 0;
}
def main():
    return
class Main {
    public static void main(String[] args) {
    }
}
function main()
end
PROGRAM main
END PROGRAM main

programming languages

C Main Function
C++ Main Function
Python Main Function
Java Main Function
Julia Main Function
Fortran Main Function