Debian Codegraph @

docs/source/vs_typer/docstring/main.py

raw symbols SCIP
1 import typer
2
3 import cyclopts
4
5 typer_app = typer.Typer()
6
7
8 @typer_app.callback()
9 def dummy():
10 # So that ``foo`` is considered a command.
11 pass
12
13
14 @typer_app.command()
15 def foo(bar):
16 """Foo Docstring.
17
18 Parameters
19 ----------
20 bar: str
21 Bar parameter docstring.
22 """
23 pass
24
25
26 print("Typer:")
27
28 # Typer correctly parses the docstring short description.
29 typer_app(["--help"], standalone_mode=False)
30 # ╭─ Commands ─────────────────────────────────────────────────────╮
31 # │ foo Foo Docstring. │
32 # ╰────────────────────────────────────────────────────────────────╯
33
34
35 # However, it fails at parsing the rest of the docstring.
36 typer_app(["foo", "--help"], standalone_mode=False)
37 # Foo Docstring.
38 # Parameters ---------- bar: str Bar parameter docstring.
39 #
40 # ╭─ Arguments ────────────────────────────────────────────────────╮
41 # │ * bar TEXT [default: None] [required] │
42 # ╰────────────────────────────────────────────────────────────────╯
43
44 cyclopts_app = cyclopts.App()
45
46
47 @cyclopts_app.command()
48 def foo(bar):
49 """Foo Docstring.
50
51 Parameters
52 ----------
53 bar: str
54 Bar parameter docstring.
55 """
56 pass
57
58
59 print("Cyclopts:")
60
61 # Cyclopts also properly parses the short description.
62 cyclopts_app(["--help"])
63 # ╭─ Commands ─────────────────────────────────────────────────────╮
64 # │ foo Foo Docstring. │
65 # ╰────────────────────────────────────────────────────────────────╯
66 cyclopts_app(["foo", "--help"])
67 # Foo Docstring.
68 #
69 # ╭─ Parameters ───────────────────────────────────────────────────╮
70 # │ * BAR,--bar Bar parameter docstring. [required] │
71 # ╰────────────────────────────────────────────────────────────────╯