xref: /petsc/src/binding/petsc4py/docs/source/contributing.rst (revision a982d5546cc9bcf96044945e3157033f4bde0259)
1Contributing
2============
3
4Contributions from the user community are welcome. See
5the `PETSc developers <ind_developers>` documentation for general
6information on contributions.
7
8New contributions to petsc4py **must** adhere with the coding standards.
9We use cython-lint_ for Cython and ruff_ for Python source codes.
10These can be installed using::
11
12  $ python -m pip install -r src/binding/petsc4py/conf/requirements-lint.txt
13
14If you are contributing Cython code, you can check compliance with::
15
16  $ make cython-lint -C src/binding/petsc4py
17
18For Python code, run::
19
20  $ make ruff-lint -C src/binding/petsc4py
21
22Python code can be auto-formatted using::
23
24  $ make ruff-lint RUFF_OPTS='format' -C src/binding/petsc4py
25
26New contributions to petsc4py must be tested.
27Tests are located in the :file:`src/binding/petsc4py/test` folder.
28To add a new test, either add a new :file:`test_xxx.py` or modify a
29pre-existing file according to the
30`unittest <https://docs.python.org/3/library/unittest.html>`_
31specifications.
32
33If you add a new :file:`test_xxx.py`, you can run the tests using::
34
35  $ cd src/binding/petsc4py
36  $ python test/runtests.py -k test_xxx
37
38If instead you are modifying an existing :file:`test_xxx.py`,
39you can test your additions by using the fully qualified name of the Python
40class or method you are modifying, e.g.::
41
42  $ python test/runtests.py -k test_xxx.class_name.method_name
43
44All new code must include documentation in accordance with the `documentation
45standard <documentation_standards>`. To check for compliance, run::
46
47  $ make html SPHINXOPTS='-W' -C src/binding/petsc4py/docs/source
48
49.. warning::
50
51    The docstrings must not cause Sphinx warnings.
52
53.. _cython-lint: https://github.com/MarcoGorelli/cython-lint
54.. _ruff: https://docs.astral.sh/ruff
55