Skip to content
Myr

🔧 Update MkDocs to have titles in Markdown files instead of config (#913)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sebastián Ramírez · committed by GitHub · parent 9791e14 · Browse files · 59 files+174 added−58 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

59 files+174 added−58 removed

  • other:+174 added−58 removed

59 files+174 added−58 removed

modified:docs/tutorial/arguments/default.md+2 added
modified:docs/tutorial/arguments/envvar.md+2 added
1# CLI Arguments with Environment Variables23You can also configure a *CLI argument* to read a value from an environment variable if it is not provided in the command line as a *CLI argument*.45To do that, use the `envvar` parameter for `typer.Argument()`:6
174 unmodified lines
modified:docs/tutorial/arguments/help.md+2 added
1# CLI Arguments with Help23In the *First Steps* section you saw how to add help for a CLI app/command by adding it to a function's <abbr title="a multi-line string as the first expression inside a function (not assigned to any variable) used for documentation">docstring</abbr>.45Here's how that last example looked like:6
449 unmodified lines
modified:docs/tutorial/arguments/index.md+2 added
modified:docs/tutorial/arguments/optional.md+2 added
1# Optional CLI Arguments23We said before that *by default*:45* *CLI options* are **optional**6* *CLI arguments* are **required**
247 unmodified lines
modified:docs/tutorial/arguments/other-uses.md+2 added
modified:docs/tutorial/commands/arguments.md+2 added
modified:docs/tutorial/commands/callback.md+2 added
1# Typer Callback23When you create an `app = typer.Typer()` it works as a group of commands.45And you can create multiple commands with it.6
187 unmodified lines
modified:docs/tutorial/commands/context.md+2 added
1# Using the Context23When you create a **Typer** application it uses Click underneath. And every Click application has a special object called a <a href="https://click.palletsprojects.com/en/8.1.x/commands/#nested-handling-and-contexts" class="external-link" target="_blank">"Context"</a> that is normally hidden.45But you can access the context by declaring a function parameter of type `typer.Context`.6
129 unmodified lines
modified:docs/tutorial/commands/help.md+2 added
1# Command Help23The same as before, you can add help for the commands in the docstrings and the *CLI options*.45And the `typer.Typer()` application receives a parameter `help` that you can pass with the main help text for your CLI program:6
567 unmodified lines
modified:docs/tutorial/commands/index.md+2 added
1# Commands23We have seen how to create a CLI program with possibly several *CLI options* and *CLI arguments*.45But **Typer** allows you to create CLI programs with several commands (also known as subcommands).6
280 unmodified lines
modified:docs/tutorial/commands/name.md+2 added
1# Custom Command Name23By default, the command names are generated from the function name.45So, if your function is something like:6
52 unmodified lines
modified:docs/tutorial/commands/one-or-multiple.md+2 added
1# One or Multiple Commands23You might have noticed that if you create a single command, as in the first example:45```Python hl_lines="3 6 12"6{!../docs_src/commands/index/tutorial001.py!}
150 unmodified lines
modified:docs/tutorial/commands/options.md+2 added
1# Command CLI Options23Commands can also have their own *CLI options*.45In fact, each command can have different *CLI arguments* and *CLI options*:6
113 unmodified lines
modified:docs/tutorial/multiple-values/arguments-with-multiple-values.md+2 added
1# CLI Arguments with Multiple Values23*CLI arguments* can also receive multiple values.45You can define the type of a *CLI argument* using `typing.List`.6
94 unmodified lines
modified:docs/tutorial/multiple-values/index.md+2 added
1# Multiple Values23There are several ways to declare multiple values for *CLI options* and *CLI arguments*.45We'll see them in the next short sections.
modified:docs/tutorial/multiple-values/multiple-options.md+2 added
1# Multiple CLI Options23You can declare a *CLI option* that can be used multiple times, and then get all the values.45For example, let's say you want to accept several users in a single execution.6
99 unmodified lines
modified:docs/tutorial/multiple-values/options-with-multiple-values.md+2 added
1# CLI Options with Multiple Values23You can also declare a *CLI option* that takes several values of different types.45You can set the number of values and types to anything you want, but it has to be a fixed number of values.6
107 unmodified lines
modified:docs/tutorial/options/callback-and-context.md+2 added
1# CLI Option Callback and Context23In some occasions you might want to have some custom logic for a specific *CLI parameter* (for a *CLI option* or *CLI argument*) that is executed with the value received from the terminal.45In those cases you can use a *CLI parameter* callback function.6
285 unmodified lines
modified:docs/tutorial/options/help.md+2 added
1# CLI Options with Help23You already saw how to add a help text for *CLI arguments* with the `help` parameter.45Let's now do the same for *CLI options*:6
239 unmodified lines
modified:docs/tutorial/options/index.md+2 added
1# CLI Options23In the next short sections we will see how to modify *CLI options* using `typer.Option()`.45`typer.Option()` works very similarly to `typer.Argument()`, but has some extra features that we'll see next.
modified:docs/tutorial/options/name.md+2 added
1# CLI Option Name23By default **Typer** will create a *CLI option* name from the function parameter.45So, if you have a function with:6
415 unmodified lines
modified:docs/tutorial/options/password.md+2 added
1# Password CLI Option and Confirmation Prompt23Apart from having a prompt, you can make a *CLI option* have a `confirmation_prompt=True`:45//// tab | Python 3.7+6
85 unmodified lines
modified:docs/tutorial/options/prompt.md+2 added
1# CLI Option Prompt23It's also possible to, instead of just showing an error, ask for the missing value with `prompt=True`:45//// tab | Python 3.7+6
138 unmodified lines
modified:docs/tutorial/options/required.md+2 added
1# Required CLI Options23We said before that *by default*:45* *CLI options* are **optional**6* *CLI arguments* are **required**
83 unmodified lines
modified:docs/tutorial/options/version.md+2 added
1# Version CLI Option, `is_eager`23You could use a callback to implement a `--version` *CLI option*.45It would show the version of your CLI program and then it would terminate it. Even before any other *CLI parameter* is processed.6
166 unmodified lines
modified:docs/tutorial/parameter-types/bool.md+2 added
1# Boolean CLI Options23We have seen some examples of *CLI options* with `bool`, and how **Typer** creates `--something` and `--no-something` automatically.45But we can customize those names.6
253 unmodified lines
modified:docs/tutorial/parameter-types/custom-types.md+2 added
1# Custom Types23You can easily use your own custom types in your **Typer** applications.45The way to do it is by providing a way to <abbr title="convert from some plain format, like the input text in the CLI, into Python objects">parse</abbr> input into your own types.6
44 unmodified lines
modified:docs/tutorial/parameter-types/datetime.md+2 added
1# DateTime23You can specify a *CLI parameter* as a Python <a href="https://docs.python.org/3/library/datetime.html" class="external-link" target="_blank">`datetime`</a>.45Your function will receive a standard Python `datetime` object, and again, your editor will give you completion, etc.6
101 unmodified lines
modified:docs/tutorial/parameter-types/enum.md+2 added
1# Enum - Choices23To define a *CLI parameter* that can take a value from a predefined set of values you can use a standard Python <a href="https://docs.python.org/3/library/enum.html" class="external-link" target="_blank">`enum.Enum`</a>:45```Python hl_lines="1 6 7 8 9 12 13"6{!../docs_src/parameter_types/enum/tutorial001.py!}
149 unmodified lines
modified:docs/tutorial/parameter-types/file.md+2 added
1# File23Apart from `Path` *CLI parameters* you can also declare some types of "files".45/// tip6
346 unmodified lines
modified:docs/tutorial/parameter-types/index.md+2 added
1# CLI Parameter Types23You can use several data types for the *CLI options* and *CLI arguments*, and you can add data validation requirements too.45## Data conversion6
65 unmodified lines
modified:docs/tutorial/parameter-types/number.md+2 added
1# Number23You can define numeric validations with `max` and `min` values for `int` and `float` *CLI parameters*:45//// tab | Python 3.7+6
199 unmodified lines
modified:docs/tutorial/parameter-types/path.md+2 added
1# Path23You can declare a *CLI parameter* to be a standard Python <a href="https://docs.python.org/3/library/pathlib.html#basic-use" class="external-link" target="_blank">`pathlib.Path`</a>.45This is what you would do for directory paths, file paths, etc:6
146 unmodified lines
modified:docs/tutorial/parameter-types/uuid.md+2 added
1# UUID23/// info45A UUID is a <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" class="external-link" target="_blank">"Universally Unique Identifier"</a>.6
45 unmodified lines
modified:docs/tutorial/subcommands/add-typer.md+2 added
1# Add Typer23We'll start with the core idea.45To add a `typer.Typer()` app inside of another.6
168 unmodified lines
modified:docs/tutorial/subcommands/callback-override.md+2 added
1# Sub-Typer Callback Override23When creating a **Typer** app you can define a callback function, it always executes and defines the *CLI arguments* and *CLI options* that go before a command.45When adding a Typer app inside of another, the sub-Typer can also have its own callback.6
100 unmodified lines
modified:docs/tutorial/subcommands/index.md+2 added
1# SubCommands - Command Groups23You read before how to create a program with [Commands](../commands/index.md){.internal-link target=_blank}.45Now we'll see how to create a *CLI program* with commands that have their own subcommands. Also known as command groups.6
35 unmodified lines
modified:docs/tutorial/subcommands/name-and-help.md+2 added
1# SubCommand Name and Help23When adding a Typer app to another we have seen how to set the `name` to use for the command.45For example to set the command to `users`:6
467 unmodified lines
modified:docs/tutorial/subcommands/nested-subcommands.md+2 added
1# Nested SubCommands23We'll now see how these same ideas can be extended for deeply nested commands.45Let's imagine that the same *CLI program* from the previous examples now needs to handle `lands`.6
297 unmodified lines
modified:docs/tutorial/subcommands/single-file.md+2 added
1# SubCommands in a Single File23In some cases, it's possible that your application code needs to live on a single file.45You can still use the same ideas:6
144 unmodified lines
modified:docs/tutorial/app-dir.md+2 added
1# CLI Application Directory23You can get the application directory where you can, for example, save configuration files with `typer.get_app_dir()`:45```Python hl_lines="9"6{!../docs_src/app_dir/tutorial001.py!}
39 unmodified lines
modified:docs/tutorial/first-steps.md+2 added
1# First Steps23## The simplest example45The simplest **Typer** file could look like this:6
515 unmodified lines
modified:docs/tutorial/index.md+2 added
1# Tutorial - User Guide23## Python types45If you need a refresher about how to use Python type hints, check the first part of <a href="https://fastapi.tiangolo.com/python-types/" class="external-link" target="_blank">FastAPI's Python types intro</a>.6
88 unmodified lines
modified:docs/tutorial/launch.md+2 added
1# Launching Applications23You can launch applications from your CLI program with `typer.launch()`.45It will launch the appropriate application depending on the URL or file type you pass it:6
47 unmodified lines
modified:docs/tutorial/options-autocompletion.md+2 added
1# CLI Option autocompletion23As you have seen, apps built with **Typer** have completion in your shell that works when you create a Python package or using the `typer` command.45It normally completes *CLI options*, *CLI arguments*, and subcommands (that you will learn about later).6
560 unmodified lines
modified:docs/tutorial/package.md+2 added
1# Building a Package23When you create a CLI program with **Typer** you probably want to create your own Python package.45That's what allows your users to install it and have it as an independent program that they can use in their terminal.6
769 unmodified lines
modified:docs/tutorial/printing.md+2 added
1# Printing and Colors23You can use the normal `print()` to show information on the screen:45```Python hl_lines="5"6{!../docs_src/first_steps/tutorial001.py!}
292 unmodified lines
modified:docs/tutorial/progressbar.md+2 added
1# Progress Bar23If you are executing an operation that can take some time, you can inform it to the user. 🤓45## Progress Bar6
244 unmodified lines
modified:docs/tutorial/prompt.md+2 added
1# Ask with Prompt23When you need to ask the user for info interactively you should normally use [*CLI Option*s with Prompt](options/prompt.md){.internal-link target=_blank}, because they allow using the CLI program in a non-interactive way (for example, a Bash script could use it).45But if you absolutely need to ask for interactive information without using a *CLI option*, you can use `typer.prompt()`:6
96 unmodified lines
modified:docs/tutorial/terminating.md+2 added
1# Terminating23There are some cases where you might want to terminate a command at some point, and stop all subsequent execution.45It could be that your code determined that the program completed successfully, or it could be an operation aborted.6
120 unmodified lines
modified:docs/tutorial/testing.md+2 added
1# Testing23Testing **Typer** applications is very easy with <a href="https://docs.pytest.org/en/latest/" class="external-link" target="_blank">pytest</a>.45Let's say you have an application `app/main.py` with:6
242 unmodified lines
modified:docs/tutorial/using-click.md+2 added
1# Using Click23/// warning45This is a more advanced topic, if you are starting with **Typer**, feel free to skip it.6
195 unmodified lines
modified:docs/alternatives.md+2 added
1# Alternatives, Inspiration and Comparisons23What inspired **Typer**, how it compares to other alternatives and what it learned from them.45## Intro6
97 unmodified lines
modified:docs/contributing.md+2 added
1# Development - Contributing23First, you might want to see the basic ways to [help Typer and get help](help-typer.md){.internal-link target=_blank}.45## Developing6
244 unmodified lines
modified:docs/features.md+2 added
1# Features23## Design based on **FastAPI**45<a href="https://fastapi.tiangolo.com" target="_blank"><img src="https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png" style="width: 20%;"></a>6
87 unmodified lines
modified:docs/help-typer.md+2 added
1# Help Typer - Get Help23Are you liking **Typer**?45Would you like to help Typer, other users, and the author?6
243 unmodified lines
modified:docs/release-notes.md+2 added
1# Release Notes23## Latest Changes45### Features6
580 unmodified lines
modified:mkdocs.yml+58 added-58 removed
50 unmodified lines
51 typer-cli.md: tutorial/typer-command.md5253nav:54 - Typer: index.md55 - Features: features.md55 - features.md56 - Tutorial - User Guide:57 - Tutorial - User Guide - Intro: tutorial/index.md58 - First Steps: tutorial/first-steps.md59 - Printing and Colors: tutorial/printing.md60 - Terminating: tutorial/terminating.md57 - tutorial/index.md58 - tutorial/first-steps.md59 - tutorial/printing.md60 - tutorial/terminating.md61 - CLI Arguments:62 - CLI Arguments Intro: tutorial/arguments/index.md63 - Optional CLI Arguments: tutorial/arguments/optional.md64 - CLI Arguments with Default: tutorial/arguments/default.md65 - CLI Arguments with Help: tutorial/arguments/help.md66 - CLI Arguments with Environment Variables: tutorial/arguments/envvar.md67 - Other uses: tutorial/arguments/other-uses.md62 - tutorial/arguments/index.md63 - tutorial/arguments/optional.md64 - tutorial/arguments/default.md65 - tutorial/arguments/help.md66 - tutorial/arguments/envvar.md67 - tutorial/arguments/other-uses.md68 - CLI Options:69 - CLI Options Intro: tutorial/options/index.md70 - CLI Options with Help: tutorial/options/help.md71 - Required CLI Options: tutorial/options/required.md72 - CLI Option Prompt: tutorial/options/prompt.md73 - Password CLI Option and Confirmation Prompt: tutorial/options/password.md74 - CLI Option Name: tutorial/options/name.md75 - CLI Option Callback and Context: tutorial/options/callback-and-context.md76 - Version CLI Option, is_eager: tutorial/options/version.md69 - tutorial/options/index.md70 - tutorial/options/help.md71 - tutorial/options/required.md72 - tutorial/options/prompt.md73 - tutorial/options/password.md74 - tutorial/options/name.md75 - tutorial/options/callback-and-context.md76 - tutorial/options/version.md77 - Commands:78 - Commands Intro: tutorial/commands/index.md79 - Command CLI Arguments: tutorial/commands/arguments.md80 - Command CLI Options: tutorial/commands/options.md81 - Command Help: tutorial/commands/help.md82 - Custom Command Name: tutorial/commands/name.md83 - Typer Callback: tutorial/commands/callback.md84 - One or Multiple Commands: tutorial/commands/one-or-multiple.md85 - Using the Context: tutorial/commands/context.md86 - CLI Option autocompletion: tutorial/options-autocompletion.md78 - tutorial/commands/index.md79 - tutorial/commands/arguments.md80 - tutorial/commands/options.md81 - tutorial/commands/help.md82 - tutorial/commands/name.md83 - tutorial/commands/callback.md84 - tutorial/commands/one-or-multiple.md85 - tutorial/commands/context.md86 - tutorial/options-autocompletion.md87 - CLI Parameter Types:88 - CLI Parameter Types Intro: tutorial/parameter-types/index.md89 - Number: tutorial/parameter-types/number.md90 - Boolean CLI Options: tutorial/parameter-types/bool.md91 - UUID: tutorial/parameter-types/uuid.md92 - DateTime: tutorial/parameter-types/datetime.md93 - Enum - Choices: tutorial/parameter-types/enum.md94 - Path: tutorial/parameter-types/path.md95 - File: tutorial/parameter-types/file.md96 - Custom Types: tutorial/parameter-types/custom-types.md88 - tutorial/parameter-types/index.md89 - tutorial/parameter-types/number.md90 - tutorial/parameter-types/bool.md91 - tutorial/parameter-types/uuid.md92 - tutorial/parameter-types/datetime.md93 - tutorial/parameter-types/enum.md94 - tutorial/parameter-types/path.md95 - tutorial/parameter-types/file.md96 - tutorial/parameter-types/custom-types.md97 - SubCommands - Command Groups:98 - SubCommands - Command Groups - Intro: tutorial/subcommands/index.md99 - Add Typer: tutorial/subcommands/add-typer.md100 - SubCommands in a Single File: tutorial/subcommands/single-file.md101 - Nested SubCommands: tutorial/subcommands/nested-subcommands.md102 - Sub-Typer Callback Override: tutorial/subcommands/callback-override.md103 - SubCommand Name and Help: tutorial/subcommands/name-and-help.md98 - tutorial/subcommands/index.md99 - tutorial/subcommands/add-typer.md100 - tutorial/subcommands/single-file.md101 - tutorial/subcommands/nested-subcommands.md102 - tutorial/subcommands/callback-override.md103 - tutorial/subcommands/name-and-help.md104 - Multiple Values:105 - Multiple Values Intro: tutorial/multiple-values/index.md106 - Multiple CLI Options: tutorial/multiple-values/multiple-options.md107 - CLI Options with Multiple Values: tutorial/multiple-values/options-with-multiple-values.md108 - CLI Arguments with Multiple Values: tutorial/multiple-values/arguments-with-multiple-values.md109 - Ask with Prompt: tutorial/prompt.md110 - Progress Bar: tutorial/progressbar.md111 - CLI Application Directory: tutorial/app-dir.md112 - Launching Applications: tutorial/launch.md113 - Testing: tutorial/testing.md114 - Using Click: tutorial/using-click.md115 - Building a Package: tutorial/package.md105 - tutorial/multiple-values/index.md106 - tutorial/multiple-values/multiple-options.md107 - tutorial/multiple-values/options-with-multiple-values.md108 - tutorial/multiple-values/arguments-with-multiple-values.md109 - tutorial/prompt.md110 - tutorial/progressbar.md111 - tutorial/app-dir.md112 - tutorial/launch.md113 - tutorial/testing.md114 - tutorial/using-click.md115 - tutorial/package.md116 - tutorial/exceptions.md117 - tutorial/typer-command.md118 - Alternatives, Inspiration and Comparisons: alternatives.md119 - Help Typer - Get Help: help-typer.md120 - Development - Contributing: contributing.md121 - Release Notes: release-notes.md118 - alternatives.md119 - help-typer.md120 - contributing.md121 - release-notes.md122123markdown_extensions:124 toc:125 permalink: true
49 unmodified lines