Skip to content

Commit 1e24b48

Browse files
committed
[IMP] contributing/documentation: document usage of code tabs
task-2787415 Part-of: #1688
1 parent df527a2 commit 1e24b48

File tree

1 file changed

+95
-1
lines changed

1 file changed

+95
-1
lines changed

content/contributing/documentation/rst_cheat_sheet.rst

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Use the following markups to emphasize your text to your liking:
5757
+--------------+----------+
5858
| \*Text\* | *Text* |
5959
+--------------+----------+
60-
| \`\`Text\`\` | ``Text`` |
60+
| \`Text\` | ``Text`` |
6161
+--------------+----------+
6262

6363
.. seealso::
@@ -521,6 +521,29 @@ Render
521521

522522
Customize this admonition with a **Title** of your choice.
523523

524+
.. _contributing/code-blocks:
525+
526+
Code blocks
527+
===========
528+
529+
RST
530+
---
531+
532+
.. code-block:: text
533+
534+
.. code-block:: python
535+
536+
def main():
537+
print("Hello world!")
538+
539+
Render
540+
------
541+
542+
.. code-block:: python
543+
544+
def main():
545+
print("Hello world!")
546+
524547
.. _contributing/tabs:
525548

526549
Content tabs
@@ -535,9 +558,14 @@ Content tabs
535558
- A tab cannot contain :ref:`internal hyperlink targets
536559
<contributing/internal-hyperlink-targets>`.
537560

561+
.. _contributing/tabs/basic:
562+
538563
Basic tabs
539564
----------
540565

566+
Basic tabs are useful to split content into multiple options. The `tabs` directive is used to define
567+
a sequence of tabs. Each tab is then defined with the `tab` directive followed by a label.
568+
541569
RST
542570
~~~
543571

@@ -574,9 +602,13 @@ Render
574602

575603
Third version for On-premise users.
576604

605+
.. _contributing/tabs/nested:
606+
577607
Nested tabs
578608
-----------
579609

610+
Tabs can be nested inside one another.
611+
580612
RST
581613
~~~
582614

@@ -645,9 +677,15 @@ Render
645677

646678
Orbits Jupiter.
647679

680+
.. _contributing/tabs/group:
681+
648682
Group tabs
649683
----------
650684

685+
Group tabs are special tabs that synchronize based on a group label. The last selected group is
686+
remembered and automatically selected when the user returns on the page or visits another page with
687+
the tabs group. The `group-tab` directive is used to define group tabs.
688+
651689
RST
652690
~~~
653691

@@ -734,6 +772,62 @@ Render
734772
public static void main(String[] args) {}
735773
}
736774
775+
.. _contributing/tabs/code:
776+
777+
Code tabs
778+
---------
779+
780+
Code tabs are essentially :ref:`group tabs <contributing/tabs/group>` that treat the content as a
781+
:ref:`code block <contributing/code-blocks>`. The `code-tab` directive is used to define a code tab.
782+
Just as for the `code-block` directive, the language defines the syntax highlighting of the tab. If
783+
set, the label is used instead of the language for grouping tabs.
784+
785+
RST
786+
~~~
787+
788+
.. code-block:: rst
789+
790+
.. tabs::
791+
792+
.. code-tab:: c++ Hello C++
793+
794+
#include <iostream>
795+
796+
int main() {
797+
std::cout << "Hello World";
798+
return 0;
799+
}
800+
801+
.. code-tab:: python Hello Python
802+
803+
print("Hello World")
804+
805+
.. code-tab:: javascript Hello JavaScript
806+
807+
console.log("Hello World");
808+
809+
Render
810+
~~~~~~
811+
812+
.. tabs::
813+
814+
.. code-tab:: c++ Hello C++
815+
816+
#include <iostream>
817+
818+
int main() {
819+
std::cout << "Hello World";
820+
return 0;
821+
}
822+
823+
.. code-tab:: python Hello Python
824+
825+
print("Hello World")
826+
827+
.. code-tab:: javascript Hello JavaScript
828+
829+
console.log("Hello World");
830+
737831
.. _contributing/document-metadata:
738832

739833
Document metadata

0 commit comments

Comments
 (0)