You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/syntax.md
+55-8Lines changed: 55 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,9 @@ An exercise directive can be included using the `exercise` pattern. The directiv
18
18
*`nonumber` : flag (empty)
19
19
20
20
Turns off exercise auto numbering.
21
+
*`hidden` : flag (empty)
22
+
23
+
Removes the directive from the final output.
21
24
22
25
**Example**
23
26
@@ -76,6 +79,9 @@ A solution directive can be included using the `solution` pattern. It takes in t
76
79
*`class` : text
77
80
78
81
Value of the solution’s class attribute which can be used to add custom CSS or JavaScript.
82
+
*`hidden` : flag (empty)
83
+
84
+
Removes the directive from the final output.
79
85
80
86
```{note}
81
87
The title of the solution directive links directly to the referred directive.
@@ -184,20 +190,31 @@ static int factorial(int n){
184
190
````
185
191
186
192
187
-
## How to Hide Directives
193
+
## Hide or Remove Directives
188
194
189
-
Directives can be hidden using the `dropdown` class which is available through [Sphinx Book Theme](https://sphinx-book-theme.readthedocs.io/en/latest/index.html). For Sphinx projects, add `"sphinx_book_theme"` to your `html_theme` in the `conf.py` to activate the theme in your Sphinx configuration
195
+
### Hide Content
190
196
191
-
```md
192
-
...
193
-
html_theme = "sphinx_book_theme"
194
-
...
197
+
The content of directives can be hidden using the `dropdown` class which is available through [sphinx-togglebutton](https://sphinx-togglebutton.readthedocs.io/en/latest/). For Sphinx projects, add `"sphinx_togglebutton"` to your `extensions` list in `conf.py` to activate the extension
198
+
199
+
```python
200
+
extensions = [
201
+
...
202
+
"sphinx_togglebutton"
203
+
...
204
+
]
195
205
```
196
206
197
-
Jupyter Book's default theme is Sphinx Book Theme; therefore, Jupyter Book projects can utilize `dropdown` without having to activate the theme in your Sphinx configuration.
207
+
For Jupyter Book projects, add `sphinx_togglebutton` under `extra_extensions`
198
208
209
+
```yaml
210
+
sphinx:
211
+
extra_extensions:
212
+
- sphinx_togglebutton
213
+
```
199
214
200
-
To hide the directive, simply add `:class: dropdown` as a directive option.
215
+
To hide the content, simply add `:class: dropdown` as a directive option.
216
+
217
+
For more use cases see [sphinx-togglebutton](https://sphinx-togglebutton.readthedocs.io/en/latest/#usage).
201
218
202
219
**Example**
203
220
@@ -231,6 +248,36 @@ for any positive integer $n$.
231
248
```
232
249
````
233
250
251
+
### Remove Directives
252
+
253
+
Any specific directive can be hidden by introducing the `:hidden:` option. For example, the following example will not be displayed
254
+
255
+
````md
256
+
```{exercise}
257
+
:hidden:
258
+
259
+
This is a hidden exercise directive.
260
+
```
261
+
````
262
+
263
+
```{exercise}
264
+
:hidden:
265
+
266
+
This is a hidden exercise directive.
267
+
```
268
+
269
+
### Remove All Solutions
270
+
271
+
All solution directives can be removed from the final output by setting `hide_solutions` to `True`. For Sphinx projects, add the configuration key in the `conf.py` file. Jupyter Book projects, should set the configuration key in `_config.yml` as follows
272
+
273
+
```yaml
274
+
...
275
+
sphinx:
276
+
config:
277
+
hide_solutions: True
278
+
...
279
+
```
280
+
234
281
## Custom CSS or JavaScript
235
282
236
283
Custom JavaScript scripts and CSS rules will allow you to add additional functionality or customize how elements are displayed. If you'd like to include custom CSS or JavaScript scripts in Jupyter Book, simply add any files ending in `.css` or `.js` under a `_static` folder. Any files under this folder will be automatically copied into the built book.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
0 commit comments