@@ -7,23 +7,26 @@ sections of your page.
77
88For example, click the "+" button to the right:
99
10- .. note :: Here's a toggled admonition
11- :class: toggle
10+ .. toggle ::
11+
12+ .. note :: Here's a toggled admonition
1213
1314It was created with this code:
1415
15- .. code :: rst
16+ .. code-block :: rst
1617
17- .. note:: Here's a toggled admonition
18- :class: toggle
18+ .. toggle::
19+
20+ .. note:: Here's a toggled admonition
1921
20- (admonition body here)
22+ You can also add a title to your toggled block. The title will show up,
23+ and the toggle button will change the block's content. For example:
2124
22- And here's a code block:
25+ .. toggle :: Toggle to see what's inside
2326
24- .. container :: toggle
27+ It's a code block!
2528
26- .. code :: python
29+ .. code-block :: python
2730
2831 a = " wow, very python"
2932 print (" this code should be toggle-able!" )
@@ -34,7 +37,7 @@ Installation
3437
3538You can install `sphinx-togglebutton ` with `pip `:
3639
37- .. code :: bash
40+ .. code-block :: bash
3841
3942 pip install sphinx-togglebutton
4043
@@ -47,113 +50,115 @@ to your extensions list.
4750
4851E.g.:
4952
50- .. code :: python
53+ .. code-block :: python
5154
5255 extensions = [
5356 ...
5457 ' sphinx_togglebutton'
5558 ...
5659 ]
5760
58- Now, whenever you wish for an admonition to be toggle-able, add the
59- ``:class: toggle `` parameter to the admonition directive that you use.
6061
61- For example, this code would create a toggle-able "note" admonition:
62+ The toggle directive
63+ --------------------
6264
63- .. code :: rst
65+ To add toggle-able content, use the **toggle directive **. This directive
66+ will wrap its content in a toggle-able container. You can call it like so:
6467
65- .. note::
66- :class: toggle
68+ .. code-block :: rst
6769
68- This is my note.
70+ .. toggle::
6971
70- Here's how it looks:
72+ Here is my toggle-able content!
7173
72- .. note ::
73- :class: toggle
74+ The code above results in:
7475
75- This is my note.
76+ .. toggle ::
7677
77- Clicking on the toggle button will toggle the item's visibility.
78+ Here is my toggle-able content!
7879
80+ You can also add titles to your toggle-able content:
7981
80- Show content by default
81- -----------------------
82+ .. code-block :: rst
8283
83- By default, all items with toggle buttons added to them will be hidden by
84- default. You may also **show the content by default **. To do so, add the
85- ``toggle `` class *as well as * a ``toggle-shown `` class, like so:
84+ .. toggle:: My title
8685
87- .. code :: rst
86+ Here is my toggle-able content!
8887
89- .. note::
90- :class: toggle, toggle-shown
88+ Which results in:
9189
92- This is my note.
9390
94- This will generate the following block:
91+ .. toggle :: My title
9592
96- .. note ::
97- :class: toggle, toggle-shown
93+ Here is my toggle-able content!
9894
99- This is my note .
95+ To show the toggle-able content by default, use the `` :show: `` flag .
10096
101- Toggle any container of content
102- -------------------------------
97+ .. code-block :: rst
10398
104- You can also use ** containers ** to add arbitrary toggle-able code. For example,
105- here's a container with an image inside :
99+ .. toggle::
100+ :show :
106101
107- .. container :: toggle
102+ Here is my toggle-able content!
108103
109- .. admonition :: Look at that, an image!
104+ It results in the following:
110105
111- .. image :: https://media.giphy.com/media/mW05nwEyXLP0Y/giphy.gif
106+ .. toggle ::
107+ :show:
112108
113- It was generated with this code:
109+ Here is my toggle-able content!
114110
115- .. code :: rst
116111
117- .. container:: toggle
112+ Toggling content by adding classes
113+ ----------------------------------
118114
119- .. admonition:: Look at that, an image!
115+ You can also make elements toggle-able by adding the ``toggle `` class to
116+ them. This can be done with admonitions and containers with the
117+ ``:class: my, classes `` keyword.
120118
121- .. image:: https://media.giphy.com/media/mW05nwEyXLP0Y/giphy.gif
119+ For example, this code would create a toggle-able "note" admonition:
122120
123- Here's how they look right after one another:
121+ .. code-block :: rst
122+
123+ .. note::
124+ :class: toggle
125+
126+ This is my note.
127+
128+ Here's how it looks:
124129
125130.. note ::
126131 :class: toggle
127132
128133 This is my note.
129134
130- .. note ::
131- :class: toggle
135+ Clicking on the toggle button will toggle the item's visibility.
132136
133- This is my second.
134137
135- Customize the selector words used to toggle content
136- ---------------------------------------------------
138+ To show the content by default, add a ``toggle-shown `` class as well.
137139
138- ``sphinx-togglebutton `` adds a toggle button to elements that are selected
139- by a CSS selection query. By default, this is ``.toggle ``. You can customize
140- the query that is used with the following Sphinx parameter (in ``conf.py ``):
140+ .. code-block :: rst
141141
142- .. code-block :: python
142+ .. note::
143+ :class: toggle, toggle-shown
144+
145+ This is my note.
143146
144- togglebutton_selector = " <your-selector>
147+ This will generate the following block:
145148
146- For example, the documentation with this site uses the following configuration
147- value:
149+ .. note ::
150+ :class: toggle, toggle-shown
148151
149- .. code-block :: python
152+ This is my note.
150153
151- togglebutton_selector = " .toggle, .secondtoggle "
154+ Here's how they look right after one another:
152155
153- This means that any element with either of these classes will have toggle
154- buttons added to them.
156+ .. note ::
157+ :class: toggle
158+
159+ This is my note.
155160
156161.. note ::
157- :class: secondtoggle
162+ :class: toggle
158163
159- A note with a `` .secondtoggle `` class .
164+ This is my second .
0 commit comments