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 6d4bf36 point at 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}.:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 2why, one step back2:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 3why, one step back3## Developing:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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`:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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::sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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```:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 57why, one step back57To check it worked, use::sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 58why, one step back58: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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 85–86why, one step back85!!! tip86 Every time you install a new package with `pip` under that environment, activate the environment again.:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 87why, one step back87:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 88why, one step back88 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.:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 89why, one step back89:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 90why, one step back90### Flit:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 91why, one step back91:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 92why, one step back92**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.:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 93why, one step back93:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 94why, one step back94After activating the environment as described above, install `flit`::sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 95why, one step back95:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 96–97why, one step back96<div class="termy">97:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
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%:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 102why, one step back102```:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 103why, one step back103:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 104–105why, one step back104</div>105:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 106why, one step back106Now re-activate the environment to make sure you are using the `flit` you just installed (and not a global one).:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 107why, one step back107:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 108–109why, one step back108And 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:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
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:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
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.:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 143–145why, one step back143144That way, you don't have to "install" your local version to be able to test every change.145:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
lines 146–149why, one step back146### 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:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 152–153why, one step back152```console153$ bash scripts/format.sh:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
lines 154–155why, one step back154```155:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 156–157why, one step back156</div>157:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 161why, one step back161:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 162why, one step back162### Format imports:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 163why, one step back163:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 164why, one step back164There is another script that formats all the imports and makes sure you don't have unused imports::sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 165why, one step back165:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 166–167why, one step back166<div class="termy">167:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 168–170why, one step back168```console169$ bash scripts/format-imports.sh170```:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 171why, one step back171:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 172–173why, one step back172</div>173:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 174–179why, 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>.179:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
lines 180–185why, one step back180All 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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
lines 187–189why, one step back187188And those Python files are included/injected in the documentation when generating the site.189:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 190why, one step back190### Docs for tests:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
lines 191–197why, one step back191192Most 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.:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 198why, one step back198* Most of the features are covered by the documentation, ensured by test coverage.:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
lines 199–201why, one step back199200During 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:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
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: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
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:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 215why, one step back215It will serve the documentation on `http://127.0.0.1:8008`.:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
lines 216–218why, one step back216217That way, you can edit the documentation/source files and see the changes live.218:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 219why, one step back219## Tests:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 220why, one step back220:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 221why, one step back221There is a script that you can run locally to test all the code and generate coverage reports in HTML::sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 222why, one step back222:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 223–224why, one step back223<div class="termy">224:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
lines 225–226why, one step back225```console226$ bash scripts/test-cov-html.sh:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 227why, one step back227```:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d
lines 228–229why, one step back228229</div>:sparkles: Add automatic completion options by default, if click-completion is installedSebastián Ramírezbefore adoption6d4bf36
line 230why, one step back230:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411
line 231why, one step back231This 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.