|
| 1 | +(sec_development)= |
| 2 | + |
| 3 | +# Development |
| 4 | + |
| 5 | +Contributions to Dinf are welcome! |
| 6 | +Please make pull requests against our |
| 7 | +[git repository](https://github.com/RacimoLab/dinf). |
| 8 | + |
| 9 | +## Installation |
| 10 | + |
| 11 | +Compared with a regular installation via `pip install dinf`, |
| 12 | +additional dependencies are required during development, as |
| 13 | +developers regularly run the test suite, build the documentation, and assess |
| 14 | +whether their code changes conform to style guidelines. |
| 15 | +For developers, installation is from the git repository directly, |
| 16 | +and a virtual environment is highly recommended. The `requirements.txt` |
| 17 | +file in the top-level folder points to the developer dependencies. |
| 18 | + |
| 19 | +```sh |
| 20 | +# Clone the repository. |
| 21 | +git clone https://github.com/RacimoLab/dinf.git |
| 22 | +cd dinf |
| 23 | +# Create a virtual environment for development. |
| 24 | +python -m venv venv |
| 25 | +# Activate the environment. |
| 26 | +source venv/bin/activate |
| 27 | +pip install --upgrade pip |
| 28 | +# Install the developer dependencies. |
| 29 | +pip install -r requirements.txt |
| 30 | +``` |
| 31 | + |
| 32 | +```{note} |
| 33 | +Non-developer requirements are listed in the `install_requires` section |
| 34 | +of the ``setup.cfg`` file in the top-level folder of the sources. |
| 35 | +``` |
| 36 | + |
| 37 | +## Continuous integration (CI) |
| 38 | + |
| 39 | +After a pull request is submitted, an automated process known as |
| 40 | +*continuous integration* (CI) will: |
| 41 | + |
| 42 | + * assess if the proposed changes conform to style guidelines (known as *lint* checks), |
| 43 | + * run the test suite, |
| 44 | + * and build the documentation. |
| 45 | + |
| 46 | +The CI process uses |
| 47 | +[GitHub Actions](https://docs.github.com/en/free-pro-team@latest/actions) |
| 48 | +and the configuration files detailing how these are run can be found under the |
| 49 | +`.github/workflows/` folder of the sources. |
| 50 | + |
| 51 | +## Lint checks |
| 52 | + |
| 53 | +The following tools are run during the linting process: |
| 54 | + |
| 55 | + * [black](https://black.readthedocs.io/), a code formatter |
| 56 | + (code is only checked during CI, not reformatted), |
| 57 | + * [flake8](https://flake8.pycqa.org/), |
| 58 | + a [PEP8](https://www.python.org/dev/peps/pep-0008/) code-style checker, |
| 59 | + * [mypy](http://mypy-lang.org/), a static type checker. |
| 60 | + |
| 61 | +Each of these tools can also be run manually from the top-level folder of the |
| 62 | +sources. The `setup.cfg` file includes some project-specific configuration |
| 63 | +for each of these tools, so running them from the command line should match |
| 64 | +the behaviour of the CI checks. |
| 65 | + |
| 66 | +## Test suite |
| 67 | + |
| 68 | +A suite of tests is included in the `tests/` folder. |
| 69 | +The CI process uses the `pytest` tool to run the tests, which can also be run |
| 70 | +manually from the top-level folder of the sources. |
| 71 | + |
| 72 | +```sh |
| 73 | +python -m pytest -v tests --cov=dinf --cov-report=term-missing |
| 74 | +``` |
| 75 | + |
| 76 | +## Building the documentation |
| 77 | + |
| 78 | +The Dinf documentation is built with [jupyter-book](https://jupyter-book.org/), |
| 79 | +which uses [sphinx](https://www.sphinx-doc.org/). |
| 80 | +Much of the documentation is under the `docs/` folder, written in the |
| 81 | +[MyST](https://myst-parser.readthedocs.io/en/latest/) flavour of Markdown, |
| 82 | +and is configured in the `docs/_config.yml` file. |
| 83 | +In contrast, the API documentation is automatically generated from "docstrings" |
| 84 | +in the Python code that use the |
| 85 | +[reStructuredText](https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html) |
| 86 | +format. |
| 87 | +Finally, some documentation files are ipython notebooks that get executed and |
| 88 | +converted into markdown by jupyter-book. A couple of these notebooks take a |
| 89 | +long time to run, so they are excluded from execution in the |
| 90 | +jupyter-book configuration file and run manually as required. |
| 91 | + |
| 92 | +To build the documentation locally, run the following from the top-level folder. |
| 93 | + |
| 94 | +```sh |
| 95 | +make -C docs |
| 96 | +``` |
| 97 | + |
0 commit comments