| 1 | # Contributing |
| 2 | |
| 3 | Django Ninja uses Flit to build, package and publish the project. |
| 4 | |
| 5 | to install it use: |
| 6 | |
| 7 | ``` |
| 8 | pip install flit |
| 9 | ``` |
| 10 | |
| 11 | Once you have it - to install all dependencies required for development and testing use this command: |
| 12 | |
| 13 | |
| 14 | ``` |
| 15 | flit install --deps develop --symlink |
| 16 | ``` |
| 17 | |
| 18 | Once done you can check if all works with |
| 19 | |
| 20 | ``` |
| 21 | pytest . |
| 22 | ``` |
| 23 | |
| 24 | or using Makefile: |
| 25 | |
| 26 | ``` |
| 27 | make test |
| 28 | ``` |
| 29 | |
| 30 | Now you are ready to make your contribution |
| 31 | |
| 32 | |
| 33 | When you're done please make sure you to test your functionality |
| 34 | and check the coverage of your contribution. |
| 35 | |
| 36 | ``` |
| 37 | pytest --cov=ninja --cov-report term-missing tests |
| 38 | ``` |
| 39 | |
| 40 | or using Makefile: |
| 41 | |
| 42 | ``` |
| 43 | make test-cov |
| 44 | ``` |
| 45 | |
| 46 | ## Code style |
| 47 | |
| 48 | Django Ninja uses `ruff`, and `mypy` for style checks. |
| 49 | |
| 50 | Run `pre-commit install` to create a git hook to fix your styles before you commit. |
| 51 | |
| 52 | Alternatively, manually check your code with: |
| 53 | |
| 54 | ``` |
| 55 | ruff format --check ninja tests |
| 56 | ruff check ninja tests |
| 57 | mypy ninja |
| 58 | ``` |
| 59 | |
| 60 | or using Makefile: |
| 61 | |
| 62 | ``` |
| 63 | make lint |
| 64 | ``` |
| 65 | |
| 66 | Or reformat your code with: |
| 67 | |
| 68 | ``` |
| 69 | ruff format ninja tests |
| 70 | ruff check ninja tests --fix |
| 71 | ``` |
| 72 | |
| 73 | or using Makefile: |
| 74 | |
| 75 | ``` |
| 76 | make fmt |
| 77 | ``` |
| 78 | |
| 79 | ## Docs |
| 80 | Please do not forget to document your contribution |
| 81 | |
| 82 | Django Ninja uses `mkdocs`: |
| 83 | |
| 84 | ``` |
| 85 | cd docs/ |
| 86 | mkdocs serve |
| 87 | ``` |
| 88 | and go to browser to see changes in real time |
| 89 |