Skip to content

Commit 4d16307

Browse files
Update documentation to copy tags when forking, so versioning is reasonable (#10576)
* Update docs to copy tags across in a new fork * Update docs so fetch updates xarray version too * Move "create a development environment" so instructions are chronological * Fix hyperlink * Reroute a hyperlink that went to the pandas docs to the equivalent section of these docs * Tidy wording * Update another link to be internal rather than full url * Reformat a couple of minor points * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add newline to fix syntax * Add some underscores to make warning go away "WARNING: Duplicate explicit target name: "documentation"" --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d6fae2e commit 4d16307

File tree

1 file changed

+107
-99
lines changed

1 file changed

+107
-99
lines changed

doc/contribute/contributing.rst

Lines changed: 107 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Where to start?
3737
If you are brand new to *xarray* or open-source development, we recommend going
3838
through the `GitHub "issues" tab <https://github.com/pydata/xarray/issues>`_
3939
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>`_
40+
Some issues are particularly suited for new contributors by the label `Documentation <https://github.com/pydata/xarray/labels/topic-documentation>`__
4141
and `good first issue
4242
<https://github.com/pydata/xarray/labels/contrib-good-first-issue>`_ where you could start out.
4343
These are well documented issues, that do not require a deep understanding of the internals of xarray.
@@ -130,6 +130,8 @@ you can work seamlessly between your local repository and GitHub.
130130
but contributors who are new to git may find it easier to use other tools instead such as
131131
`Github Desktop <https://desktop.github.com/>`_.
132132

133+
.. _contributing.dev_workflow:
134+
133135
Development workflow
134136
====================
135137

@@ -151,107 +153,16 @@ maintainers to see what you've done, and why you did it, we recommend you to fol
151153
This creates the directory ``xarray`` and connects your repository to
152154
the upstream (main project) *xarray* repository.
153155

154-
Creating a development environment
155-
----------------------------------
156-
157-
To test out code changes locally, you'll need to build *xarray* from source, which requires you to
158-
`create a local development environment <https://docs.xarray.dev/en/stable/contributing.html#contributing-dev-env>`_.
159-
160-
Update the ``main`` branch
161-
--------------------------
162-
163-
First make sure you have followed `Setting up xarray for development
164-
<https://docs.xarray.dev/en/stable/contributing.html#creating-a-development-environment>`_
165-
166-
Before starting a new set of changes, fetch all changes from ``upstream/main``, and start a new
167-
feature branch from that. From time to time you should fetch the upstream changes from GitHub: ::
168-
169-
git fetch upstream
170-
git merge upstream/main
171-
172-
This will combine your commits with the latest *xarray* git ``main``. If this
173-
leads to merge conflicts, you must resolve these before submitting your pull
174-
request. If you have uncommitted changes, you will need to ``git stash`` them
175-
prior to updating. This will effectively store your changes, which can be
176-
reapplied after updating.
177-
178-
Create a new feature branch
179-
---------------------------
180-
181-
Create a branch to save your changes, even before you start making changes. You want your
182-
``main branch`` to contain only production-ready code::
183-
184-
git checkout -b shiny-new-feature
185-
186-
This changes your working directory to the ``shiny-new-feature`` branch. Keep any changes in this
187-
branch specific to one bug or feature so it is clear what the branch brings to *xarray*. You can have
188-
many "shiny-new-features" and switch in between them using the ``git checkout`` command.
189-
190-
Generally, you will want to keep your feature branches on your public GitHub fork of xarray. To do this,
191-
you ``git push`` this new branch up to your GitHub repo. Generally (if you followed the instructions in
192-
these pages, and by default), git will have a link to your fork of the GitHub repo, called ``origin``.
193-
You push up to your own fork with: ::
194-
195-
git push origin shiny-new-feature
196-
197-
In git >= 1.7 you can ensure that the link is correctly set by using the ``--set-upstream`` option: ::
198-
199-
git push --set-upstream origin shiny-new-feature
200-
201-
From now on git will know that ``shiny-new-feature`` is related to the ``shiny-new-feature branch`` in the GitHub repo.
202-
203-
The editing workflow
204-
--------------------
205-
206-
1. Make some changes
156+
4. Copy tags across from the xarray repository::
207157

208-
2. See which files have changed with ``git status``. You'll see a listing like this one: ::
158+
git fetch --tags upstream
209159

210-
# On branch shiny-new-feature
211-
# Changed but not updated:
212-
# (use "git add <file>..." to update what will be committed)
213-
# (use "git checkout -- <file>..." to discard changes in working directory)
214-
#
215-
# modified: README
216-
217-
3. Check what the actual changes are with ``git diff``.
218-
219-
4. Build the `documentation run <https://docs.xarray.dev/en/stable/contributing.html#building-the-documentation>`_
220-
for the documentation changes.
221-
222-
`Run the test suite <https://docs.xarray.dev/en/stable/contributing.html#running-the-test-suite>`_ for code changes.
223-
224-
Commit and push your changes
225-
----------------------------
226-
227-
1. To commit all modified files into the local copy of your repo, do ``git commit -am 'A commit message'``.
228-
229-
2. To push the changes up to your forked repo on GitHub, do a ``git push``.
230-
231-
Open a pull request
232-
-------------------
233-
234-
When you're ready or need feedback on your code, open a Pull Request (PR) so that the xarray developers can
235-
give feedback and eventually include your suggested code into the ``main`` branch.
236-
`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>`_
237-
are the mechanism for contributing to xarray's code and documentation.
238-
239-
Enter a title for the set of changes with some explanation of what you've done.
240-
Follow the PR template, which looks like this. ::
241-
242-
[ ]Closes #xxxx
243-
[ ]Tests added
244-
[ ]User visible changes (including notable bug fixes) are documented in whats-new.rst
245-
[ ]New functions/methods are listed in api.rst
246-
247-
Mention anything you'd like particular attention for - such as a complicated change or some code you are not happy with.
248-
If you don't think your request is ready to be merged, just say so in your pull request message and use
249-
the "Draft PR" feature of GitHub. This is a good way of getting some preliminary code review.
160+
This will ensure that when you create a development environment a reasonable version number is created.
250161

251162
.. _contributing.dev_env:
252163

253164
Creating a development environment
254-
==================================
165+
----------------------------------
255166

256167
To test out code changes locally, you'll need to build *xarray* from source, which
257168
requires a Python environment. If you're making documentation changes, you can
@@ -281,7 +192,7 @@ development environment:
281192
- Install either `Anaconda <https://www.anaconda.com/download/>`_ or `miniconda
282193
<https://conda.io/miniconda.html>`_
283194
- Make sure your conda is up to date (``conda update conda``)
284-
- Make sure that you have :ref:`cloned the repository <contributing.forking>`
195+
- Make sure that you have :ref:`cloned the repository <contributing.dev_workflow>`
285196
- ``cd`` to the *xarray* source directory
286197

287198
We'll now kick off a two-step process:
@@ -316,7 +227,7 @@ built version:
316227
$ python # start an interpreter
317228
>>> import xarray
318229
>>> xarray.__version__
319-
'0.10.0+dev46.g015daca'
230+
'2025.7.2.dev14+g5ce69b2b.d20250725'
320231
321232
This will create the new environment, and not touch any of your existing environments,
322233
nor any existing Python installation.
@@ -347,6 +258,103 @@ This can be done by running: ::
347258
from the root of the xarray repository. You can skip the pre-commit checks with
348259
``git commit --no-verify``.
349260

261+
262+
Update the ``main`` branch
263+
--------------------------
264+
265+
First make sure you have :ref:`created a development environment <contributing.dev_env>`.
266+
267+
Before starting a new set of changes, fetch all changes from ``upstream/main``, and start a new
268+
feature branch from that. From time to time you should fetch the upstream changes from GitHub: ::
269+
270+
git fetch --tags upstream
271+
git merge upstream/main
272+
273+
This will combine your commits with the latest *xarray* git ``main``. If this
274+
leads to merge conflicts, you must resolve these before submitting your pull
275+
request. If you have uncommitted changes, you will need to ``git stash`` them
276+
prior to updating. This will effectively store your changes, which can be
277+
reapplied after updating.
278+
279+
If the *xarray* ``main`` branch version has updated since you last fetched changes,
280+
you may also wish to reinstall xarray so that the pip version reflects the *xarray*
281+
version::
282+
283+
pip install -e .
284+
285+
Create a new feature branch
286+
---------------------------
287+
288+
Create a branch to save your changes, even before you start making changes. You want your
289+
``main branch`` to contain only production-ready code::
290+
291+
git checkout -b shiny-new-feature
292+
293+
This changes your working directory to the ``shiny-new-feature`` branch. Keep any changes in this
294+
branch specific to one bug or feature so it is clear what the branch brings to *xarray*. You can have
295+
many "shiny-new-features" and switch in between them using the ``git checkout`` command.
296+
297+
Generally, you will want to keep your feature branches on your public GitHub fork of xarray. To do this,
298+
you ``git push`` this new branch up to your GitHub repo. Generally (if you followed the instructions in
299+
these pages, and by default), git will have a link to your fork of the GitHub repo, called ``origin``.
300+
You push up to your own fork with: ::
301+
302+
git push origin shiny-new-feature
303+
304+
In git >= 1.7 you can ensure that the link is correctly set by using the ``--set-upstream`` option: ::
305+
306+
git push --set-upstream origin shiny-new-feature
307+
308+
From now on git will know that ``shiny-new-feature`` is related to the ``shiny-new-feature branch`` in the GitHub repo.
309+
310+
The editing workflow
311+
--------------------
312+
313+
1. Make some changes
314+
315+
2. See which files have changed with ``git status``. You'll see a listing like this one: ::
316+
317+
# On branch shiny-new-feature
318+
# Changed but not updated:
319+
# (use "git add <file>..." to update what will be committed)
320+
# (use "git checkout -- <file>..." to discard changes in working directory)
321+
#
322+
# modified: README
323+
324+
3. Check what the actual changes are with ``git diff``.
325+
326+
4. Build the `documentation <https://docs.xarray.dev/en/stable/contributing.html#building-the-documentation>`__
327+
for the documentation changes.
328+
329+
5. `Run the test suite <https://docs.xarray.dev/en/stable/contributing.html#running-the-test-suite>`_ for code changes.
330+
331+
Commit and push your changes
332+
----------------------------
333+
334+
1. To commit all modified files into the local copy of your repo, do ``git commit -am 'A commit message'``.
335+
336+
2. To push the changes up to your forked repo on GitHub, do a ``git push``.
337+
338+
Open a pull request
339+
-------------------
340+
341+
When you're ready or need feedback on your code, open a Pull Request (PR) so that the xarray developers can
342+
give feedback and eventually include your suggested code into the ``main`` branch.
343+
`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>`_
344+
are the mechanism for contributing to xarray's code and documentation.
345+
346+
Enter a title for the set of changes with some explanation of what you've done.
347+
Follow the PR template, which looks like this. ::
348+
349+
[ ]Closes #xxxx
350+
[ ]Tests added
351+
[ ]User visible changes (including notable bug fixes) are documented in whats-new.rst
352+
[ ]New functions/methods are listed in api.rst
353+
354+
Mention anything you'd like particular attention for - such as a complicated change or some code you are not happy with.
355+
If you don't think your request is ready to be merged, just say so in your pull request message and use
356+
the "Draft PR" feature of GitHub. This is a good way of getting some preliminary code review.
357+
350358
.. _contributing.documentation:
351359

352360
Contributing to the documentation
@@ -425,7 +433,7 @@ How to build the *xarray* documentation
425433

426434
Requirements
427435
~~~~~~~~~~~~
428-
Make sure to follow the instructions on :ref:`creating a development environment above <contributing.dev_env>`, but
436+
Make sure to follow the instructions on :ref:`creating a development environment<contributing.dev_env>` above, but
429437
to build the docs you need to use the environment file ``ci/requirements/doc.yml``.
430438
You should also use this environment and these steps if you want to view changes you've made to the docstrings.
431439

0 commit comments

Comments
 (0)