Skip to content
Myr

contributing.md

This file

Path

docs/contributing.md

248 lines · 5.8 KiB · Markdown

Last changed by

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

History of this file

Take it

The walk stopped after 200 commits: lines older than d75debf point at it.

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

lines 1–24why, one step back
1First, you might want to see the basic ways to [help Typer and get help](help-typer.md){.internal-link target=_blank}.
23## Developing45If you already cloned the repository and you know that you need to deep dive in the code, here are some guidelines to set up your environment.67### Virtual environment with `venv`89You can create a virtual environment in a directory using Python's `venv` module:1011<div class="termy">1213```console14$ python -m venv env15```1617</div>1819That will create a directory `./env/` with the Python binaries and then you will be able to install packages for that isolated environment.2021### Activate the environment2223Activate the new environment with:24

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 25why, one step back
25//// tab | Linux, macOS

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 26why, one step back
26

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 27why, one step back
27<div class="termy">

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 28why, one step back
28

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 29–31why, one step back
29```console
30$ source ./env/bin/activate31```

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 32why, one step back
32

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 33why, one step back
33</div>

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 34why, one step back
34

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 35why, one step back
35////

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 36why, one step back
36

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 37why, one step back
37//// tab | Windows PowerShell

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 38why, one step back
38

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 39why, one step back
39<div class="termy">

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 40why, one step back
40

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 41–43why, one step back
41```console
42$ .\env\Scripts\Activate.ps143```

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 44why, one step back
44

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 45why, one step back
45</div>

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 46why, one step back
46

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 47why, one step back
47////

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 48why, one step back
48

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 49why, one step back
49//// tab | Windows Bash

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 50why, one step back
50

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 51why, one step back
51Or if you use Bash for Windows (e.g. <a href="https://gitforwindows.org/" class="external-link" target="_blank">Git Bash</a>):

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 52why, one step back
52

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 53why, one step back
53<div class="termy">

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 54why, one step back
54

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 55–62why, one step back
55```console
56$ source ./env/Scripts/activate57```5859</div>6061////62

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

lines 63–64why, one step back
63To check it worked, use:
64

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 65why, one step back
65//// tab | Linux, macOS, Windows Bash

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 66why, one step back
66

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 67why, one step back
67<div class="termy">

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 68why, one step back
68

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 69–70why, one step back
69```console
70$ which pip

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 71why, one step back
71

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 72–73why, one step back
72some/directory/typer/env/bin/pip
73```

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 74why, one step back
74

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 75why, one step back
75</div>

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 76why, one step back
76

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 77why, one step back
77////

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 78why, one step back
78

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 79why, one step back
79//// tab | Windows PowerShell

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 80why, one step back
80

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 81why, one step back
81<div class="termy">

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 82why, one step back
82

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 83–84why, one step back
83```console
84$ Get-Command pip

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 85why, one step back
85

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 86–87why, one step back
86some/directory/typer/env/bin/pip
87```

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 88why, one step back
88

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 89–92why, one step back
89</div>
9091////92

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

lines 93–94why, one step back
93If it shows the `pip` binary at `env/bin/pip` then it worked. 🎉
94

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 95why, one step back
95/// tip

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 96why, one step back
96

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 97why, one step back
97Every time you install a new package with `pip` under that environment, activate the environment again.

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 98why, one step back
98

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 99–102why, one step back
99This makes sure that if you use a terminal program installed by that package (like `flit`), you use the one from your local environment and not any other that could be installed globally.
100101///102

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

