contributing.md
This file
Path
docs/contributing.md
231 lines · 5.8 KiB · Markdown
Last changed by
:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
History of this fileTake it
:memo: Refactor docs with internal links #38Sebastián Ramírezbefore adoption8d6b201
line 1why, one step back1First, you might want to see the basic ways to [help Typer and get help](help-typer.md){.internal-link target=_blank}.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 2why, one step back2:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 3why, one step back3## Developing:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 4–6why, one step back45If 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.6:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 7why, one step back7### Virtual environment with `venv`:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 8why, one step back8:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 9why, one step back9You can create a virtual environment in a directory using Python's `venv` module::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 10why, one step back10:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 11–12why, one step back11<div class="termy">12:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 13–15why, one step back13```console14$ python -m venv env15```:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 16why, one step back16:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 17–18why, one step back17</div>18:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
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:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 25–26why, one step back25<div class="termy">26:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 27–28why, one step back27```console28$ source ./env/bin/activate:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 29–30why, one step back29```30:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 31–32why, one step back31</div>32:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 33why, one step back33Or in Windows' PowerShell::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 34why, one step back34:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 35–36why, one step back35<div class="termy">36:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 37–38why, one step back37```console38$ .\env\Scripts\Activate.ps1:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 39–40why, one step back39```40:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 41–42why, one step back41</div>42:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 43why, one step back43Or if you use Bash for Windows (e.g. <a href="https://gitforwindows.org/" class="external-link" target="_blank">Git Bash</a>)::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 44why, one step back44:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 45–46why, one step back45<div class="termy">46:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 47–49why, one step back47```console48$ source ./env/Scripts/activate49```:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 50why, one step back50:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 51–52why, one step back51</div>52:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 53why, one step back53To check it worked, use::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 54why, one step back54:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 55–56why, one step back55<div class="termy">56:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 57–58why, one step back57```console58$ which pip:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 59why, one step back59:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 60–61why, one step back60some/directory/typer/env/bin/pip61```:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 62why, one step back62:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 63–64why, one step back63</div>64:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 65why, one step back65If it shows the `pip` binary at `env/bin/pip` then it worked. 🎉:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 66why, one step back66:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 67why, one step back67Or in Windows PowerShell::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 68why, one step back68:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 69–70why, one step back69<div class="termy">70:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 71–72why, one step back71```console72$ Get-Command pip:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 73why, one step back73:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 74why, one step back74some/directory/typer/env/bin/pip:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 75–76why, one step back75```76:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 77–78why, one step back77</div>78:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 79–80why, one step back79!!! tip80 Every time you install a new package with `pip` under that environment, activate the environment again.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 81why, one step back81:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 82why, one step back82 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.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 83why, one step back83:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 84why, one step back84### Flit:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 85why, one step back85:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 86why, one step back86**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.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 87why, one step back87:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 88why, one step back88After activating the environment as described above, install `flit`::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 89why, one step back89:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 90–91why, one step back90<div class="termy">91:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 92–93why, one step back92```console93$ pip install flit:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 94–95why, one step back9495---> 100%:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 96why, one step back96```:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 97why, one step back97:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 98–99why, one step back98</div>99:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 100why, one step back100Now re-activate the environment to make sure you are using the `flit` you just installed (and not a global one).:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 101why, one step back101:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 102–103why, one step back102And now use `flit` to install the development dependencies:103:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 104–105why, one step back104<div class="termy">105:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 106–107why, one step back106```console107$ flit install --deps develop --symlink:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 108–109why, one step back108109---> 100%:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 110–111why, one step back110```111:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 112–125why, one step back112</div>113114If you are on Windows, use `--pth-file` instead of `--symlink`:115116<div class="termy">117118```console119$ flit install --deps develop --pth-file120121---> 100%122```123124</div>125:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 126–135why, one step back126It will install all the dependencies and your local Typer in your local environment.127128#### Using your local Typer129130If 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.131132And if you update that local Typer source code, as it is installed with `--symlink`, when you run that Python file again, it will use the fresh version of Typer you just edited.133134That way, you don't have to "install" your local version to be able to test every change.135:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 136–139why, one step back136### Format137138There is a script that you can run that will format and clean all your code:139:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 140–141why, one step back140<div class="termy">141:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 142–143why, one step back142```console143$ bash scripts/format.sh:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 144–145why, one step back144```145:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 146–147why, one step back146</div>147:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 148–149why, one step back148It will also auto-sort all your imports.149:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
line 150why, one step back150For 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).:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 151why, one step back151:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 152why, one step back152### Format imports:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 153why, one step back153:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 154why, one step back154There is another script that formats all the imports and makes sure you don't have unused imports::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 155why, one step back155:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 156–157why, one step back156<div class="termy">157:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 158–160why, one step back158```console159$ bash scripts/format-imports.sh160```:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 161why, one step back161:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 162–163why, one step back162</div>163:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 164–169why, one step back164As 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.165166## Docs167168The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.169:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 170–179why, one step back170All the documentation is in Markdown format in the directory `./docs`.171172Many of the tutorials have blocks of code.173174In most of the cases, these blocks of code are actual complete applications that can be run as is.175176In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs/src/` directory.177178And those Python files are included/injected in the documentation when generating the site.179:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 180why, one step back180### Docs for tests:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 181–187why, one step back181182Most of the tests actually run against the example source files in the documentation.183184This helps making sure that:185186* The documentation is up to date.187* The documentation examples can be run as is.:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 188why, one step back188* Most of the features are covered by the documentation, ensured by test coverage.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 189–191why, one step back189190During local development, there is a script that builds the site and checks for any changes, live-reloading:191:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 192–193why, one step back192<div class="termy">193:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 194–195why, one step back194```console195$ bash scripts/docs-live.sh:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 196–200why, one step back196197<span style="color: green;">[INFO]</span> - Building documentation...198<span style="color: green;">[INFO]</span> - Cleaning site directory199<span style="color: green;">[INFO]</span> - Documentation built in 2.74 seconds200<span style="color: green;">[INFO]</span> - Serving on http://127.0.0.1:8008:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 201–202why, one step back201```202:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 203–204why, one step back203</div>204:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 205why, one step back205It will serve the documentation on `http://127.0.0.1:8008`.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 206–208why, one step back206207That way, you can edit the documentation/source files and see the changes live.208:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 209why, one step back209## Tests:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 210why, one step back210:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 211why, one step back211There is a script that you can run locally to test all the code and generate coverage reports in HTML::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 212why, one step back212:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 213–214why, one step back213<div class="termy">214:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 215–216why, one step back215```console216$ bash scripts/test-cov-html.sh:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 217why, one step back217```:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 218–219why, one step back218219</div>:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 220why, one step back220:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 221why, one step back221This 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.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 222why, one step back222:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 223why, one step back223### Tests in your editor:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 224why, one step back224:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 225why, one step back225If you want to use the integrated tests in your editor add `./docs/src` to your `PYTHONPATH` variable.:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 226why, one step back226:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 227why, one step back227For example, in VS Code you can create a file `.env` with::memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 228why, one step back228:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 229–230why, one step back229```env230PYTHONPATH=./docs/src:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
line 231why, one step back231```