Debian Codegraph @

docs/development.rst

raw
1 Developers Guide
2 ================
3
4 Project links
5 -------------
6
7 :PyPI page:
8 https://pypi.org/project/bpack
9 :repository:
10 https://github.com/avalentino/bpack
11 :issue tracker:
12 https://github.com/avalentino/bpack/issues
13 :CI:
14 https://github.com/avalentino/bpack/actions
15 :HTML documentation:
16 https://bpack.readthedocs.io
17
18
19 Set-up the development environment
20 ----------------------------------
21
22 Pip based environment
23 ~~~~~~~~~~~~~~~~~~~~~
24
25 .. code-block:: shell
26
27 $ python3 -m venv --prompt venv .venv
28 $ source .venv/bin/activate
29 (venv) $ python3 -m pip install -r requirements-dev-txt
30
31
32 Conda based environment
33 ~~~~~~~~~~~~~~~~~~~~~~~
34
35 .. code-block:: shell
36
37 $ conda create -c conda-forge -n bpack \
38 --file requirements-dev.txt python=3
39
40
41 Debian/Ubuntu
42 ~~~~~~~~~~~~~
43
44 .. code-block:: shell
45
46 $ sudo apt install python3-bitstruct python3-bitarray \
47 python3-pytest python3-pytest-cov \
48 python3-sphinx python3-sphinx-rtd-theme
49
50
51 Testing the code
52 ----------------
53
54 Basic testing
55 ~~~~~~~~~~~~~
56
57 .. code-block:: shell
58
59 $ python3 -m pytest
60
61 It is also recommended to use the ``-W=error`` option.
62
63
64 Advanced testing
65 ~~~~~~~~~~~~~~~~
66
67 Tox_ (>4) is used to run a comprehensive test suite on multiple Python version.
68 It also checks formatting, coverage and ensures that the documentation builds
69 properly.
70
71 .. code-block:: shell
72
73 $ tox run
74
75
76 Test coverage
77 -------------
78
79 .. code-block:: shell
80
81 $ python3 -m pytest --cov --cov-report=html --cov-report=term bpack
82
83
84 Check code style and formatting
85 -------------------------------
86
87 The code style and formatting shall be checked with flake8_ as follows:
88
89 .. code-block:: shell
90
91 $ python3 -m flake8 --statistics --count bpack
92
93 Moreover, also the correct formatting of "docstrings" shall be checked, using
94 pydocstyle_ this time:
95
96 .. code-block:: shell
97
98 $ python3 -m pydocstyle --count bpack
99
100 A more strict check of formatting can be done using black_:
101
102 .. code-block:: shell
103
104 $ python3 -m black --check bpack
105
106 Finally the ordering of imports can be checked with isort_ as follows:
107
108 .. code-block:: shell
109
110 $ python3 -m isort --check bpack
111
112 Please note that all the relevant configuration for the above mentioned
113 tools are in the `pyproject.toml` file.
114
115
116 Build the documentation
117 -----------------------
118
119 .. code-block:: shell
120
121 $ make -C docs html
122
123
124 Test code snippets in the documentation
125 ---------------------------------------
126
127 .. code-block:: shell
128
129 $ make -C docs doctest
130
131
132 Check documentation links
133 -------------------------
134
135 .. code-block:: shell
136
137 $ make -C docs linkcheck
138
139
140 Check documentation spelling
141 ----------------------------
142
143 .. code-block:: shell
144
145 $ make -C docs spelling
146
147
148 Update the API documentation
149 ----------------------------
150
151 .. code-block:: shell
152
153 $ rm -rf docs/api
154 $ sphinx-apidoc --module-first --separate --no-toc \
155 --doc-project "bpack API" -o docs/api \
156 --templatedir docs/_templates/apidoc \
157 bpack bpack/tests
158
159
160 .. _Tox: https://tox.readthedocs.io
161 .. _Python: https://www.python.org
162 .. _flake8: https://flake8.pycqa.org
163 .. _pydocstyle: http://www.pydocstyle.org
164 .. _black: https://black.readthedocs.io
165 .. _isort: https://pycqa.github.io/isort