|
2 | 2 | Contribution Guidelines |
3 | 3 | ======================= |
4 | 4 |
|
5 | | -Contributions in code to the ``asyncstdlib`` library are highly welcome! |
| 5 | +Contributions to ``asyncstdlib`` are highly welcome! |
| 6 | +The place to go is the `asyncstdlib GitHub repository`_ |
| 7 | +where you can report bugs, request improvements or propose changes. |
6 | 8 |
|
7 | | -We describe below how you can create a pull request and have it merged in. |
| 9 | +- For bug reports and feature requests simply `open a new issue`_ |
| 10 | + and fill in the appropriate template. |
| 11 | +- Even for content submissions it is highly recommended to make sure an issue |
| 12 | + exists - this allows you to get early feedback and document the development. |
| 13 | + You can use whatever tooling you like to create the content, |
| 14 | + but the next sections give a rough outline on how to proceed. |
8 | 15 |
|
9 | | -Discuss First |
10 | | -============= |
11 | | -Before you start writing code, please create `a new issue`_ first and discuss |
12 | | -what you intend to implement. |
13 | | -It can well be that somebody else is already working on it, or that |
14 | | -the suggested interface of your code needs to be changed in order to be |
15 | | -consistent with the rest of the library *etc*. |
| 16 | +.. _asyncstdlib GitHub repository: https://github.com/maxfischer2781/asyncstdlib |
| 17 | +.. _open a new issue: https://github.com/maxfischer2781/asyncstdlib/issues/new/choose |
16 | 18 |
|
17 | | -.. _a new issue: https://github.com/maxfischer2781/asyncstdlib/issues/new |
| 19 | +Submitting Content |
| 20 | +================== |
18 | 21 |
|
19 | | -Fork |
20 | | -==== |
21 | | -We develop using `GitHub's forks`_: |
| 22 | +To submit concrete content suggestions you *must* use a `GitHub Fork and Pull Request`_. |
| 23 | +This lets you create the content at your own pace yet still receive direct feedback. |
| 24 | +Feel free to start with a *Draft Pull Request* to get feedback early. |
22 | 25 |
|
23 | | -* Create a fork of the repository to your Github account, |
24 | | -* Clone the forked repository locally, |
25 | | -* Write code in a branch of your local repository, |
26 | | -* Push the branch to the remote forked repository, and finally |
27 | | -* Create the pull request (by using Github UI on your forked repository). |
| 26 | +All content goes through mandatory automated and manual review. |
| 27 | +You can run most of the automated review yourself to get faster feedback, |
| 28 | +yet it is also fine to wait for the checks run on GitHub itself. |
| 29 | +Dependencies for automated code and documentation checking is available via |
| 30 | +the extras ``test`` and ``doc``, respectively. |
28 | 31 |
|
29 | | -Please see the page on `GitHub's forks`_ for more detailed instruction. |
| 32 | +.. note:: |
30 | 33 |
|
31 | | -Also see this page on `how to update your fork to the upstream repository`_. |
| 34 | + Ideally you develop with the repository checked out locally and a separate `Python venv`_. |
| 35 | + If you have the venv active and the current working directory is the repository root, |
| 36 | + simply run `python -m pip install -e '.[test,doc]'` to install all dependencies. |
32 | 37 |
|
33 | | -.. _GitHub's forks: https://guides.github.com/activities/forking/ |
34 | | -.. _how to update your fork to the upstream repository: https://medium.com/@topspinj/how-to-git-rebase-into-a-forked-repo-c9f05e821c8a |
| 38 | +.. _`GitHub Fork and Pull Request`: https://guides.github.com/activities/forking/ |
| 39 | +.. _`Python venv`: https://docs.python.org/3/library/venv.html |
35 | 40 |
|
36 | | -Development Environment |
37 | | -======================= |
38 | | -To set up the development environment on your computer, change to the local |
39 | | -repository and: |
40 | | - |
41 | | -* Create the virtual environment in ``venv`` directory: |
42 | | - |
43 | | - .. code-block:: |
44 | | -
|
45 | | - python -m venv venv |
46 | | -
|
47 | | -
|
48 | | -* Activate the virtual environment, on Windows: |
49 | | - |
50 | | - .. code-block:: |
51 | | -
|
52 | | - venv\Scripts\activate |
53 | | -
|
54 | | -
|
55 | | - or on Linux/Mac: |
56 | | - |
57 | | - .. code-block:: |
58 | | -
|
59 | | - . venv/bin/activate |
60 | | -
|
61 | | -* Install the test dependencies and documentation dependencies of |
62 | | - ``asyncstdlib``: |
63 | | - |
64 | | - .. code-block:: |
65 | | -
|
66 | | - pip3 install .[test,doc] |
67 | | -
|
68 | | -Write the Code |
69 | | -============== |
70 | | - |
71 | | -Now you can implement your feature. |
72 | | - |
73 | | -Make sure you also write the corresponding unit tests in the |
74 | | -``unittests/`` directory. |
75 | | - |
76 | | -Pre-commit Checks |
77 | | -================= |
78 | | -We perform the following battery of pre-commit checks: |
79 | | - |
80 | | -* Check the code style with `flake8`_: |
81 | | - |
82 | | - .. code-block:: |
83 | | -
|
84 | | - python -m flake8 |
85 | | -
|
86 | | -* Check the code formatting with `Black`_: |
87 | | - |
88 | | - .. code-block:: |
89 | | -
|
90 | | - python -m black --target-version py36 --diff --check asyncstdlib unittests |
91 | | -
|
92 | | - You can also automatically format the code with: |
93 | | - |
94 | | - .. code-block:: |
95 | | -
|
96 | | - python -m black --target-version py36 asyncstdlib unittests |
97 | | -
|
98 | | -* Run unit tests and measure the code coverage by: |
99 | | - |
100 | | - .. code-block:: |
101 | | -
|
102 | | - python -m coverage run -m pytest |
103 | | -
|
104 | | - The HTML report of the coverage can be generated by: |
105 | | - |
106 | | - .. code-block:: |
107 | | -
|
108 | | - coverage html |
109 | | -
|
110 | | - The report on coverage is stored in the ``htmlcov/`` directory. |
111 | | - |
112 | | - Make sure that your test provide a full coverage of your code. |
113 | | - |
114 | | -.. _flake8: https://flake8.pycqa.org/en/latest/ |
115 | | -.. _Black: https://github.com/psf/black |
116 | | - |
117 | | -Document |
118 | | -======== |
119 | | -Once you are finished with the implementation, do not forget to document your |
120 | | -code in the directory ``docs/source/api/``. |
121 | | - |
122 | | -We use `Sphinx`_ to render the documentation to HTML. |
123 | | - |
124 | | -.. _Sphinx: https://www.sphinx-doc.org/en/master/ |
125 | | - |
126 | | -To generate the documentation, change to ``docs/`` and execute, on Windows: |
127 | | - |
128 | | -.. code-block:: |
129 | | -
|
130 | | - make.bat html |
131 | | -
|
132 | | -or on Linux/Mac: |
133 | | - |
134 | | -.. code-block:: |
135 | | -
|
136 | | - make html |
137 | | -
|
138 | | -The documentation is available in ``docs/_build/html``. |
139 | | - |
140 | | -Commit your Changes |
141 | | -=================== |
142 | | -Make a single commit for each self-contained change. |
143 | | - |
144 | | -Write the the commit messages in `past tense`_ and starting with a lower case. |
145 | | -Please observe the maximum line length of 72 characters for the body. |
146 | | - |
147 | | -Here are a couple of examples of commit messages: |
148 | | - |
149 | | -.. code-block:: |
| 41 | +Testing Code |
| 42 | +------------ |
150 | 43 |
|
151 | | - added itertools.pairwise |
| 44 | +Code is verified locally using the tools `flake8`, `black`, `pytest` and `mypy`. |
| 45 | +If you do not have your own preferences we recommend the following order: |
152 | 46 |
|
153 | | -.. code-block:: |
| 47 | +.. code:: bash |
154 | 48 |
|
155 | | - documented itertools.pairwise |
| 49 | + python -m black asyncstdlib unittests |
| 50 | + python -m flake8 asyncstdlib unittests |
| 51 | + python -m pytest |
| 52 | + python -m mypy --pretty |
156 | 53 |
|
| 54 | +This runs tests from simplest to most advanced and should allow you quick development. |
| 55 | +Note that some additional checks are run on GitHub to check test coverage and code health. |
157 | 56 |
|
158 | | -.. _past tense: https://en.wikipedia.org/wiki/Past_tense |
| 57 | +Building Docs |
| 58 | +------------- |
159 | 59 |
|
160 | | -Push the commit to your remote fork and create the pull request (see |
161 | | -the documentation on `Github's forks`_ for more details). |
| 60 | +If you change the documentation, either directly or via significant edits to docstrings, |
| 61 | +you can build the documentation yourself to check if everything renders as expected. |
| 62 | +To do so, trigger a `Sphinx build`_ to generate a HTML version of the docs: |
162 | 63 |
|
163 | | -Please put the title of your pull request in `imperative mood`_ and first upper |
164 | | -case. |
| 64 | +.. code:: bash |
165 | 65 |
|
166 | | -.. _imperative mood: https://en.wikipedia.org/wiki/Imperative_mood |
| 66 | + sphinx-build -M html ./docs ./docs/_build |
167 | 67 |
|
168 | | -Here is an example of a title of the pull request: |
| 68 | +On success, simply open `./docs/_build/html/index.html` in your favourite browser. |
169 | 69 |
|
170 | | -.. code-block:: |
| 70 | +.. _`Sphinx build`: https://www.sphinx-doc.org/en/master/man/sphinx-build.html |
171 | 71 |
|
172 | | - Add itertools.pairwise |
| 72 | +The Review |
| 73 | +---------- |
173 | 74 |
|
174 | | -We will review your pull request as soon as possible. |
175 | | -If changes are requested, please create new commits to address the review |
176 | | -comments. |
| 75 | +Once you mark your pull request as ready for review, be prepared for one or more rounds of comments. |
| 76 | +These can range from general commentary, to code suggestions, to inquiries why a specific change was made. |
| 77 | +We strive to give actionable advice, but whenever you have trouble understanding how to proceed - |
| 78 | +please just reply with a comment of your own and ask how to proceed! |
177 | 79 |
|
178 | | -Once the pull request is approved, we will finally squash |
179 | | -the individual commits and merge it into the main branch. |
| 80 | +Once all comments are resolved and your pull request was approved, sit back and relax! |
| 81 | +We will merge your pull request in due time and include it in the next release. |
| 82 | +Thanks for contributing! |
0 commit comments