Skip to content

Commit a226fc1

Browse files
committed
Update and convert contribution guidelines to md
1 parent 938693a commit a226fc1

File tree

3 files changed

+87
-100
lines changed

3 files changed

+87
-100
lines changed

CONTRIBUTING.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Contributing to pslab-python
2+
3+
Before opening a pull request, make sure that:
4+
5+
1. The code builds.
6+
2. The docs build.
7+
3. The linters pass.
8+
4. The tests pass.
9+
5. Test coverage has not decreased.
10+
11+
## Building & Installing
12+
13+
The following assumes that the commands are executed from the root of the repository:
14+
15+
The project can be built with:
16+
17+
pip install wheel
18+
python setup.py sdist bdist_wheel
19+
20+
The project can be installed in editable mode with:
21+
22+
pip install -e .
23+
24+
The documentation can be built with:
25+
26+
tox -e docs
27+
28+
The linters can be run with:
29+
30+
tox -e lint
31+
32+
## Testing
33+
34+
pslab-python tests are written to run against real hardware. The tests are integration tests, since they depend on the correct function of not just the Python code under test, but also the firmware and hardware of the connected PSLab device. The tests can be run with:
35+
36+
tox -e integration
37+
38+
When running the tests, the serial traffic to and from the PSLab can optionally be recorded by running:
39+
40+
tox -e record
41+
42+
The recorded traffic is played back when running the tests on Travis, since no real device is connected in that situation. The tests can be run with recorded traffic instead of against real hardware by running:
43+
44+
tox -e playback
45+
46+
### Writing new tests
47+
48+
Tests are written in pytest.
49+
50+
If the test requires multiple PSLab instruments to be connected together, this should be documented in the module docstring.
51+
52+
Test coverage should be \>90%, but aim for 100%.
53+
54+
## Code style
55+
56+
### General
57+
58+
- Black.
59+
- When in doubt, refer to PEP8.
60+
- Use type hints (PEP484).
61+
- Maximum line length is 88 characters, but aim for less than 80.
62+
- Maximum [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) is ten, but aim for five or lower.
63+
- Blank lines before and after statements (for, if, return, \...), unless
64+
- the statement comes at the beginning or end of another statement.
65+
- the indentation level is five lines or fewer long.
66+
67+
### Imports
68+
69+
- All imports at the top of the module.
70+
- Built-in imports come first, then third-party, and finally pslab, with a blank line between each group of imports.
71+
- No relative imports.
72+
- Within import groups, `import`-style imports come before `from`-style imports.
73+
- One `import`-style import per line.
74+
- All `from`-style imports from a specific package or module on the same line, unless that would violate the line length limit.
75+
- In that case, strongly consider using `import`-style instead.
76+
- If that is not possible, use one import per line.
77+
- Imports are sorted alphabetically within groups.
78+
79+
### Comments and docstrings
80+
81+
- All public interfaces (modules, classes, methods) have Numpydoc-style docstrings.
82+
- Blank line after module- and class-level docstrings, but not after method-level docstrings.
83+
- Comments start with a capital letter and end with a period if they contain at least two words.
84+
- Comments go on the same line as the code they explain, unless that would violate the line length limit.
85+
- In that case, the comment goes immediately before the code it explains.
86+
- Avoid multiline comments.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Wherever we interact, we strive to follow the [FOSSASIA Code of Conduct](https:/
5151

5252
## Contributing
5353

54-
See [doc/development.rst](https://github.com/fossasia/pslab-python/blob/development/docs/development.rst) to get started.
54+
See [CONTRIBUTING.md](https://github.com/fossasia/pslab-python/blob/development/CONTRIBUTING.md) to get started.
5555

5656
## License
5757

docs/development.rst

-99
This file was deleted.

0 commit comments

Comments
 (0)