Skip to content

Commit fc8e197

Browse files
committed
Contributing: Explain how to create a toggable paragraph
1 parent 149671c commit fc8e197

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

docs/contributing/writing-docs-guide.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,38 @@ Using {term}`React` makes frontends fun again!
234234
Using {term}`React` makes frontends fun again!
235235

236236

237-
#### Toggle paragraph (Exercises / FAQ)
237+
#### Toggle paragraph (Exercise solution / FAQ)
238238

239-
````{admonition} This is a title
239+
Text snippets can be hidden with the option to show. Wrap it in an `admonition` and add the `class` `toggle`.
240+
241+
`````
242+
````{admonition} f-strings can make your life easier
240243
:class: toggle
241244
245+
To use formatted string literals, begin a string with f or F before the opening quotation mark or triple quotation mark.
246+
Inside this string, you can write a Python expression between { and } characters that can refer to variables or literal values.
247+
248+
```{code-block} python
249+
:linenos:
250+
:emphasize-lines: 1, 3
251+
252+
a = 2
253+
print("my 1st line")
254+
print(f"my {a}nd line")
255+
```
256+
````
257+
`````
258+
259+
Be aware to increase the number of backticks if you include directives like a `code-block`.
260+
261+
This would be rendered as:
262+
263+
````{admonition} f-strings can make your life easier
264+
:class: toggle
265+
266+
To use formatted string literals, begin a string with f or F before the opening quotation mark or triple quotation mark.
267+
Inside this string, you can write a Python expression between { and } characters that can refer to variables or literal values.
268+
242269
```{code-block} python
243270
:linenos:
244271
:emphasize-lines: 1, 3

0 commit comments

Comments
 (0)