Skip to content

Commit f0f45dc

Browse files
committed
Improve contents of CONTRIBUTING.md listing all tox environments
1 parent 43c807c commit f0f45dc

File tree

1 file changed

+113
-5
lines changed

1 file changed

+113
-5
lines changed

CONTRIBUTING.md

Lines changed: 113 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,122 @@
22

33
Pull Requests are very welcome for this project!
44

5-
For bug fixes or new features, please file an issue before submitting a pull request. If the change isn't trivial, it may be best to wait for feedback. For a quicker response, contact [Will McGugan](mailto:[email protected]) directly.
5+
For bug fixes or new features, please file an issue before submitting a pull
6+
request. If the change isn't trivial, it may be best to wait for feedback.
7+
For a quicker response, contact [Will McGugan](mailto:[email protected])
8+
directly.
69

7-
## Coding Guidelines
810

9-
This project runs on Python2.7 and Python3.X. Python2.7 will be dropped at some point, but for now, please maintain compatibility.
11+
## `tox`
12+
13+
Most of the guidelines that follow can be checked with a particular
14+
[`tox`](https://pypi.org/project/tox/) environment. Having it installed will
15+
help you develop and verify your code locally without having to wait for
16+
our Continuous Integration pipeline to finish.
1017

11-
Please format new code with [black](https://github.com/ambv/black), using the default settings.
1218

1319
## Tests
1420

15-
New code should have unit tests. We strive to have near 100% coverage. Get in touch, if you need assistance with the tests.
21+
New code should have unit tests. We strive to have near 100% coverage.
22+
Get in touch, if you need assistance with the tests. You shouldn't refrain
23+
from opening a Pull Request even if all the tests were not added yet, or if
24+
not all of them are passing yet.
25+
26+
### Dependencies
27+
28+
The dependency for running the tests can be found in the `tests/requirements.txt` file.
29+
If you're using `tox`, you won't have to install them manually. Otherwise,
30+
they can be installed with `pip`:
31+
```console
32+
$ pip install -r tests/requirements.txt
33+
```
34+
35+
### Running (with `tox`)
36+
37+
Simply run in the repository folder to execute the tests for all available
38+
environments:
39+
```console
40+
$ tox
41+
```
42+
43+
Since this can take some time, you can use a single environment to run
44+
tests only once, for instance to run tests only with Python 3.9:
45+
```console
46+
$ tox -e py39
47+
```
48+
49+
### Running (without `tox`)
50+
51+
Tests are written using the standard [`unittest`](https://docs.python.org/3/library/unittest.html)
52+
framework. You should be able to run them using the standard library runner:
53+
```console
54+
$ python -m unittest discover -vv
55+
```
56+
57+
58+
## Coding Guidelines
59+
60+
This project runs on Python2.7 and Python3.X. Python2.7 will be dropped at
61+
some point, but for now, please maintain compatibility. PyFilesystem2 uses
62+
the [`six`](https://pypi.org/project/six/) library to write version-agnostic
63+
Python code.
64+
65+
### Style
66+
67+
The code (including the tests) should follow PEP8. You can check for the
68+
code style with:
69+
```console
70+
$ tox -e codestyle
71+
```
72+
73+
This will invoke [`flake8`](https://pypi.org/project/flake8/) with some common
74+
plugins such as [`flake8-comprehensions`](https://pypi.org/project/flake8-comprehensions/).
75+
76+
### Format
77+
78+
Please format new code with [black](https://github.com/ambv/black), using the
79+
default settings. You can check whether the code is well-formatted with:
80+
```console
81+
$ tox -e codeformat
82+
```
83+
84+
### Type annotations
85+
86+
The code is typechecked with [`mypy`](https://pypi.org/project/mypy/), and
87+
type annotations written as comments, to stay compatible with Python2. Run
88+
the typechecking with:
89+
```console
90+
$ tox -e typecheck
91+
```
92+
93+
94+
## Documentation
95+
96+
### Dependencies
97+
98+
The documentation is built with [Sphinx](https://pypi.org/project/Sphinx/),
99+
using the [ReadTheDocs](https://pypi.org/project/sphinx-rtd-theme/) theme.
100+
The dependencies are listed in `docs/requirements.txt` and can be installed with
101+
`pip`:
102+
```console
103+
$ pip install -r docs/requirements.txt
104+
```
105+
106+
### Building
107+
108+
Run the following command to build the HTML documentation:
109+
```console
110+
$ python setup.py build_sphinx
111+
```
112+
113+
The documentation index will be written to the `build/sphinx/html/`
114+
directory.
115+
116+
### Style
117+
118+
The API reference is written in the Python source, using docstrings in
119+
[Google format](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).
120+
The documentation style can be checked with:
121+
```console
122+
$ tox -e docstyle
123+
```

0 commit comments

Comments
 (0)