Skip to content

Commit 911588d

Browse files
committed
📚 DOCS: add/update documentation on hiding content and directive
1 parent 8b9214a commit 911588d

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

docs/source/syntax.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ An exercise directive can be included using the `exercise` pattern. The directiv
1818
* `nonumber` : flag (empty)
1919

2020
Turns off exercise auto numbering.
21+
* `hidden` : flag (empty)
22+
23+
Removes the directive from the final output.
2124

2225
**Example**
2326

@@ -76,6 +79,9 @@ A solution directive can be included using the `solution` pattern. It takes in t
7679
* `class` : text
7780

7881
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.
7985

8086
```{note}
8187
The title of the solution directive links directly to the referred directive.
@@ -184,11 +190,13 @@ static int factorial(int n){
184190
````
185191

186192

187-
## How to Hide Directives
193+
## Hide or Remove Directives
194+
195+
### Hide Content
188196

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
197+
The content of 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
190198

191-
```md
199+
```python
192200
...
193201
html_theme = "sphinx_book_theme"
194202
...
@@ -197,7 +205,7 @@ html_theme = "sphinx_book_theme"
197205
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.
198206

199207

200-
To hide the directive, simply add `:class: dropdown` as a directive option.
208+
To hide the content, simply add `:class: dropdown` as a directive option.
201209

202210
**Example**
203211

@@ -231,6 +239,36 @@ for any positive integer $n$.
231239
```
232240
````
233241

242+
### Remove Directives
243+
244+
Any specific directive can be hidden by introducing the `:hidden:` option. For example, the following example will not be displayed
245+
246+
````md
247+
```{exercise}
248+
:hidden:
249+
250+
This is a hidden exercise directive.
251+
```
252+
````
253+
254+
```{exercise}
255+
:hidden:
256+
257+
This is a hidden exercise directive.
258+
```
259+
260+
### Remove All Solutions
261+
262+
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
263+
264+
```yaml
265+
...
266+
sphinx:
267+
config:
268+
hide_solutions: True
269+
...
270+
```
271+
234272
## Custom CSS or JavaScript
235273

236274
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.

0 commit comments

Comments
 (0)