|
| 1 | +# Contributing |
| 2 | + |
| 3 | +<!-- TOC --> |
| 4 | + |
| 5 | +- [Installation and Development](#install) |
| 6 | + - [Running Tests](#tests) |
| 7 | + - [Test Coverage](#test-coverage) |
| 8 | +- [Coding Style](#codestyle) |
| 9 | +- [PR Submission](#pr) |
| 10 | +- [Documentation](#documentation) |
| 11 | + |
| 12 | +## Installation and Development<a name="install"></a> |
| 13 | + |
| 14 | +Clone from github: |
| 15 | +```bash |
| 16 | +git clone https://github.com/aced-differentiate/auto_cat.git |
| 17 | +``` |
| 18 | + |
| 19 | +Create a virtual environment; |
| 20 | +one option is to use conda, but it is not required: |
| 21 | +```bash |
| 22 | +conda create -n <env_name> python=3.9 |
| 23 | +conda activate <env_name> |
| 24 | +``` |
| 25 | + |
| 26 | +Then install requirements from within the cloned `AutoCat` directory: |
| 27 | +```bash |
| 28 | +pip install -U -r requirements.txt |
| 29 | +pip install -U -r test_requirements.txt |
| 30 | +pip install --no-deps -e . |
| 31 | +``` |
| 32 | + |
| 33 | +### Running tests<a name="tests"></a> |
| 34 | +We use [pytest](https://docs.pytest.org/en/stable/contents.html) to run tests. |
| 35 | +To run all tests: |
| 36 | +```bash |
| 37 | +pytest -svv |
| 38 | +``` |
| 39 | + |
| 40 | +### Test coverage<a name="test-coverage"></a> |
| 41 | + |
| 42 | +We use [pytest-cov](https://pytest-cov.readthedocs.io/en/latest) to check |
| 43 | +code coverage. |
| 44 | +To run all tests and output a report of the coverage of the `src` directory: |
| 45 | +```bash |
| 46 | +pytest --cov=src/ --cov-report term-missing -svv |
| 47 | +``` |
| 48 | + |
| 49 | +## Coding Style<a name="codestyle"></a> |
| 50 | + |
| 51 | +`AutoCat` follows [PEP8](https://www.python.org/dev/peps/pep-0008/), with |
| 52 | +several docstring rules relaxed. |
| 53 | +See `tox.ini` for a list of the ignored rules. |
| 54 | +Docstrings must follow the |
| 55 | +[Numpy style](https://numpydoc.readthedocs.io/en/latest/format.html). |
| 56 | + |
| 57 | +We use [flake8](https://flake8.pycqa.org/en/latest/) as a linter. |
| 58 | +To run the linter on the `src` directory: |
| 59 | +```bash |
| 60 | +flake8 src |
| 61 | +``` |
| 62 | + |
| 63 | +A pre-commit hook is available to auto-format code with |
| 64 | +[black](https://black.readthedocs.io/en/stable) (recommended): |
| 65 | + |
| 66 | +1. Make sure you are using a Python version >=3.9 |
| 67 | +2. Install black: ``$ pip install black`` |
| 68 | +3. Install pre-commit: ``$ pip install pre-commit`` |
| 69 | +4. Intall git hooks in your ``.git`` directory: ``$ pre-commit install`` |
| 70 | + |
| 71 | +Names for functions, arguments, classes, and methods should be as descriptive as possible, |
| 72 | +even if it means making them a little longer. For example, `generate_surface_structures` is |
| 73 | +a preferred function name to `gen_surfs`. |
| 74 | +All class names should adhere to [upper CamelCase](https://en.wikipedia.org/wiki/Camel_case). |
| 75 | + |
| 76 | +## PR Submission<a name="pr"></a> |
| 77 | + |
| 78 | +All PRs must be submitted to the `develop` branch (either fork or clone). |
| 79 | +Releases will be from the `master` branch. |
| 80 | + |
| 81 | +In order to be merged, a PR must be approved by one authorized user and the |
| 82 | +build must pass. |
| 83 | +A passing build requires the following: |
| 84 | +* All tests pass |
| 85 | +* The linter finds no violations of PEP8 style (not including the exceptions in `tox.ini`) |
| 86 | +* Every line of code is executed by a test (100% coverage) |
| 87 | +* Documentation has been updated or extended (as needed) and builds |
| 88 | + |
| 89 | +PR descriptions should describe the motivation and context of the code changes in the PR, |
| 90 | +both for the reviewer and also for future developers. If there's a Github issue, the PR should |
| 91 | +be linked to the issue to provide that context. |
| 92 | + |
| 93 | +## Documentation<a name="documentation"></a> |
| 94 | +`AutoCat` documentation is built using `mkdocs` via |
| 95 | +[`mkdocs-material`](https://squidfunk.github.io/mkdocs-material/) |
| 96 | +and |
| 97 | +[`mkdocstrings`](https://mkdocstrings.github.io/). |
| 98 | +All custom documentation should be written as `.md` files, appropriately placed within |
| 99 | +`docs/`, and referenced within the `mkdocs.yml` file. |
| 100 | + |
| 101 | +With `mkdocs` the docs webpage can be hosted locally with the command: |
| 102 | +```bash |
| 103 | +mkdocs serve |
| 104 | +``` |
| 105 | +which will give an `html` link that can be pasted in a web-browser. |
| 106 | + |
| 107 | +API documentation is automatically generated with `mkdocstrings` which parses the docstrings. |
| 108 | +Please ensure that all docstrings follow the Numpy style. |
0 commit comments