Skip to content

Commit

Permalink
🏷️ Change tags type to match jupytext (#1780)
Browse files Browse the repository at this point in the history
Co-authored-by: Rowan Cockett <[email protected]>
  • Loading branch information
tobydriscoll and rowanc1 authored Jan 20, 2025
1 parent 74e96e1 commit 2fd17a3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions docs/execute-notebooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Here's an example of adding this tag with a {myst:directive}`code-cell` directiv

````markdown
```{code-cell}
:tags: raises-exception
:tags: [raises-exception]

print("Hello" + 10001)
```
Expand All @@ -57,7 +57,7 @@ For [Markdown notebooks using the {myst:directive}`code-cell` directive](noteboo

````markdown
```{code-cell}
:tags: skip-execution
:tags: [skip-execution]

name = input("What is your name?")
```
Expand Down
13 changes: 12 additions & 1 deletion docs/notebook-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,22 @@ In Markdown of a jupyter notebook these look like:

````markdown
```{code-cell} python
:tags: remove-input
:tags: [remove-input]
print("This will show output with no input!")
```
````

for a single tag, or

````markdown
```{code-cell} python
:tags: [my-tag1, my-tag2]
print("This will show output with no input!")
```
````

for any number of tags.

:::{table} Notebook cell tags with special meanings
:label: tbl:notebook-cell-tags

Expand Down
10 changes: 5 additions & 5 deletions docs/notebooks-with-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,22 @@ For example, the following code defines a `remove-input` tag (See all [notebook

````markdown
```{code-cell} python
:tags: remove-input
:tags: [remove-input]
print("This will show output with no input!")
```
````

and results in the following:

> ```{code-cell} python
> :tags: remove-input
> :tags: [remove-input]
> print("This will show output with no input!")
> ```

This can be particularly helpful for showing the output of a calculation or plot, which is reproducible in the {download}`source code <./notebooks-with-markdown.md>`, but not shown to the user like this `matplotlib` plot:

```{code-cell} python
:tags: remove-input
:tags: [remove-input]
# Data for plotting
t = np.arange(0.0, 2.0, 0.01)
s = 1 + np.sin(2 * np.pi * t)
Expand All @@ -149,12 +149,12 @@ plt.show()

For **multiple tags** you have two ways to provide them:

- If you specify argument options with `:`, tags will be parsed as a comma-separated string.
- If you specify argument options with `:`, tags will be parsed as a comma-separated list of strings.
For example:

````markdown
```{code-cell} python
:tags: tag1, tag2,tag3
:tags: [tag1, tag2,tag3]
# Note that whitespace is removed from tags!
print("howdy!")
```
Expand Down

0 comments on commit 2fd17a3

Please sign in to comment.