Skip to content

Commit 61eb2d4

Browse files
restructure the contributing guide (#7681)
* Communication Channels added * enhanced the commit * Writing ReST pages * removed the text related to a broken link * changes_minute * Upto bug report * how to contribute * pre-commit hooks * minute_changes * development workflow * updated development workflow * minute_change * done until development workflow * Writing ReST pages * PR template added
1 parent c9c1c6d commit 61eb2d4

File tree

1 file changed

+211
-54
lines changed

1 file changed

+211
-54
lines changed

doc/contributing.rst

+211-54
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,67 @@
44
Contributing to xarray
55
**********************
66

7-
87
.. note::
98

109
Large parts of this document came from the `Pandas Contributing
1110
Guide <http://pandas.pydata.org/pandas-docs/stable/contributing.html>`_.
1211

12+
Overview
13+
========
14+
15+
We welcome your skills and enthusiasm at the xarray project!. There are numerous opportunities to
16+
contribute beyond just writing code.
17+
All contributions, including bug reports, bug fixes, documentation improvements, enhancement suggestions,
18+
and other ideas are welcome.
19+
20+
If you have any questions on the process or how to fix something feel free to ask us!
21+
The recommended place to ask a question is on `GitHub Discussions <https://github.com/pydata/xarray/discussions>`_
22+
, but we also have a `Discord <https://discord.com/invite/wEKPCt4PDu>`_ and a
23+
`mailing list <https://groups.google.com/g/xarray>`_. There is also a
24+
`"python-xarray" tag on Stack Overflow <https://stackoverflow.com/questions/tagged/python-xarray>`_ which we monitor for questions.
25+
26+
We also have a biweekly community call, details of which are announced on the
27+
`Developers meeting <https://docs.xarray.dev/en/stable/developers-meeting.html>`_.
28+
You are very welcome to join! Though we would love to hear from you, there is no expectation to
29+
contribute during the meeting either - you are always welcome to just sit in and listen.
30+
31+
This project is a community effort, and everyone is welcome to contribute. Everyone within the community
32+
is expected to abide by our `code of conduct <https://github.com/pydata/xarray/blob/main/CODE_OF_CONDUCT.md>`_.
33+
1334
Where to start?
1435
===============
1536

16-
All contributions, bug reports, bug fixes, documentation improvements,
17-
enhancements, and ideas are welcome.
18-
1937
If you are brand new to *xarray* or open-source development, we recommend going
2038
through the `GitHub "issues" tab <https://github.com/pydata/xarray/issues>`_
21-
to find issues that interest you. There are a number of issues listed under
22-
`Documentation <https://github.com/pydata/xarray/labels/topic-documentation>`_
39+
to find issues that interest you.
40+
Some issues are particularly suited for new contributors by the label `Documentation <https://github.com/pydata/xarray/labels/topic-documentation>`_
2341
and `good first issue
24-
<https://github.com/pydata/xarray/labels/contrib-good-first-issue>`_
25-
where you could start out. Once you've found an interesting issue, you can
26-
return here to get your development environment setup.
42+
<https://github.com/pydata/xarray/labels/contrib-good-first-issue>`_ where you could start out.
43+
These are well documented issues, that do not require a deep understanding of the internals of xarray.
2744

28-
Feel free to ask questions on the `mailing list
29-
<https://groups.google.com/g/xarray>`_.
45+
Once you've found an interesting issue, you can return here to get your development environment setup.
46+
The xarray project does not assign issues. Issues are "assigned" by opening a Pull Request(PR).
3047

3148
.. _contributing.bug_reports:
3249

3350
Bug reports and enhancement requests
3451
====================================
3552

3653
Bug reports are an important part of making *xarray* more stable. Having a complete bug
37-
report will allow others to reproduce the bug and provide insight into fixing. See
38-
this `stackoverflow article for tips on
39-
writing a good bug report <https://stackoverflow.com/help/mcve>`_ .
54+
report will allow others to reproduce the bug and provide insight into fixing.
4055

4156
Trying out the bug-producing code on the *main* branch is often a worthwhile exercise
4257
to confirm that the bug still exists. It is also worth searching existing bug reports and
4358
pull requests to see if the issue has already been reported and/or fixed.
4459

45-
Bug reports must:
60+
Submitting a bug report
61+
-----------------------
62+
63+
If you find a bug in the code or documentation, do not hesitate to submit a ticket to the
64+
`Issue Tracker <https://github.com/pydata/xarray/issues>`_.
65+
You are also welcome to post feature requests or pull requests.
66+
67+
If you are reporting a bug, please use the provided template which includes the following:
4668

4769
#. Include a short, self-contained Python snippet reproducing the problem.
4870
You can format the code nicely by using `GitHub Flavored Markdown
@@ -67,26 +89,20 @@ Bug reports must:
6789

6890
#. Explain why the current behavior is wrong/not desired and what you expect instead.
6991

70-
The issue will then show up to the *xarray* community and be open to comments/ideas
71-
from others.
92+
The issue will then show up to the *xarray* community and be open to comments/ideas from others.
7293

73-
.. _contributing.github:
94+
See this `stackoverflow article for tips on writing a good bug report <https://stackoverflow.com/help/mcve>`_ .
7495

75-
Working with the code
76-
=====================
96+
97+
.. _contributing.github:
7798

7899
Now that you have an issue you want to fix, enhancement to add, or documentation
79100
to improve, you need to learn how to work with GitHub and the *xarray* code base.
80101

81102
.. _contributing.version_control:
82103

83104
Version control, Git, and GitHub
84-
--------------------------------
85-
86-
To the new user, working with Git is one of the more daunting aspects of contributing
87-
to *xarray*. It can very quickly become overwhelming, but sticking to the guidelines
88-
below will help keep the process straightforward and mostly trouble free. As always,
89-
if you are having difficulties please feel free to ask for help.
105+
================================
90106

91107
The code is hosted on `GitHub <https://www.github.com/pydata/xarray>`_. To
92108
contribute you will need to sign up for a `free GitHub account
@@ -112,41 +128,41 @@ you can work seamlessly between your local repository and GitHub.
112128
but contributors who are new to git may find it easier to use other tools instead such as
113129
`Github Desktop <https://desktop.github.com/>`_.
114130

115-
.. _contributing.forking:
131+
Development workflow
132+
====================
133+
134+
To keep your work well organized, with readable history, and in turn make it easier for project
135+
maintainers to see what you've done, and why you did it, we recommend you to follow workflow:
116136

117-
Forking
118-
-------
137+
1. `Create an account <https://github.com/>`_ on GitHub if you do not already have one.
119138

120-
You will need your own fork to work on the code. Go to the `xarray project
121-
page <https://github.com/pydata/xarray>`_ and hit the ``Fork`` button. You will
122-
want to clone your fork to your machine::
139+
2. You will need your own fork to work on the code. Go to the `xarray project
140+
page <https://github.com/pydata/xarray>`_ and hit the ``Fork`` button near the top of the page.
141+
This creates a copy of the code under your account on the GitHub server.
142+
143+
3. Clone your fork to your machine::
123144

124145
git clone https://github.com/your-user-name/xarray.git
125146
cd xarray
126147
git remote add upstream https://github.com/pydata/xarray.git
127148

128-
This creates the directory `xarray` and connects your repository to
129-
the upstream (main project) *xarray* repository.
130-
131-
Creating a branch
132-
-----------------
133-
134-
You want your ``main`` branch to reflect only production-ready code, so create a
135-
feature branch before making your changes. For example::
149+
This creates the directory `xarray` and connects your repository to
150+
the upstream (main project) *xarray* repository.
136151

137-
git branch shiny-new-feature
138-
git checkout shiny-new-feature
152+
Creating a development environment
153+
----------------------------------
139154

140-
The above can be simplified to::
155+
To test out code changes locally, you'll need to build *xarray* from source, which requires you to
156+
`create a local development environment <https://docs.xarray.dev/en/stable/contributing.html#creating-a-development-environment>`_.
141157

142-
git checkout -b shiny-new-feature
158+
Update the ``main`` branch
159+
--------------------------
143160

144-
This changes your working directory to the shiny-new-feature branch. Keep any
145-
changes in this branch specific to one bug or feature so it is clear
146-
what the branch brings to *xarray*. You can have many "shiny-new-features"
147-
and switch in between them using the ``git checkout`` command.
161+
First make sure you have followed `Setting up xarray for development
162+
<https://docs.xarray.dev/en/stable/contributing.html#creating-a-development-environment>`_
148163

149-
To update this branch, you need to retrieve the changes from the ``main`` branch::
164+
Before starting a new set of changes, fetch all changes from ``upstream/main``, and start a new
165+
feature branch from that. From time to time you should fetch the upstream changes from GitHub: ::
150166

151167
git fetch upstream
152168
git merge upstream/main
@@ -157,10 +173,83 @@ request. If you have uncommitted changes, you will need to ``git stash`` them
157173
prior to updating. This will effectively store your changes, which can be
158174
reapplied after updating.
159175

176+
Create a new feature branch
177+
---------------------------
178+
179+
Create a branch to save your changes, even before you start making changes. You want your
180+
``main branch`` to contain only production-ready code::
181+
182+
git checkout -b shiny-new-feature
183+
184+
This changes your working directory to the ``shiny-new-feature`` branch. Keep any changes in this
185+
branch specific to one bug or feature so it is clear what the branch brings to *xarray*. You can have
186+
many "shiny-new-features" and switch in between them using the ``git checkout`` command.
187+
188+
Generally, you will want to keep your feature branches on your public GitHub fork of xarray. To do this,
189+
you ``git push`` this new branch up to your GitHub repo. Generally (if you followed the instructions in
190+
these pages, and by default), git will have a link to your fork of the GitHub repo, called ``origin``.
191+
You push up to your own fork with: ::
192+
193+
git push origin shiny-new-feature
194+
195+
In git >= 1.7 you can ensure that the link is correctly set by using the ``--set-upstream`` option: ::
196+
197+
git push --set-upstream origin shiny-new-feature
198+
199+
From now on git will know that ``shiny-new-feature`` is related to the ``shiny-new-feature branch`` in the GitHub repo.
200+
201+
The editing workflow
202+
--------------------
203+
204+
1. Make some changes
205+
206+
2. See which files have changed with ``git status``. You'll see a listing like this one: ::
207+
208+
# On branch shiny-new-feature
209+
# Changed but not updated:
210+
# (use "git add <file>..." to update what will be committed)
211+
# (use "git checkout -- <file>..." to discard changes in working directory)
212+
#
213+
# modified: README
214+
215+
3. Check what the actual changes are with ``git diff``.
216+
217+
4. Build the `documentation run <https://docs.xarray.dev/en/stable/contributing.html#building-the-documentation>`_
218+
for the documentation changes.
219+
220+
`Run the test suite <https://docs.xarray.dev/en/stable/contributing.html#running-the-test-suite>`_ for code changes.
221+
222+
Commit and push your changes
223+
----------------------------
224+
225+
1. To commit all modified files into the local copy of your repo, do ``git commit -am 'A commit message'``.
226+
227+
2. To push the changes up to your forked repo on GitHub, do a ``git push``.
228+
229+
Open a pull request
230+
-------------------
231+
232+
When you're ready or need feedback on your code, open a Pull Request (PR) so that the xarray developers can
233+
give feedback and eventually include your suggested code into the ``main`` branch.
234+
`Pull requests (PRs) on GitHub <https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests>`_
235+
are the mechanism for contributing to xarray's code and documentation.
236+
237+
Enter a title for the set of changes with some explanation of what you've done.
238+
Follow the PR template, which looks like this. ::
239+
240+
[ ]Closes #xxxx
241+
[ ]Tests added
242+
[ ]User visible changes (including notable bug fixes) are documented in whats-new.rst
243+
[ ]New functions/methods are listed in api.rst
244+
245+
Mention anything you'd like particular attention for - such as a complicated change or some code you are not happy with.
246+
If you don't think your request is ready to be merged, just say so in your pull request message and use
247+
the "Draft PR" feature of GitHub. This is a good way of getting some preliminary code review.
248+
160249
.. _contributing.dev_env:
161250

162251
Creating a development environment
163-
----------------------------------
252+
==================================
164253

165254
To test out code changes locally, you'll need to build *xarray* from source, which
166255
requires a Python environment. If you're making documentation changes, you can
@@ -182,7 +271,7 @@ documentation locally before pushing your changes.
182271
.. _contributing.dev_python:
183272

184273
Creating a Python Environment
185-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
274+
-----------------------------
186275

187276
Before starting any development, you'll need to create an isolated xarray
188277
development environment:
@@ -240,6 +329,22 @@ To return to your root environment::
240329

241330
See the full `conda docs here <http://conda.pydata.org/docs>`__.
242331

332+
Install pre-commit hooks
333+
------------------------
334+
335+
We highly recommend that you setup `pre-commit <https://pre-commit.com/>`_ hooks to automatically
336+
run all the above tools every time you make a git commit. To install the hooks::
337+
338+
python -m pip install pre-commit
339+
pre-commit install
340+
341+
This can be done by running: ::
342+
343+
pre-commit run
344+
345+
from the root of the xarray repository. You can skip the pre-commit checks with
346+
``git commit --no-verify``.
347+
243348
.. _contributing.documentation:
244349

245350
Contributing to the documentation
@@ -363,6 +468,60 @@ If you want to do a full clean build, do::
363468
make clean
364469
make html
365470

471+
Writing ReST pages
472+
------------------
473+
474+
Most documentation is either in the docstrings of individual classes and methods, in explicit
475+
``.rst`` files, or in examples and tutorials. All of these use the
476+
`ReST <https://docutils.sourceforge.io/rst.html>`_ syntax and are processed by
477+
`Sphinx <https://www.sphinx-doc.org/en/master/>`_.
478+
479+
This section contains additional information and conventions how ReST is used in the
480+
xarray documentation.
481+
482+
Section formatting
483+
~~~~~~~~~~~~~~~~~~
484+
485+
We aim to follow the recommendations from the
486+
`Python documentation <https://devguide.python.org/documentation/start-documenting/index.html#sections>`_
487+
and the `Sphinx reStructuredText documentation <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#sections>`_
488+
for section markup characters,
489+
490+
- ``*`` with overline, for chapters
491+
492+
- ``=``, for heading
493+
494+
- ``-``, for sections
495+
496+
- ``~``, for subsections
497+
498+
- ``**`` text ``**``, for **bold** text
499+
500+
Referring to other documents and sections
501+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
502+
503+
`Sphinx <https://www.sphinx-doc.org/en/master/>`_ allows internal
504+
`references <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`_ between documents.
505+
506+
Documents can be linked with the ``:doc:`` directive:
507+
508+
::
509+
510+
See the :doc:`/getting-started-guide/installing`
511+
512+
See the :doc:`/getting-started-guide/quick-overview`
513+
514+
will render as:
515+
516+
See the `Installation <https://docs.xarray.dev/en/stable/getting-started-guide/installing.html>`_
517+
518+
See the `Quick Overview <https://docs.xarray.dev/en/stable/getting-started-guide/quick-overview.html>`_
519+
520+
Including figures and files
521+
---------------------------
522+
523+
Image files can be directly included in pages with the ``image::`` directive.
524+
366525
.. _contributing.code:
367526

368527
Contributing to the code base
@@ -490,9 +649,7 @@ Writing tests
490649

491650
All tests should go into the ``tests`` subdirectory of the specific package.
492651
This folder contains many current examples of tests, and we suggest looking to these for
493-
inspiration. If your test requires working with files or
494-
network connectivity, there is more information on the `testing page
495-
<https://github.com/pydata/xarray/wiki/Testing>`_ of the wiki.
652+
inspiration.
496653

497654
The ``xarray.testing`` module has many special ``assert`` functions that
498655
make it easier to make statements about whether DataArray or Dataset objects are

0 commit comments

Comments
 (0)