|
| 1 | +--- |
| 2 | +icon: material/code-block-tags |
| 3 | +title: Contribution guide |
| 4 | +tags: |
| 5 | + - contribution |
| 6 | + - development |
| 7 | +--- |
| 8 | + |
| 9 | +First off, thanks for considering to contribute to this project! |
| 10 | + |
| 11 | +These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request. |
| 12 | + |
| 13 | +## Development |
| 14 | + |
| 15 | +Clone the repository: |
| 16 | + |
| 17 | +```sh |
| 18 | +# install development dependencies |
| 19 | +python -m pip install -U -r requirements/development.txt |
| 20 | +# alternatively: pip install -e .[dev] |
| 21 | + |
| 22 | +# install project as editable |
| 23 | +python -m pip install -e . |
| 24 | + |
| 25 | +# install git hooks |
| 26 | +pre-commit install |
| 27 | +``` |
| 28 | + |
| 29 | +Then follow the [contribution guidelines](#guidelines). |
| 30 | + |
| 31 | +### Run the tests |
| 32 | + |
| 33 | +```sh |
| 34 | +# install development dependencies |
| 35 | +python -m pip install -U -r requirements/testing.txt |
| 36 | +# alternatively: pip install -e .[test] |
| 37 | + |
| 38 | +# run tests |
| 39 | +pytest |
| 40 | +``` |
| 41 | + |
| 42 | +### Build the documentation |
| 43 | + |
| 44 | +```sh |
| 45 | +# install dependencies for documentation |
| 46 | +python -m pip install -U -r requirements/documentation.txt |
| 47 | +# alternatively: pip install -e .[doc] |
| 48 | + |
| 49 | +# build the documentation |
| 50 | +mkdocs build |
| 51 | +``` |
| 52 | + |
| 53 | +### Release workflow |
| 54 | + |
| 55 | +1. Fill the `CHANGELOG.md` |
| 56 | +1. Change the version number in `__about__.py` |
| 57 | +1. Apply a git tag with the relevant version: `git tag -a 0.3.0 {git commit hash} -m "New awesome feature"` |
| 58 | +1. Push tag to main branch: `git push origin 0.3.0` |
| 59 | + |
| 60 | +---- |
| 61 | + |
| 62 | +## Guidelines |
| 63 | + |
| 64 | +### Git hooks |
| 65 | + |
| 66 | +We use git hooks through [pre-commit](https://pre-commit.com/) to enforce and automatically check some "rules". Please install it before to push any commit. |
| 67 | + |
| 68 | +See the relevant configuration file: `.pre-commit-config.yaml`. |
| 69 | + |
| 70 | +### Code Style |
| 71 | + |
| 72 | +Make sure your code *roughly* follows [PEP-8](https://www.python.org/dev/peps/pep-0008/) and keeps things consistent with the rest of the code: |
| 73 | + |
| 74 | +- docstrings: [sphinx-style](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html#the-sphinx-docstring-format) is used to write technical documentation. |
| 75 | +- formatting: [black](https://black.readthedocs.io/) is used to automatically format the code without debate. |
| 76 | +- sorted imports: [isort](https://pycqa.github.io/isort/) is used to sort imports |
| 77 | +- static analysis: [flake8](https://flake8.pycqa.org/en/latest/) is used to catch some dizziness and keep the source code healthy. |
| 78 | + |
| 79 | +### Pulls requests |
| 80 | + |
| 81 | +Pull requests are really welcome since you take the time to push or modify tests related to the code you edit or create. |
| 82 | + |
| 83 | +---- |
| 84 | + |
| 85 | +## IDE proposed settings |
| 86 | + |
| 87 | +Feel free to use the IDE you love. Here come configurations for some popular IDEs to fit those guidelines. |
| 88 | + |
| 89 | +### Visual Studio Code |
| 90 | + |
| 91 | +```jsonc |
| 92 | +{ |
| 93 | + // Editor |
| 94 | + "files.associations": { |
| 95 | + "./requirements/*.txt": "pip-requirements" |
| 96 | + }, |
| 97 | + // Python |
| 98 | + "[python]": { |
| 99 | + "editor.codeActionsOnSave": { |
| 100 | + "source.organizeImports": true |
| 101 | + }, |
| 102 | + "editor.defaultFormatter": "ms-python.black-formatter", |
| 103 | + "editor.formatOnSave": true, |
| 104 | + "editor.guides.bracketPairs": "active", |
| 105 | + "editor.rulers": [ |
| 106 | + 88 |
| 107 | + ], |
| 108 | + "editor.wordWrapColumn": 88, |
| 109 | + }, |
| 110 | + "flake8.args": [ |
| 111 | + "--config=setup.cfg", |
| 112 | + "--verbose" |
| 113 | + ], |
| 114 | + "isort.args": [ |
| 115 | + "--profile", |
| 116 | + "black" |
| 117 | + ], |
| 118 | + "isort.check": true, |
| 119 | + // extensions |
| 120 | + "autoDocstring.guessTypes": true, |
| 121 | + "autoDocstring.docstringFormat": "google", |
| 122 | + "autoDocstring.generateDocstringOnEnter": false, |
| 123 | +} |
| 124 | +``` |
0 commit comments