Debian Codegraph @

docs/source/contrib.rst

raw
1 Contribute
2 ==========
3
4
5 What can you do
6 ---------------
7
8 If you like the project and think you could help with making it better, there are many ways you can do it:
9
10 - Create a new issue for new feature proposal or a bug
11 - Triage old issues that needs a refresh
12 - Implement existing issues (there are quite some of them, choose whatever you like)
13 - Help with improving the documentation (We still have work to do!)
14 - Spread a word about the project to your colleagues, friends, blogs or any other channels
15 - Any other things you could imagine
16
17 Any contribution would be of great help and I will highly appreciate it! If you have any questions, please create a new issue.
18
19
20 Development process
21 -------------------
22
23 Create a fork of the git repository and checkout a new branch from ``master`` branch.
24 The branch name may start with an associated issue number so that we can easily
25 cross-reference them. For example, use ``1234-some-brach-name`` as the name of the branch working to fix issue ``1234``.
26 Once you're ready to run a full batterie of tests to your changes, open a pull request.
27
28 Don't forget to sync your fork once in while to work from the latest revision.
29
30 Pre-commit checks
31 -----------------
32
33 Make sure all the unit tests pass and the code pass the coding standard checks.
34
35 We use `tox <https://tox.wiki/en/stable/>`_ for running our checks, but you can roughly do the same thing from your python environment.
36
37 .. list-table:: Pre-commit checks
38 :widths: 10 45 45
39 :header-rows: 1
40
41 * - \
42 - Using `tox`
43 - Using your environment
44 * - Run unit tests
45 - ``tox -e test``
46 - ``pip install '.[test]' && pytest pydoctor``
47 * - Run pyflakes
48 - ``tox -e pyflakes``
49 - ``pip install pyflakes && find pydoctor/ -name \*.py ! -path '*/testpackages/*' ! -path '*/sre_parse36.py' ! -path '*/sre_constants36.py' | xargs pyflakes``
50 * - Run mypy
51 - ``tox -e mypy``
52 - ``pip install '.[mypy]' && mypy pydoctor``
53 * - Run pydoctor on it's own source
54 - ``tox -e apidocs``
55 - ``pip install . && pydoctor --privacy "HIDDEN:pydoctor.test" -q -W pydoctor``
56
57 These should be the minimum check to run on your local system.
58 A pull request will trigger more tests and most probably there is a tox
59 environment dedicated to that extra test.
60
61 Other things hapenning when a PR is open
62 ----------------------------------------
63
64 - System tests: these tests checks if pydoctor can generate the documentation for a few
65 specific packages that have been considered as problematic in the past.
66 - Pydoctor primer: this is to pydoctor what ``mypy_primer`` is to ``mypy``.
67 It runs pydoctor on a corpus of open source code and compares the output of the application before and after a modification in the code.
68 Then it reports in comments the result for a PR. The source code of this tool is here: https://github.com/twisted/pydoctor_primer.
69 - Readthedocs build: For every PR, the sphinx documentation is built and available at ``https://pydoctor--{pr-number}.org.readthedocs.build/en/``.
70
71 Review process and requirements
72 -------------------------------
73
74 - Code changes and code added should have tests: untested code is buggy code. Except special cases, overall test coverage should be increased.
75 - If your pull request is a work in progress, please mark it as draft such that reviewers do not loose time on a PR that is not ready yet.
76 - There is no strict coding style standard. Since pydoctor is more than 20 years old and we have vendored some code from
77 other packages as well (namely epydoc and sre_parse), so we can’t really enforce the same style everywhere. It's up to the reviewers
78 to request refactors when the code is too ugly.
79 - All code changes must be reviewed by at least one person who is not an author of the code being added.
80 This helps prevent bugs from slipping through the net and gives another source for improvements.
81 If the author of the PR is one of the core developers of pydoctor* and no one has reviewed their PR after 9 calendar days, they can review the code changes themselves and proceed with next steps.
82 - When one is done with the review, always say what the next step should be: for example, if the author is a core developer, can they merge the PR after making a few minor fixes?
83 If your review feedback is more substantial, should they ask for another review?
84
85
86 \* A core developer is anyone with a write access to the repository that have an intimate knowledge of pydoctor internals, or,
87 alternatively the specific aspect in which they are contributing to (i.e. Sphinx docs, setup, pytest, etc.).
88
89 Read more about reviewing:
90
91 - `How to be a good reviewer <https://twistedmatrix.com/trac/wiki/ReviewProcess#Howtobeagoodreviewer>`_.
92 - `Leave well enough alone <https://mail.python.org/archives/list/[email protected]/thread/53LZTRNRYLZJ4QLEF3YPAE53CWSL6LXD/>`_.
93
94 Releasing and publishing a new package
95 --------------------------------------
96
97 Publishing to PyPI is done via a GitHub Actions workflow.
98 The publish to PyPI is triggered when a tag is pushed.
99 Version is configured in the ``setup.cfg``.
100
101 The `pydoctor PyPI project <https://pypi.org/manage/project/pydoctor/settings/publishing>`_ is configured to accept trusted publishing via GitHub actions from the `unit.yaml` workflow.
102
103 If the release is done from another workflow file, the PyPI project management page needs to be updated.
104
105 The following process ensures correct version management:
106
107 - Create a branch: name it by the name of the new major ``pydoctor`` version, i.e. ``21.9.x``, re-use that same branch for bug-fixes.
108 - On the branch, update the version and release notes.
109 - Update the HTML templates version (meta tag ``pydoctor-template-version``) when there is a change from a version to another.
110 For instance, check the diff of the HTML templates since version ``21.9.1`` with the following git command::
111
112 git diff 21.9.1 pydoctor/themes/*/*.html
113
114 .. note:: The HTML template version can also be updated in the PR in which the actual HTML template change is done.
115 - Create a PR for that branch, wait for tests to pass and get an approval.
116 - Create a tag based on the ``HEAD`` of the release branch, name it by the full version number of the ``pydoctor`` version, i.e. ``21.9.1``, this will trigger the release. For instance::
117
118 git tag 21.9.1
119 git push --tags
120
121 - Update the version on the branch and append ``.dev0`` to the current version number. In this way, stable versions only exist for a brief period of time (if someone tries to do a ``pip install`` from the git source, they will get a ``.dev0`` version instead of a misleading stable version number.
122 - Update the README file and add an empty placeholder for unreleased changes.
123 - Merge the branch
124
125 Updating pydoctor for Linux distributions
126 -----------------------------------------
127
128 The information below covers Debian and its derivative distributions.
129 The same principles should be applied for Fedora, Arch, Alpine or any other
130 Linux distribution.
131
132 There shouldn't be any additional steps needed to get pydoctor updated in
133 Debian (and its downstream distributions like Ubuntu).
134 As pydoctor is a Python based package the `Debian Python Team
135 <https://wiki.debian.org/Teams/PythonTeam>`_ is usually taking care about
136 updating pydoctor in Debian. The DPT is available through the team mailing
137 list (``Debian Python List <[email protected]>``) there everyone
138 can get in contact by email. If you just want to ask something quickly please
139 use this option.
140
141 Debian uses a separate, non GitHub, BTS (Bug Tracking System) to keep track
142 of issues. The package maintainers like to use this system in case of more
143 specific requests or problems. The preferred and suggested way to open up
144 new issues within the Debian BTS is to use the tool `reportbug
145 <https://wiki.debian.org/reportbug>`_ that will do some additional magic
146 while collecting the data for the bug report like collecting installed
147 packages and there versions. ``reportbug`` should be used if you are working
148 on a Debian based system.
149
150 But you can also use any email client to open up bug reports on the Debian
151 BTS by simply writing an email to the address ``[email protected]``.
152
153 If you want to help to keep the pydoctor package up to date in Debian the
154 DPT is happy to take your help! Helping out can be done in various ways.
155
156 * Keep an eye on `reported issues <https://bugs.debian.org/cgi-bin/pkgreport.cgi?repeatmerged=yes&src=pydoctor>`_
157 for the pydoctor package and forward them upstream if needed.
158 * Have also a look at cross connected packages and possible build issues
159 there regarding the build dependency onpydoctor. These packages are mostly
160 `twisted <https://tracker.debian.org/pkg/twisted>`_ or
161 `git-buildpackage <https://tracker.debian.org/pkg/git-buildpackage>`_.
162 * Ideally taking over some maintainer responsibilities for pydoctor in Debian.
163
164 pydoctor and new depending packages
165 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
166
167 It might happen that pydoctor is requiring new additional Python libraries
168 due to new wanted features or to enhance the internal test suite.
169
170 Such new packages shouldn't get vendored. They need to be packaged in
171 Debian. Best is to get in contact with the DPT to talk about about new
172 requirements and the best way to get things done.
173
174 Profiling pydoctor with austin and speedscope
175 ---------------------------------------------
176
177 1. Install austin (https://github.com/P403n1x87/austin)
178 2. Install austin-python (https://pypi.org/project/austin-python/)
179 3. Run program under austin
180
181 .. code::
182
183 $ sudo austin -i 1ms -C -o pydoctor.austin pydoctor <pydoctor args>
184
185 4. Convert .austin to .speedscope (austin2speedscope comes from austin-python)
186
187 .. code::
188
189 $ austin2speedscope pydoctor.austin pydoctor.speedscope
190
191
192 5. Open https://speedscope.app and load pydoctor.speedscope into it.
193
194 Note on sampling interval
195 ~~~~~~~~~~~~~~~~~~~~~~~~~
196
197 On our large repo I turn down the sampling interval from 100us to 1ms to make
198 the resulting ``.speedscope`` file a manageable size (15MB instead of 158MB which is too large to put into a gist.)
199
200 Author Design Notes
201 -------------------
202
203 I guess I've always been interested in more-or-less static analysis of
204 Python code and have over time developed some fairly strong opinions
205 on the Right Way\ |trade| to do it.
206
207 The first of these is that pydoctor works on an entire *system* of
208 packages and modules, not just a ``.py`` file at a time.
209
210 The second, and this only struck me with full force as I have written
211 pydoctor, is that it's much the best approach to proceed
212 incrementally, and outside-in. First, you scan the directory
213 structure to and compute the package/module structure, then parse each
214 module, then do some analysis on what you've found, then generate
215 html.
216
217 Finally, pydoctor should never crash, no matter what code you feed it
218 (this seems a basic idea for a documentation generator, but it's not
219 that universally applied, it seems). Missing information is OK,
220 crashing out is not. This probably isn't as true as it should be at
221 the moment.