contributing.md
This file
Path
docs/contributing.md
231 lines · 5.8 KiB · Markdown
Last changed by
⬆ Upgrade Isort to version 5.x.x (#137)Sebastián Ramírezbefore adoption89ddc35
History of this fileTake it
The walk stopped after 200 commits: lines older than 96731c4 point at it.
:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 1–10why, one step back1First, 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:10:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 11–12why, one step back11<div class="termy">12:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 13–16why, one step back13```console14$ python -m venv env15```16:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 17–18why, one step back17</div>18:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 19–24why, one step back19That 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:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 25why, one step back25=== "Linux, macOS":bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 26why, one step back26:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 27why, one step back27 <div class="termy">:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 28why, one step back28:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 29–31why, one step back29 ```console30 $ source ./env/bin/activate31 ```:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 32why, one step back32:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 33why, one step back33 </div>:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 34why, one step back34:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 35why, one step back35=== "Windows PowerShell":bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 36why, one step back36:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 37why, one step back37 <div class="termy">:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 38why, one step back38:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 39–41why, one step back39 ```console40 $ .\env\Scripts\Activate.ps141 ```:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 42why, one step back42:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 43why, one step back43 </div>:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 44why, one step back44:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 45why, one step back45=== "Windows Bash":bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 46why, one step back46:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 47why, one step back47 Or if you use Bash for Windows (e.g. <a href="https://gitforwindows.org/" class="external-link" target="_blank">Git Bash</a>)::sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 48why, one step back48:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 49why, one step back49 <div class="termy">:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 50why, one step back50:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 51–56why, one step back51 ```console52 $ source ./env/Scripts/activate53 ```5455 </div>56:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 57–58why, one step back57To check it worked, use:58:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 59why, one step back59=== "Linux, macOS, Windows Bash":bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 60why, one step back60:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 61why, one step back61 <div class="termy">:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 62why, one step back62:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 63–64why, one step back63 ```console64 $ which pip:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 65why, one step back65:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 66–67why, one step back66 some/directory/typer/env/bin/pip67 ```:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 68why, one step back68:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 69why, one step back69 </div>:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 70why, one step back70:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 71why, one step back71=== "Windows PowerShell":sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 72why, one step back72:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 73why, one step back73 <div class="termy">:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 74why, one step back74:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 75–76why, one step back75 ```console76 $ Get-Command pip:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 77why, one step back77:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 78–79why, one step back78 some/directory/typer/env/bin/pip79 ```:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 80why, one step back80:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 81why, one step back81 </div>:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 82why, one step back82:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 83–84why, one step back83If it shows the `pip` binary at `env/bin/pip` then it worked. 🎉84:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 85–95why, one step back85!!! tip86 Every time you install a new package with `pip` under that environment, activate the environment again.8788 This 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.8990### Flit9192**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.9394After activating the environment as described above, install `flit`:95:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 96–97why, one step back96<div class="termy">97:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 98–99why, one step back98```console99$ pip install flit:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 100–101why, one step back100101---> 100%:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 102–103why, one step back102```103:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 104–105why, one step back104</div>105:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 106–109why, one step back106Now re-activate the environment to make sure you are using the `flit` you just installed (and not a global one).107108And now use `flit` to install the development dependencies:109:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 110why, one step back110=== "Linux, macOS":bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 111why, one step back111:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 112why, one step back112 <div class="termy">:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 113why, one step back113:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 114–115why, one step back114 ```console115 $ flit install --deps develop --symlink:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
line 116why, one step back116:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 117–118why, one step back117 ---> 100%118 ```:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 119why, one step back119:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 120why, one step back120 </div>:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 121why, one step back121:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 122why, one step back122=== "Windows":bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 123why, one step back123:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 124why, one step back124 If you are on Windows, use `--pth-file` instead of `--symlink`::bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 125why, one step back125:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 126why, one step back126 <div class="termy">:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 127why, one step back127:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 128–129why, one step back128 ```console129 $ flit install --deps develop --pth-file:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 130why, one step back130:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
lines 131–135why, one step back131 ---> 100%132 ```133134 </div>135:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 136–141why, one step back136It will install all the dependencies and your local Typer in your local environment.137138#### Using your local Typer139140If 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.141:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d
line 142why, one step back142And 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.:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 143–149why, one step back143144That way, you don't have to "install" your local version to be able to test every change.145146### Format147148There is a script that you can run that will format and clean all your code:149:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 150–151why, one step back150<div class="termy">151:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 152–155why, one step back152```console153$ bash scripts/format.sh154```155:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 156–157why, one step back156</div>157:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 158–159why, one step back158It will also auto-sort all your imports.159:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 160why, one step back160For 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).:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 161–165why, one step back161162### Format imports163164There is another script that formats all the imports and makes sure you don't have unused imports:165:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 166–167why, one step back166<div class="termy">167:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 168–171why, one step back168```console169$ bash scripts/format-imports.sh170```171:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 172–173why, one step back172</div>173:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 174–185why, one step back174As 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.175176## Docs177178The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.179180All the documentation is in Markdown format in the directory `./docs`.181182Many of the tutorials have blocks of code.183184In most of the cases, these blocks of code are actual complete applications that can be run as is.185⬆ Upgrade Isort to version 5.x.x (#137)Sebastián Ramírezbefore adoption89ddc35
line 186why, one step back186In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs_src/` directory.:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 187–201why, one step back187188And those Python files are included/injected in the documentation when generating the site.189190### Docs for tests191192Most of the tests actually run against the example source files in the documentation.193194This helps making sure that:195196* The documentation is up to date.197* The documentation examples can be run as is.198* Most of the features are covered by the documentation, ensured by test coverage.199200During local development, there is a script that builds the site and checks for any changes, live-reloading:201:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 202–203why, one step back202<div class="termy">203:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 204–205why, one step back204```console205$ bash scripts/docs-live.sh:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 206–210why, one step back206207<span style="color: green;">[INFO]</span> - Building documentation...208<span style="color: green;">[INFO]</span> - Cleaning site directory209<span style="color: green;">[INFO]</span> - Documentation built in 2.74 seconds210<span style="color: green;">[INFO]</span> - Serving on http://127.0.0.1:8008:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 211–212why, one step back211```212:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 213–214why, one step back213</div>214:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 215–222why, one step back215It will serve the documentation on `http://127.0.0.1:8008`.216217That way, you can edit the documentation/source files and see the changes live.218219## Tests220221There is a script that you can run locally to test all the code and generate coverage reports in HTML:222:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 223–224why, one step back223<div class="termy">224:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 225–227why, one step back225```console226$ bash scripts/test-cov-html.sh227```:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 228–229why, one step back228229</div>:sparkles: Docs for Typer CLI (#64)Sebastián Ramírezbefore adoption96731c4
lines 230–231why, one step back230231This 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.