@@ -37,7 +37,7 @@ Where to start?
37
37
If you are brand new to *xarray * or open-source development, we recommend going
38
38
through the `GitHub "issues" tab <https://github.com/pydata/xarray/issues >`_
39
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 >`_
40
+ Some issues are particularly suited for new contributors by the label `Documentation <https://github.com/pydata/xarray/labels/topic-documentation >`__
41
41
and `good first issue
42
42
<https://github.com/pydata/xarray/labels/contrib-good-first-issue> `_ where you could start out.
43
43
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.
130
130
but contributors who are new to git may find it easier to use other tools instead such as
131
131
`Github Desktop <https://desktop.github.com/ >`_.
132
132
133
+ .. _contributing.dev_workflow :
134
+
133
135
Development workflow
134
136
====================
135
137
@@ -151,107 +153,16 @@ maintainers to see what you've done, and why you did it, we recommend you to fol
151
153
This creates the directory ``xarray`` and connects your repository to
152
154
the upstream (main project) *xarray* repository.
153
155
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::
207
157
208
- 2. See which files have changed with `` git status ``. You'll see a listing like this one: ::
158
+ git fetch --tags upstream
209
159
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.
250
161
251
162
.. _contributing.dev_env :
252
163
253
164
Creating a development environment
254
- ==================================
165
+ ----------------------------------
255
166
256
167
To test out code changes locally, you'll need to build *xarray * from source, which
257
168
requires a Python environment. If you're making documentation changes, you can
@@ -281,7 +192,7 @@ development environment:
281
192
- Install either `Anaconda <https://www.anaconda.com/download/ >`_ or `miniconda
282
193
<https://conda.io/miniconda.html> `_
283
194
- 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 >`
285
196
- ``cd `` to the *xarray * source directory
286
197
287
198
We'll now kick off a two-step process:
@@ -316,7 +227,7 @@ built version:
316
227
$ python # start an interpreter
317
228
>>> import xarray
318
229
>>> xarray.__version__
319
- ' 0.10.0+dev46.g015daca '
230
+ ' 2025.7.2.dev14+g5ce69b2b.d20250725 '
320
231
321
232
This will create the new environment, and not touch any of your existing environments,
322
233
nor any existing Python installation.
@@ -347,6 +258,103 @@ This can be done by running: ::
347
258
from the root of the xarray repository. You can skip the pre-commit checks with
348
259
``git commit --no-verify ``.
349
260
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
+
350
358
.. _contributing.documentation :
351
359
352
360
Contributing to the documentation
@@ -425,7 +433,7 @@ How to build the *xarray* documentation
425
433
426
434
Requirements
427
435
~~~~~~~~~~~~
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
429
437
to build the docs you need to use the environment file ``ci/requirements/doc.yml ``.
430
438
You should also use this environment and these steps if you want to view changes you've made to the docstrings.
431
439
0 commit comments