Skip to content
Myr

📝 Update contributing docs, reference central docs (#1777)

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 4810173 · Browse files · 1 file+1 added−190 removed
This commit

State

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

Diff stats

1 file+1 added−190 removed

  • other:+1 added−190 removed

1 file+1 added−190 removed

modified:docs/contributing.md+1 added-190 removed
2 unmodified lines
3First, you might want to see the basic ways to [help Typer and get help](help-typer.md).45## Developing67If you already cloned the [typer repository](https://github.com/fastapi/typer) and you want to deep dive in the code, here are some guidelines to set up your environment.7To contribute code to the project, please follow the guidelines in [tiangolo.com - Contributing](https://tiangolo.com/open-source/contributing/).89### Install Requirements Using `uv`1011Create a virtual environment and install the required packages in one command:1213<div class="termy">1415```console16$ uv sync1718---> 100%19```2021</div>2223It will install all the dependencies and your local Typer in your local environment.2425### Using your Local Typer2627If you create a Python file that imports and uses Typer, and run it with the Python from your local environment, it will use your cloned local Typer source code.2829And if you update that local Typer source code when you run that Python file again, it will use the fresh version of Typer you just edited.3031That way, you don't have to "install" your local version to be able to test every change.3233/// note | "Technical Details"3435This only happens when you install using this included `requirements.txt` instead of running `pip install typer` directly.3637That is because inside the `requirements.txt` file, the local version of Typer is marked to be installed in "editable" mode, with the `-e` option.3839///4041### Format4243There is a script that you can run that will format and clean all your code:4445<div class="termy">4647```console48$ bash scripts/format.sh49```5051</div>5253It will also auto-sort all your imports.5455## Tests5657There is a script that you can run locally to test all the code and generate coverage reports in HTML:5859<div class="termy">6061```console62$ bash scripts/test-cov-html.sh63```6465</div>6667This 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.689## Completion1011To try and test the completion for different shells and check that they are working you can use a Docker container.12
132 unmodified lines
145146If you exit from the container, you can start a new one, you will probably have to install the packages again and install completion again.147148Using this process, you can test all the shells, with their completions, being able to start from scratch quickly in a fresh container, and verifying that everything works as expected.209210## Docs211212First, make sure you set up your environment as described above, that will install all the requirements.213214### Docs live215216During local development, there is a script that builds the site and checks for any changes, live-reloading:217218<div class="termy">219220```console221$ python ./scripts/docs.py live222223<span style="color: green;">[INFO]</span> Serving on http://127.0.0.1:8008224<span style="color: green;">[INFO]</span> Start watching changes225<span style="color: green;">[INFO]</span> Start detecting changes226```227228</div>229230It will serve the documentation on `http://127.0.0.1:8008`.231232That way, you can edit the documentation/source files and see the changes live.233234/// tip235236Alternatively, you can perform the same steps that script does manually.237238Go into the docs directory at `docs/`:239240```console241$ cd docs/242```243244Then run `zensical` in that directory:245246```console247$ zensical serve --dev-addr 8008248```249250///251252#### Typer CLI (optional)253254The instructions here show you how to use the script at `./scripts/docs.py` with the `python` program directly.255256But you can also use [Typer CLI](https://typer.tiangolo.com/typer-cli/), and you will get autocompletion in your terminal for the commands after installing completion.257258If you install Typer CLI, you can install completion with:259260<div class="termy">261262```console263$ typer --install-completion264265zsh completion installed in /home/user/.bashrc.266Completion will take effect once you restart the terminal.267```268269</div>270271### Docs Structure272273The documentation uses [Zensical](https://zensical.org).274275And there are extra tools/scripts in place in `./scripts/docs.py`.276277/// tip278279You don't need to see the code in `./scripts/docs.py`, you just use it in the command line.280281///282283All the documentation is in Markdown format in the directory `./docs`.284285Many of the tutorials have blocks of code.286287In most of the cases, these blocks of code are actual complete applications that can be run as is.288289In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs_src/` directory.290291And those Python files are included/injected in the documentation when generating the site.292293### Docs for Tests294295Most of the tests actually run against the example source files in the documentation.296297This helps to make sure that:298299* The documentation is up-to-date.300* The documentation examples can be run as is.301* Most of the features are covered by the documentation, ensured by test coverage.302303## Automated Code and AI304305You are encouraged to use all the tools you want to do your work and contribute as efficiently as possible, this includes AI (LLM) tools, etc. Nevertheless, contributions should have meaningful human intervention, judgement, context, etc.306307If the **human effort** put in a PR, e.g. writing LLM prompts, is **less** than the **effort we would need to put** to **review it**, please **don't** submit the PR.308309Think of it this way: we can already write LLM prompts or run automated tools ourselves, and that would be faster than reviewing external PRs.310311### Closing Automated and AI PRs312313If we see PRs that seem AI generated or automated in similar ways, we'll flag them and close them.314315The same applies to comments and descriptions, please don't copy paste the content generated by an LLM.316317### Human Effort Denial of Service318319Using automated tools and AI to submit PRs or comments that we have to carefully review and handle would be the equivalent of a [Denial-of-service attack](https://en.wikipedia.org/wiki/Denial-of-service_attack) on our human effort.320321It would be very little effort from the person submitting the PR (an LLM prompt) that generates a large amount of effort on our side (carefully reviewing code).322323Please don't do that.324325We'll need to block accounts that spam us with repeated automated PRs or comments.326327### Use Tools Wisely328329As Uncle Ben said:330331<blockquote>332With great <strike>power</strike> <strong>tools</strong> comes great responsibility.333</blockquote>334335Avoid inadvertently doing harm.336337You have amazing tools at hand, use them wisely to help effectively.