Skip to content

Commit 12459d2

Browse files
authored
📝 Update markdown includes to use the new simpler format (#1054)
1 parent f802688 commit 12459d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+186
-1855
lines changed

docs/tutorial/app-dir.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
You can get the application directory where you can, for example, save configuration files with `typer.get_app_dir()`:
44

5-
```Python hl_lines="9"
6-
{!../docs_src/app_dir/tutorial001.py!}
7-
```
5+
{* docs_src/app_dir/tutorial001.py hl[9] *}
86

97
It will give you a directory for storing configurations appropriate for your CLI program for the current user in each operating system.
108

docs/tutorial/arguments/default.md

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,7 @@ That way the *CLI argument* will be optional *and also* have a default value.
88

99
We can also use `typer.Argument()` to make a *CLI argument* have a default value other than `None`:
1010

11-
//// tab | Python 3.7+
12-
13-
```Python hl_lines="5"
14-
{!> ../docs_src/arguments/default/tutorial001_an.py!}
15-
```
16-
17-
////
18-
19-
//// tab | Python 3.7+ non-Annotated
20-
21-
/// tip
22-
23-
Prefer to use the `Annotated` version if possible.
24-
25-
///
26-
27-
```Python hl_lines="4"
28-
{!> ../docs_src/arguments/default/tutorial001.py!}
29-
```
30-
31-
////
11+
{* docs_src/arguments/default/tutorial001_an.py hl[5] *}
3212

3313
/// tip
3414

@@ -72,27 +52,7 @@ Hello Camila
7252

7353
And we can even make the default value be dynamically generated by passing a function as the `default_factory` argument:
7454

75-
//// tab | Python 3.7+
76-
77-
```Python hl_lines="7-8 11"
78-
{!> ../docs_src/arguments/default/tutorial002_an.py!}
79-
```
80-
81-
////
82-
83-
//// tab | Python 3.7+ non-Annotated
84-
85-
/// tip
86-
87-
Prefer to use the `Annotated` version if possible.
88-
89-
///
90-
91-
```Python hl_lines="6-7 10"
92-
{!> ../docs_src/arguments/default/tutorial002.py!}
93-
```
94-
95-
////
55+
{* docs_src/arguments/default/tutorial002_an.py hl[7:8,11] *}
9656

9757
In this case, we created the function `get_name` that will just return a random `str` each time.
9858

docs/tutorial/arguments/envvar.md

Lines changed: 3 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,7 @@ You can learn more about environment variables in the [Environment Variables](..
1010

1111
To do that, use the `envvar` parameter for `typer.Argument()`:
1212

13-
//// tab | Python 3.7+
14-
15-
```Python hl_lines="5"
16-
{!> ../docs_src/arguments/envvar/tutorial001_an.py!}
17-
```
18-
19-
////
20-
21-
//// tab | Python 3.7+ non-Annotated
22-
23-
/// tip
24-
25-
Prefer to use the `Annotated` version if possible.
26-
27-
///
28-
29-
```Python hl_lines="4"
30-
{!> ../docs_src/arguments/envvar/tutorial001.py!}
31-
```
32-
33-
////
13+
{* docs_src/arguments/envvar/tutorial001_an.py hl[5] *}
3414

3515
In this case, the *CLI argument* `name` will have a default value of `"World"`, but will also read any value passed to the environment variable `AWESOME_NAME` if no value is provided in the command line:
3616

@@ -75,27 +55,7 @@ Hello Mr. Czernobog
7555

7656
You are not restricted to a single environment variable, you can declare a list of environment variables that could be used to get a value if it was not passed in the command line:
7757

78-
//// tab | Python 3.7+
79-
80-
```Python hl_lines="6"
81-
{!> ../docs_src/arguments/envvar/tutorial002_an.py!}
82-
```
83-
84-
////
85-
86-
//// tab | Python 3.7+ non-Annotated
87-
88-
/// tip
89-
90-
Prefer to use the `Annotated` version if possible.
91-
92-
///
93-
94-
```Python hl_lines="4"
95-
{!> ../docs_src/arguments/envvar/tutorial002.py!}
96-
```
97-
98-
////
58+
{* docs_src/arguments/envvar/tutorial002_an.py hl[6] *}
9959

10060
Check it:
10161

@@ -130,27 +90,7 @@ Hello Mr. Anubis
13090

13191
By default, environment variables used will be shown in the help text, but you can disable them with `show_envvar=False`:
13292

133-
//// tab | Python 3.7+
134-
135-
```Python hl_lines="7"
136-
{!> ../docs_src/arguments/envvar/tutorial003_an.py!}
137-
```
138-
139-
////
140-
141-
//// tab | Python 3.7+ non-Annotated
142-
143-
/// tip
144-
145-
Prefer to use the `Annotated` version if possible.
146-
147-
///
148-
149-
```Python hl_lines="4"
150-
{!> ../docs_src/arguments/envvar/tutorial003.py!}
151-
```
152-
153-
////
93+
{* docs_src/arguments/envvar/tutorial003_an.py hl[7] *}
15494

15595
Check it:
15696

docs/tutorial/arguments/help.md

Lines changed: 9 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,15 @@ In the *First Steps* section you saw how to add help for a CLI app/command by ad
44

55
Here's how that last example looked like:
66

7-
```Python
8-
{!../docs_src/first_steps/tutorial006.py!}
9-
```
7+
{* docs_src/first_steps/tutorial006.py *}
108

119
Now that you also know how to use `typer.Argument()`, let's use it to add documentation specific for a *CLI argument*.
1210

1311
## Add a `help` text for a *CLI argument*
1412

1513
You can use the `help` parameter to add a help text for a *CLI argument*:
1614

17-
//// tab | Python 3.7+
18-
19-
```Python hl_lines="5"
20-
{!> ../docs_src/arguments/help/tutorial001_an.py!}
21-
```
22-
23-
////
24-
25-
//// tab | Python 3.7+ non-Annotated
26-
27-
/// tip
28-
29-
Prefer to use the `Annotated` version if possible.
30-
31-
///
32-
33-
```Python hl_lines="4"
34-
{!> ../docs_src/arguments/help/tutorial001.py!}
35-
```
36-
37-
////
15+
{* docs_src/arguments/help/tutorial001_an.py hl[5] *}
3816

3917
And it will be used in the automatic `--help` option:
4018

@@ -59,27 +37,7 @@ Options:
5937

6038
And of course, you can also combine that `help` with the <abbr title="a multi-line string as the first expression inside a function (not assigned to any variable) used for documentation">docstring</abbr>:
6139

62-
//// tab | Python 3.7+
63-
64-
```Python hl_lines="5-8"
65-
{!> ../docs_src/arguments/help/tutorial002_an.py!}
66-
```
67-
68-
////
69-
70-
//// tab | Python 3.7+ non-Annotated
71-
72-
/// tip
73-
74-
Prefer to use the `Annotated` version if possible.
75-
76-
///
77-
78-
```Python hl_lines="4-7"
79-
{!> ../docs_src/arguments/help/tutorial002.py!}
80-
```
81-
82-
////
40+
{* docs_src/arguments/help/tutorial002_an.py hl[5:8] *}
8341

8442
And the `--help` option will combine all the information:
8543

@@ -106,27 +64,7 @@ Options:
10664

10765
If you have a *CLI argument* with a default value, like `"World"`:
10866

109-
//// tab | Python 3.7+
110-
111-
```Python hl_lines="5"
112-
{!> ../docs_src/arguments/help/tutorial003_an.py!}
113-
```
114-
115-
////
116-
117-
//// tab | Python 3.7+ non-Annotated
118-
119-
/// tip
120-
121-
Prefer to use the `Annotated` version if possible.
122-
123-
///
124-
125-
```Python hl_lines="4"
126-
{!> ../docs_src/arguments/help/tutorial003.py!}
127-
```
128-
129-
////
67+
{* docs_src/arguments/help/tutorial003_an.py hl[5] *}
13068

13169
It will show that default value in the help text:
13270

@@ -151,27 +89,7 @@ Options:
15189

15290
But you can disable that if you want to, with `show_default=False`:
15391

154-
//// tab | Python 3.7+
155-
156-
```Python hl_lines="7"
157-
{!> ../docs_src/arguments/help/tutorial004_an.py!}
158-
```
159-
160-
////
161-
162-
//// tab | Python 3.7+ non-Annotated
163-
164-
/// tip
165-
166-
Prefer to use the `Annotated` version if possible.
167-
168-
///
169-
170-
```Python hl_lines="4"
171-
{!> ../docs_src/arguments/help/tutorial004.py!}
172-
```
173-
174-
////
92+
{* docs_src/arguments/help/tutorial004_an.py hl[7] *}
17593

17694
And then it won't show the default value:
17795

@@ -206,27 +124,7 @@ In **Typer** these default values are shown by default. 👀
206124

207125
You can use the same `show_default` to pass a custom string (instead of a `bool`) to customize the default value to be shown in the help text:
208126

209-
//// tab | Python 3.7+
210-
211-
```Python hl_lines="9"
212-
{!> ../docs_src/arguments/help/tutorial005_an.py!}
213-
```
214-
215-
////
216-
217-
//// tab | Python 3.7+ non-Annotated
218-
219-
/// tip
220-
221-
Prefer to use the `Annotated` version if possible.
222-
223-
///
224-
225-
```Python hl_lines="6"
226-
{!> ../docs_src/arguments/help/tutorial005.py!}
227-
```
228-
229-
////
127+
{* docs_src/arguments/help/tutorial005_an.py hl[9] *}
230128

231129
And it will be used in the help text:
232130

@@ -271,27 +169,7 @@ But you can customize it with the `metavar` parameter for `typer.Argument()`.
271169

272170
For example, let's say you don't want to have the default of `NAME`, you want to have `username`, in lowercase, and you really want ✨ emojis ✨ everywhere:
273171

274-
//// tab | Python 3.7+
275-
276-
```Python hl_lines="5"
277-
{!> ../docs_src/arguments/help/tutorial006_an.py!}
278-
```
279-
280-
////
281-
282-
//// tab | Python 3.7+ non-Annotated
283-
284-
/// tip
285-
286-
Prefer to use the `Annotated` version if possible.
287-
288-
///
289-
290-
```Python hl_lines="4"
291-
{!> ../docs_src/arguments/help/tutorial006.py!}
292-
```
293-
294-
////
172+
{* docs_src/arguments/help/tutorial006_an.py hl[5] *}
295173

296174
Now the generated help text will have `✨username✨` instead of `NAME`:
297175

@@ -317,27 +195,7 @@ You might want to show the help information for *CLI arguments* in different pan
317195

318196
If you have installed Rich as described in the docs for [Printing and Colors](../printing.md){.internal-link target=_blank}, you can set the `rich_help_panel` parameter to the name of the panel where you want this *CLI argument* to be shown:
319197

320-
//// tab | Python 3.7+
321-
322-
```Python hl_lines="8 12"
323-
{!> ../docs_src/arguments/help/tutorial007_an.py!}
324-
```
325-
326-
////
327-
328-
//// tab | Python 3.7+ non-Annotated
329-
330-
/// tip
331-
332-
Prefer to use the `Annotated` version if possible.
333-
334-
///
335-
336-
```Python hl_lines="7 10"
337-
{!> ../docs_src/arguments/help/tutorial007.py!}
338-
```
339-
340-
////
198+
{* docs_src/arguments/help/tutorial007_an.py hl[8,12] *}
341199

342200
Then, if you check the `--help` option, you will see a default panel named "`Arguments`" for the *CLI arguments* that don't have a custom `rich_help_panel`.
343201

@@ -380,27 +238,7 @@ If you want, you can make a *CLI argument* **not** show up in the `Arguments` se
380238

381239
You will probably not want to do this normally, but it's possible:
382240

383-
//// tab | Python 3.7+
384-
385-
```Python hl_lines="5"
386-
{!> ../docs_src/arguments/help/tutorial008_an.py!}
387-
```
388-
389-
////
390-
391-
//// tab | Python 3.7+ non-Annotated
392-
393-
/// tip
394-
395-
Prefer to use the `Annotated` version if possible.
396-
397-
///
398-
399-
```Python hl_lines="4"
400-
{!> ../docs_src/arguments/help/tutorial008.py!}
401-
```
402-
403-
////
241+
{* docs_src/arguments/help/tutorial008_an.py hl[5] *}
404242

405243
Check it:
406244

0 commit comments

Comments
 (0)