|
| 1 | +# Contributing to `project_template` |
| 2 | +All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome. |
| 3 | +We recommend going through the list of [`issues`](https://github.com/pyomeca/python_project_template/issues) to find issues that interest you, preferable those tagged with `good first issue`. |
| 4 | +You can then get your development environment setup with the following instructions. |
| 5 | + |
| 6 | +## Forking `project_template` |
| 7 | + |
| 8 | +You will need your own fork to work on the code. |
| 9 | +Go to the [project_template project page](https://github.com/pyomeca/python_project_template/) and hit the `Fork` button. |
| 10 | +You will want to clone your fork to your machine: |
| 11 | + |
| 12 | +```bash |
| 13 | +git clone https://github.com/your-user-name/python_project_template.git |
| 14 | +``` |
| 15 | + |
| 16 | +## Creating and activating conda environment |
| 17 | + |
| 18 | +Before starting any development, we recommend that you create an isolated development environment. |
| 19 | +The easiest and most efficient way (due to the numerous dependencies of `project_template`) is to use an anaconda virtual environment and to create it based on the `environment.yml` file. |
| 20 | + |
| 21 | +- Install [miniconda](https://conda.io/miniconda.html) |
| 22 | +- `cd` to the `project_template` source directory |
| 23 | +- Install `project_template` dependencies with: |
| 24 | + |
| 25 | +```bash |
| 26 | +conda env create -f environment.yml |
| 27 | +conda activate project_template |
| 28 | +``` |
| 29 | + |
| 30 | +## Implementing new features |
| 31 | + |
| 32 | +Before implementing your awesome new feature, please discuss with the code owner to prevent any clashing with some other competing developments. |
| 33 | +It is also a good idea to check the current opened pull-request not to redo something currently being developed. |
| 34 | +If your feature is mentioned in the issue section of GitHub, please assign it to yourself. |
| 35 | +Otherwise, please open a new issue explaining what you are currently working on (and assign it to yourself!). |
| 36 | + |
| 37 | +As soon as possible, you are asked to open a pull-request (see below) with a short but descriptive name. |
| 38 | +Unless that pull-request is ready to be merged, please tag it as `work in progress` by adding `[WIP]` at the beginning of the pull-request name. |
| 39 | +If you are ready to get your PR reviewed, you can add the tag `ready to review` by adding `[RTR]`. |
| 40 | +If you think your PR is ready for the last review, please use the tag `ready to merge` by adding `[RTM]`. |
| 41 | +Send commits that are as small as possible; 1 to 10 lines is probably a good guess, with again short but descriptive commit names. |
| 42 | +Be aware of the review done by the maintainers, they will contain useful tips and advice that should be integrated ASAP. |
| 43 | +Once you have responded to a specific comment, please respond `Done!` and tag it as resolved. |
| 44 | + |
| 45 | +Make sure you add a minimal but meaningful example of your new feature in the `examples` folder and that you create a test with numerical values for comparison. |
| 46 | +If this feature changes the API, this should also be reflected in the ReadMe. |
| 47 | +During your development, you can create a `sandbox` folder. |
| 48 | +Everything in this folder will automatically be ignored by Git. |
| 49 | +If by accident you add a binary file in the history file (by not using a sandbox), your pull-request will be rejected and you will have to produce a new pull-request free from the binary file. |
| 50 | + |
| 51 | +When you have completed the implementation of your new feature, navigate to your pull-request in GitHub and select `Pariterre` in the `Reviewers` drop menu. |
| 52 | +At the same time, if you think your review is ready to be merged, remove the `[WIP]` tag in the name (otherwise, your pull-request won't be merged). |
| 53 | +If your pull-request is accepted, there is nothing more to do, Congrats! |
| 54 | +If changes are required, reply to all the comments and, as stated previously, respond `Done!` and tag them as resolved. |
| 55 | +Be aware that sometimes the maintainer can push modifications directly to your branch, so make sure to pull before continuing your work on that branch. |
| 56 | + |
| 57 | +## Testing your code |
| 58 | + |
| 59 | +Adding tests are required to get your development merged to the master branch. |
| 60 | +Therefore, it is very good practice to get the habit of writing tests ahead of time so this is never an issue. |
| 61 | +The `project_template` test suite runs automatically on GitHub every time a commit is submitted. |
| 62 | +However, we strongly encourage running tests locally prior to submitting the pull-request. |
| 63 | +To do so, simply run the tests folder in pytest (`pytest tests`). |
| 64 | + |
| 65 | +## Commenting |
| 66 | + |
| 67 | +Every function, class and module should have their respective proper docstrings completed. |
| 68 | +The docstring convention used is NumPy. |
| 69 | +Moreover, if your new features is available to the lay user (i.e., it changes the API), the `ReadMe.md` should be modified accordingly. |
| 70 | + |
| 71 | +## Convention of coding |
| 72 | + |
| 73 | +`project_template` tries to follow as much as possible the PEP recommendations (https://www.python.org/dev/peps/). |
| 74 | +Unless you have good reasons to disregard them, your pull-request is required to follow these recommendations. |
| 75 | +I won't get into details here, if you haven't yet, you should read them :) |
| 76 | + |
| 77 | +All variable names that could be plural should be written as such. |
| 78 | + |
| 79 | +Black is used to enforce the code spacing. |
| 80 | +`project_template` is linted with the 120-character max per line's option. |
| 81 | +This means that your pull-request tests on GitHub will appear to fail if black fails. |
| 82 | +The easiest way to make sure black is happy is to locally run this command: |
| 83 | +```bash |
| 84 | +black . -l120 |
| 85 | +``` |
| 86 | +If you need to install black, you can do it via conda using the conda-forge channel. |
| 87 | + |
0 commit comments