2019-01-02 11:47:36 +00:00
# Contributing to Starlette
The Starlette team happily welcomes contributions. This document will help you get ready to contribute to Starlette!
2019-01-14 11:22:43 +00:00
To submit new code to the project you'll need to:
2019-01-14 11:12:41 +00:00
2019-01-14 11:22:43 +00:00
* Fork the repo.
* Clone your fork on your local computer: `git clone https://github.com/<username>/starlette.git` .
* Install Starlette locally and run the tests: `./scripts/install` , `./scripts/test` .
* Create a branch for your work, e.g. `git checkout -b fix-some-bug` .
* Remember to include tests and documentation updates if applicable.
* Once ready, push to your remote: `git push origin fix-some-bug` .
* [Open a Pull Request][pull-request].
2019-01-02 11:47:36 +00:00
## Install
2019-01-14 11:22:43 +00:00
**Note**: These scripts are currently suited to **Linux** and **macOS** , but we would happily take pull requests to help us make them more cross-compatible.
2019-01-14 11:12:41 +00:00
Use the `install` script to install project dependencies in a virtual environment.
2019-01-02 11:47:36 +00:00
```bash
2019-01-14 11:12:41 +00:00
./scripts/install
2019-01-02 11:47:36 +00:00
```
2019-01-14 11:22:43 +00:00
To use a specific Python executable, use the `-p` option, e.g.:
2019-01-14 11:12:41 +00:00
```bash
2019-01-14 11:22:43 +00:00
./scripts/install -p python3.7
2019-01-14 11:12:41 +00:00
```
2019-01-02 11:47:36 +00:00
## Running the tests
The tests are written using [pytest] and located in the `tests/` directory.
**Note**: tests should be run before making any changes to the code in order to make sure that everything is running as expected.
We provide a stand-alone **test script** to run tests in a reliable manner. Run it with:
```bash
./scripts/test
```
2019-01-30 14:21:58 +00:00
By default, tests involving a database are excluded. To include them, set the `STARLETTE_TEST_DATABASES` environment variable. This should be a comma separated string of database URLs.
2019-01-02 11:47:36 +00:00
```bash
2019-01-30 14:21:58 +00:00
# Any of the following are valid for running the database tests...
export STARLETTE_TEST_DATABASES="postgresql://localhost/starlette"
export STARLETTE_TEST_DATABASES="mysql://localhost/starlette_test"
export STARLETTE_TEST_DATABASES="postgresql://localhost/starlette, mysql://localhost/starlette_test"
2019-01-02 11:47:36 +00:00
```
## Linting
2019-01-14 11:22:43 +00:00
We use [Black][black] as a code formatter. To run it along with a few other linting tools, we provide a stand-alone linting script:
2019-01-02 11:47:36 +00:00
```bash
./scripts/lint
```
If linting has anything to say about the code, it will format it in-place.
To keep the code style consistent, you should apply linting before committing.
## Documentation
The documentation is built with [MkDocs], a Markdown-based documentation site generator.
To run the docs site in hot-reload mode (useful when editing the docs), run `$ mkdocs serve` in the project root directory.
For your information, the docs site configuration is located in the `mkdocs.yml` file.
Please refer to the [MkDocs docs][MkDocs] for more usage information, including how to add new pages.
2019-01-14 11:12:41 +00:00
[issues]: https://github.com/encode/starlette/issues/new
2019-01-14 11:22:43 +00:00
[pull-request]: https://github.com/encode/starlette/compare
2019-01-02 11:47:36 +00:00
[pytest]: https://docs.pytest.org
[pytest-cov]: https://github.com/pytest-dev/pytest-cov
2019-01-14 11:22:43 +00:00
[black]: https://www.google.com/search?client=safari& rls=en& q=github+black& ie=UTF-8& oe=UTF-8
2019-01-02 11:47:36 +00:00
[MkDocs]: https://www.mkdocs.org