contributing.md
This file
Path
docs/contributing.md
125 lines · 3.7 KiB · Markdown
Last changed by
:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
History of this fileTake it
:memo: Add first version of docsSebastián Ramírezbefore adoptionc24269f
lines 1–125why, one step back1First, you might want to see the basic ways to <a href="https://typer.tiangolo.com/help-typer/" target="_blank">help Typer and get help</a>.23Coming soon...45<!-- ## Developing67If 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.8910### Pipenv1112If you are using <a href="https://pipenv.readthedocs.io/en/latest/" target="_blank">Pipenv</a>, you can create a virtual environment and install the packages with:1314```bash15pipenv install --dev16```1718Then you can activate that virtual environment with:1920```bash21pipenv shell22```232425### No Pipenv2627If you are not using Pipenv, you can create a virtual environment with your preferred tool, and install the packages listed in the file `Pipfile`.282930### Flit3132**FastAPI** uses <a href="https://flit.readthedocs.io/en/latest/index.html" target="_blank">Flit</a> to build, package and publish the project.3334If you installed the development dependencies with one of the methods above, you already have the `flit` command.3536To install your local version of FastAPI as a package in your local environment, run:3738```bash39flit install --symlink40```4142It will install your local FastAPI in your local environment.434445#### Using your local FastAPI4647If you create a Python file that imports and uses FastAPI, and run it with the Python from your local environment, it will use your local FastAPI source code.4849And if you update that local FastAPI source code, as it is installed with `--symlink`, when you run that Python file again, it will use the fresh version of FastAPI you just edited.5051That way, you don't have to "install" your local version to be able to test every change.525354### Format5556There is a script that you can run that will format and clean all your code:5758```bash59bash scripts/lint.sh60```6162It will also auto-sort all your imports.6364For it to sort them correctly, you need to have FastAPI installed locally in your environment, with the command in the section above:6566```bash67flit install --symlink68```697071### Docs7273The documentation uses <a href="https://www.mkdocs.org/" target="_blank">MkDocs</a>.7475All the documentation is in Markdown format in the directory `./docs`.7677Many of the tutorials have blocks of code.7879In most of the cases, these blocks of code are actual complete applications that can be run as is.8081In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs/src/` directory.8283And those Python files are included/injected in the documentation when generating the site.848586#### Docs for tests8788Most of the tests actually run against the example source files in the documentation.8990This helps making sure that:9192* The documentation is up to date.93* The documentation examples can be run as is.94* Most of the features are covered by the documentation, ensured by the coverage tests.9596During local development, there is a script that builds the site and checks for any changes, live-reloading:9798```bash99bash scripts/docs-live.sh100```101102It will serve the documentation on `http://0.0.0.0:8008`.103104That way, you can edit the documentation/source files and see the changes live.105106#### Apps and docs at the same time107108And if you run the examples with, e.g.:109110```bash111uvicorn tutorial001:app --reload112```113114as Uvicorn by default will use the port `8000`, the documentation on port `8008` won't clash.115116117### Tests118119There is a script that you can run locally to test all the code and generate coverage reports in HTML:120121```bash122bash scripts/test-cov-html.sh123```124125This 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. -->