lines 103–122why, one step back
103### Flit
104105**Typer** uses <a href="https://flit.readthedocs.io/en/latest/index.html" class="external-link" target="_blank">Flit</a> to build, package and publish the project.106107After activating the environment as described above, install `flit`:108109<div class="termy">110111```console112$ pip install flit113114---> 100%115```116117</div>118119Now re-activate the environment to make sure you are using the `flit` you just installed (and not a global one).120121And now use `flit` to install the development dependencies:122

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 123why, one step back
123//// tab | Linux, macOS

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 124why, one step back
124

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 125why, one step back
125<div class="termy">

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 126why, one step back
126

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 127–128why, one step back
127```console
128$ flit install --deps develop --symlink

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 129why, one step back
129

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 130–131why, one step back
130---> 100%
131```

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 132why, one step back
132

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 133why, one step back
133</div>

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 134why, one step back
134

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 135why, one step back
135////

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 136why, one step back
136

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 137why, one step back
137//// tab | Windows

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 138why, one step back
138

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 139why, one step back
139If you are on Windows, use `--pth-file` instead of `--symlink`:

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 140why, one step back
140

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

line 141why, one step back
141<div class="termy">

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 142why, one step back
142

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 143–144why, one step back
143```console
144$ flit install --deps develop --pth-file

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

line 145why, one step back
145

🔧 Update tabs and admonitions with new syntax and new MkDocs features (#906)Sebastián Ramírezbefore adoption289b230

lines 146–151why, one step back
146---> 100%
147```148149</div>150151////

🔧 Update new issue chooser to suggest GitHub Discussions (#544)Sebastián Ramírezbefore adoptiond75debf

lines 152–248why, one step back
152
153It will install all the dependencies and your local Typer in your local environment.154155#### Using your local Typer156157If you create a Python file that imports and uses Typer, and run it with the Python from your local environment, it will use your local Typer source code.158159And if you update that local Typer source code, as it is installed with `--symlink` (or `--pth-file` on Windows), when you run that Python file again, it will use the fresh version of Typer you just edited.160161That way, you don't have to "install" your local version to be able to test every change.162163### Format164165There is a script that you can run that will format and clean all your code:166167<div class="termy">168169```console170$ bash scripts/format.sh171```172173</div>174175It will also auto-sort all your imports.176177For it to sort them correctly, you need to have Typer installed locally in your environment, with the command in the section above using `--symlink` (or `--pth-file` on Windows).178179### Format imports180181There is another script that formats all the imports and makes sure you don't have unused imports:182183<div class="termy">184185```console186$ bash scripts/format-imports.sh187```188189</div>190191As it runs one command after the other and modifies and reverts many files, it takes a bit longer to run, so it might be easier to use `scripts/format.sh` frequently and `scripts/format-imports.sh` only before committing.192193## Docs194195The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.196197All the documentation is in Markdown format in the directory `./docs`.198199Many of the tutorials have blocks of code.200201In most of the cases, these blocks of code are actual complete applications that can be run as is.202203In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs_src/` directory.204205And those Python files are included/injected in the documentation when generating the site.206207### Docs for tests208209Most of the tests actually run against the example source files in the documentation.210211This helps making sure that:212213* The documentation is up to date.214* The documentation examples can be run as is.215* Most of the features are covered by the documentation, ensured by test coverage.216217During local development, there is a script that builds the site and checks for any changes, live-reloading:218219<div class="termy">220221```console222$ bash scripts/docs-live.sh223224<span style="color: green;">[INFO]</span> - Building documentation...225<span style="color: green;">[INFO]</span> - Cleaning site directory226<span style="color: green;">[INFO]</span> - Documentation built in 2.74 seconds227<span style="color: green;">[INFO]</span> - Serving on http://127.0.0.1:8008228```229230</div>231232It will serve the documentation on `http://127.0.0.1:8008`.233234That way, you can edit the documentation/source files and see the changes live.235236## Tests237238There is a script that you can run locally to test all the code and generate coverage reports in HTML:239240<div class="termy">241242```console243$ bash scripts/test-cov-html.sh244```245246</div>247248This command generates a directory `./htmlcov/`, if you open the file `./htmlcov/index.html` in your browser, you can explore interactively the regions of code that are covered by the tests, and notice if there is any region missing.