Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d8e06a9
reference index page
svlandeg Jan 19, 2026
4fbcba4
configure mkdocstrings
svlandeg Jan 19, 2026
2a50d6c
add Typer class
svlandeg Jan 19, 2026
e1c208e
add annotated-docs to the dependencies
svlandeg Jan 19, 2026
1bce4e2
start adding inline documentation
svlandeg Jan 19, 2026
30de032
document parameters of typer.Typer
svlandeg Jan 19, 2026
3362194
document parameters of typer.Typer (continued)
svlandeg Jan 19, 2026
f4db7e5
fix whitespace
svlandeg Jan 19, 2026
0c9f9cb
more docstrings in main.py
svlandeg Jan 19, 2026
fbd5fd8
fix
svlandeg Jan 19, 2026
f0fddec
more documentation
svlandeg Jan 19, 2026
8787b6b
finish documenting all methods in main.py
svlandeg Jan 20, 2026
fab4433
remove the attributes from the main.py ref docs
svlandeg Jan 20, 2026
5e45b21
add a page for parameters
svlandeg Jan 20, 2026
b159285
customize example
svlandeg Jan 20, 2026
ef6312a
first few annotations in params.py
svlandeg Jan 20, 2026
5c4f687
some more annotations in params.py
svlandeg Jan 20, 2026
4a5d4b2
more annotations in params.py
svlandeg Jan 21, 2026
064db0c
and more annotations in params.py
svlandeg Jan 21, 2026
6ef7033
some rephrasings
svlandeg Jan 21, 2026
1a112e6
Merge branch 'master' into docs/api
svlandeg Jan 26, 2026
8134ea3
document run and launch in the reference API
svlandeg Jan 26, 2026
5e679fc
add actual markdown file for run and launch
svlandeg Jan 26, 2026
d5e3ebd
fix newlines in example code
svlandeg Jan 26, 2026
73771e7
shorten examples to avoid too much horizontal scrolling
svlandeg Jan 26, 2026
3494db6
add special File classes to reference docs
svlandeg Jan 26, 2026
0ae35f1
add ref docs for Context and CallbackParam
svlandeg Jan 26, 2026
279bb3d
small fixes
svlandeg Jan 26, 2026
9ed6980
fix formatting
svlandeg Jan 26, 2026
c532901
Merge branch 'master' into docs/api
svlandeg Jan 26, 2026
5f5c0e8
🎨 Auto format
pre-commit-ci-lite[bot] Jan 26, 2026
8f03745
small fix
svlandeg Jan 26, 2026
eec2d4f
Merge remote-tracking branch 'origin/docs/api' into docs/api
svlandeg Jan 26, 2026
0eb9123
small fixes
svlandeg Jan 26, 2026
1131c9c
fixing example formatting
svlandeg Jan 26, 2026
c87feb1
remove unnecessary comma's
svlandeg Jan 26, 2026
7e2b2b4
small change of paragraph order
svlandeg Jan 26, 2026
0e57ee9
small change of paragraph order (correct edit, reverting the previous…
svlandeg Jan 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions docs/reference/context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Context

When you create a Typer application it uses Click underneath.
And every Click application has a special object called a [`Context`](https://click.palletsprojects.com/en/stable/api/#click.Context) that is normally hidden.
But you can access the context by declaring a function parameter of type `typer.Context`.

The same way you can access the context by declaring a function parameter with its value,
you can declare another function parameter with type `typer.CallbackParam` to get the specific Click [`Parameter`](https://click.palletsprojects.com/en/stable/api/#click.Parameter) object.

```python
from typing import Annotated

import typer

app = typer.Typer()


def name_callback(ctx: typer.Context, param: typer.CallbackParam, value: str):
if ctx.resilient_parsing:
return
print(f"Validating param: {param.name}")
if value != "Rick":
raise typer.BadParameter("Only Rick is allowed")
return value


@app.command()
def main(name: Annotated[str | None, typer.Option(callback=name_callback)] = None):
print(f"Hello {name}")


if __name__ == "__main__":
app()
```

::: typer.Context

::: typer.CallbackParam
18 changes: 18 additions & 0 deletions docs/reference/file_objects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# File objects

When you want to declare some types of files, you can use `Path`.
However, in some cases you may need to have access to a file-like object, and then you can use these [special File types](https://typer.tiangolo.com/tutorial/parameter-types/file/).

These objects can be imported from `typer` directly:

```python
from typer import FileBinaryRead, FileBinaryWrite, FileText, FileTextWrite
```

::: typer.FileText

::: typer.FileTextWrite

::: typer.FileBinaryRead

::: typer.FileBinaryWrite
7 changes: 7 additions & 0 deletions docs/reference/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Reference

Here's the reference or code API, the classes, functions, parameters, attributes, and
all the Typer parts you can use in your applications.

If you want to **learn Typer** you are much better off reading the
[Typer Tutorial](https://typer.tiangolo.com/tutorial/).
31 changes: 31 additions & 0 deletions docs/reference/parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Parameters

Parameters to our command line interface may be both [CLI Options](https://typer.tiangolo.com/tutorial/options/) and [CLI Arguments](https://typer.tiangolo.com/tutorial/arguments/):

```python
from typing import Annotated
import typer

app = typer.Typer()

@app.command()
def register(
user: Annotated[str, typer.Argument()],
age: Annotated[int, typer.Option(min=18)],
score: Annotated[float, typer.Option(max=100)] = 0,
):
print(f"User is {user}")
print(f"--age is {age}")
print(f"--score is {score}")

if __name__ == "__main__":
app()
```

::: typer.Argument
options:
show_overloads: false

::: typer.Option
options:
show_overloads: false
11 changes: 11 additions & 0 deletions docs/reference/run_launch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `run` and `launch`

These two functions can be imported from `typer` directly:

```python
from typer import launch, run
```

::: typer.run

::: typer.launch
16 changes: 16 additions & 0 deletions docs/reference/typer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `Typer` class

Here's the reference information for the `Typer` class, with all its parameters, attributes and methods.

You can import the `Typer` class directly from `typer`:

```python
from typer import Typer
```

::: typer.Typer
options:
members:
- callback
- command
- add_typer
26 changes: 26 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ plugins:
redirects:
redirect_maps:
typer-cli.md: tutorial/typer-command.md
mkdocstrings:
handlers:
python:
options:
extensions:
- griffe_typingdoc
show_root_heading: true
show_if_no_docstring: true
inherited_members: true
members_order: source
separate_signature: true
unwrap_annotated: true
filters:
- '!^_'
merge_init_into_class: true
docstring_section_style: spacy
signature_crossrefs: true
show_symbol_type_heading: true
show_symbol_type_toc: true

nav:
- Typer: index.md
Expand Down Expand Up @@ -138,6 +157,13 @@ nav:
- tutorial/exceptions.md
- tutorial/one-file-per-command.md
- tutorial/typer-command.md
- Reference (Code API):
- reference/index.md
- reference/typer.md
- reference/run_launch.md
- reference/parameters.md
- reference/file_objects.md
- reference/context.md
- Resources:
- resources/index.md
- help-typer.md
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ classifiers = [
dependencies = [
"click >= 8.0.0",
"typing-extensions >= 3.7.4.3",
"annotated-doc>=0.0.2",
]
readme = "README.md"

Expand Down
Loading