Skip to content
This repository was archived by the owner on Oct 24, 2024. It is now read-only.

Commit a41c1df

Browse files
Use napoleon instead of numpydoc (xarray doc alignment), and fixes (#298)
* Use napoleon instead of numpydoc, and fixes * docs * A mypy ignore for pre-commit run --all-files * Updated whats-new.rst
1 parent e4e913b commit a41c1df

File tree

8 files changed

+87
-14
lines changed

8 files changed

+87
-14
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,5 @@ dmypy.json
131131

132132
# version
133133
_version.py
134+
135+
.vscode

ci/doc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ dependencies:
1313
- sphinx-book-theme >= 0.0.38
1414
- nbsphinx
1515
- sphinxcontrib-srclinks
16+
- pickleshare
1617
- pydata-sphinx-theme>=0.4.3
17-
- numpydoc
1818
- ipython
1919
- h5netcdf
2020
- zarr

datatree/mapping.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ def wrapper(*args, **kwargs):
282282
def add_note(err: BaseException, msg: str) -> None:
283283
# TODO: remove once python 3.10 can be dropped
284284
if sys.version_info < (3, 11):
285-
err.__notes__ = getattr(err, "__notes__", []) + [msg]
285+
err.__notes__ = getattr(err, "__notes__", []) + [msg] # type: ignore[attr-defined]
286286
else:
287287
err.add_note(msg)
288288

docs/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# README - docs
2+
3+
## Build the documentation locally
4+
5+
```bash
6+
cd docs # From project's root
7+
make clean
8+
rm -rf source/generated # remove autodoc artefacts, that are not removed by `make clean`
9+
make html
10+
```
11+
12+
## Access the documentation locally
13+
14+
Open `docs/_build/html/index.html` in a web browser

docs/source/api.rst

-2
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,7 @@ Methods copied from :py:class:`numpy.ndarray` objects, here applying to the data
249249
DataTree.clip
250250
DataTree.conj
251251
DataTree.conjugate
252-
DataTree.imag
253252
DataTree.round
254-
DataTree.real
255253
DataTree.rank
256254

257255
Reshaping and reorganising

docs/source/conf.py

+65-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
# Add any Sphinx extension module names here, as strings. They can be extensions
4040
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
4141
extensions = [
42-
"numpydoc",
4342
"sphinx.ext.autodoc",
4443
"sphinx.ext.viewcode",
4544
"sphinx.ext.linkcode",
@@ -57,15 +56,78 @@
5756
]
5857

5958
extlinks = {
60-
"issue": ("https://github.com/TomNicholas/datatree/issues/%s", "GH#"),
61-
"pull": ("https://github.com/TomNicholas/datatree/pull/%s", "GH#"),
59+
"issue": ("https://github.com/xarray-contrib/datatree/issues/%s", "GH#%s"),
60+
"pull": ("https://github.com/xarray-contrib/datatree/pull/%s", "GH#%s"),
6261
}
6362
# Add any paths that contain templates here, relative to this directory.
6463
templates_path = ["_templates", sphinx_autosummary_accessors.templates_path]
6564

6665
# Generate the API documentation when building
6766
autosummary_generate = True
6867

68+
69+
# Napoleon configurations
70+
71+
napoleon_google_docstring = False
72+
napoleon_numpy_docstring = True
73+
napoleon_use_param = False
74+
napoleon_use_rtype = False
75+
napoleon_preprocess_types = True
76+
napoleon_type_aliases = {
77+
# general terms
78+
"sequence": ":term:`sequence`",
79+
"iterable": ":term:`iterable`",
80+
"callable": ":py:func:`callable`",
81+
"dict_like": ":term:`dict-like <mapping>`",
82+
"dict-like": ":term:`dict-like <mapping>`",
83+
"path-like": ":term:`path-like <path-like object>`",
84+
"mapping": ":term:`mapping`",
85+
"file-like": ":term:`file-like <file-like object>`",
86+
# special terms
87+
# "same type as caller": "*same type as caller*", # does not work, yet
88+
# "same type as values": "*same type as values*", # does not work, yet
89+
# stdlib type aliases
90+
"MutableMapping": "~collections.abc.MutableMapping",
91+
"sys.stdout": ":obj:`sys.stdout`",
92+
"timedelta": "~datetime.timedelta",
93+
"string": ":class:`string <str>`",
94+
# numpy terms
95+
"array_like": ":term:`array_like`",
96+
"array-like": ":term:`array-like <array_like>`",
97+
"scalar": ":term:`scalar`",
98+
"array": ":term:`array`",
99+
"hashable": ":term:`hashable <name>`",
100+
# matplotlib terms
101+
"color-like": ":py:func:`color-like <matplotlib.colors.is_color_like>`",
102+
"matplotlib colormap name": ":doc:`matplotlib colormap name <matplotlib:gallery/color/colormap_reference>`",
103+
"matplotlib axes object": ":py:class:`matplotlib axes object <matplotlib.axes.Axes>`",
104+
"colormap": ":py:class:`colormap <matplotlib.colors.Colormap>`",
105+
# objects without namespace: xarray
106+
"DataArray": "~xarray.DataArray",
107+
"Dataset": "~xarray.Dataset",
108+
"Variable": "~xarray.Variable",
109+
"DatasetGroupBy": "~xarray.core.groupby.DatasetGroupBy",
110+
"DataArrayGroupBy": "~xarray.core.groupby.DataArrayGroupBy",
111+
# objects without namespace: numpy
112+
"ndarray": "~numpy.ndarray",
113+
"MaskedArray": "~numpy.ma.MaskedArray",
114+
"dtype": "~numpy.dtype",
115+
"ComplexWarning": "~numpy.ComplexWarning",
116+
# objects without namespace: pandas
117+
"Index": "~pandas.Index",
118+
"MultiIndex": "~pandas.MultiIndex",
119+
"CategoricalIndex": "~pandas.CategoricalIndex",
120+
"TimedeltaIndex": "~pandas.TimedeltaIndex",
121+
"DatetimeIndex": "~pandas.DatetimeIndex",
122+
"Series": "~pandas.Series",
123+
"DataFrame": "~pandas.DataFrame",
124+
"Categorical": "~pandas.Categorical",
125+
"Path": "~~pathlib.Path",
126+
# objects with abbreviated namespace (from pandas)
127+
"pd.Index": "~pandas.Index",
128+
"pd.NaT": "~pandas.NaT",
129+
}
130+
69131
# The suffix of source filenames.
70132
source_suffix = ".rst"
71133

@@ -177,11 +239,6 @@
177239
# pixels large.
178240
# html_favicon = None
179241

180-
# Add any paths that contain custom static files (such as style sheets) here,
181-
# relative to this directory. They are copied after the builtin static files,
182-
# so a file named "default.css" will overwrite the builtin "default.css".
183-
html_static_path = ["_static"]
184-
185242
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
186243
# using the given strftime format.
187244
# html_last_updated_fmt = '%b %d, %Y'

docs/source/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Please raise any thoughts, issues, suggestions or bugs, no matter how small or l
5050
Reading and Writing Files <io>
5151
API Reference <api>
5252
Terminology <terminology>
53-
How do I ... <howdoi>
5453
Contributing Guide <contributing>
5554
What's New <whats-new>
5655
GitHub repository <https://github.com/xarray-contrib/datatree>

docs/source/whats-new.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ Bug fixes
4444

4545
Documentation
4646
~~~~~~~~~~~~~
47+
- Use ``napoleon`` instead of ``numpydoc`` to align with xarray documentation
48+
(:issue:`284`, :pull:`298`).
49+
By `Etienne Schalk <https://github.com/etienneschalk>`_.
4750

4851
Internal Changes
4952
~~~~~~~~~~~~~~~~
@@ -365,7 +368,7 @@ Breaking changes
365368
- Removes the option to delete all data in a node by assigning None to the node (in favour of deleting data by replacing
366369
the node's ``.ds`` attribute with an empty Dataset), or to create a new empty node in the same way (in favour of
367370
assigning an empty DataTree object instead).
368-
- Removes the ability to create a new node by assigning a ``Dataset`` object to ``DataTree.__setitem__`.
371+
- Removes the ability to create a new node by assigning a ``Dataset`` object to ``DataTree.__setitem__``.
369372
- Several other minor API changes such as ``.pathstr`` -> ``.path``, and ``from_dict``'s dictionary argument now being
370373
required. (:pull:`76`)
371374
By `Tom Nicholas <https://github.com/TomNicholas>`_.

0 commit comments

Comments
 (0)