Skip to content

Commit ba74979

Browse files
thodson-usgsclaude
andcommitted
docs(waterdata.xarray): emit valid numpydoc from the wrapper docstrings
_xr_doc prepended a 4-space-indented note to the wrapped getter's docstring; because the wrapped first line is unindented, inspect.getdoc's dedent broke and left the Parameters/Returns sections over-indented, so napoleon (the package uses numpydoc) mis-rendered them. Build a column-0 summary paragraph and append the cleandoc'd body so the combined docstring is valid numpydoc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 3274d91 commit ba74979

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

dataretrieval/waterdata/xarray.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from __future__ import annotations
4141

4242
import datetime as _dt
43+
import inspect as _inspect
4344
import re as _re
4445
import warnings as _warnings
4546
from collections.abc import Callable
@@ -761,13 +762,18 @@ def _xr_doc(func, *, cf_metadata=True, allow_dense=True):
761762
"(always ragged; discrete samples are too sparse for a dense grid, "
762763
"so ``dense=`` does not apply)"
763764
)
765+
# A column-0 summary paragraph + a cleandoc'd body keeps the combined
766+
# docstring valid numpydoc (the wrapped getter's first line is unindented
767+
# but its body is source-indented, which would otherwise break dedent and
768+
# over-indent the Parameters/Returns sections).
764769
note = (
765-
" xarray wrapper: same arguments as "
766-
f"``dataretrieval.waterdata.{func.__name__}``, but returns\n"
767-
f" {returns}. Hash-valued ID columns are always omitted here;\n"
768-
" the ``include_hash`` flag does not apply.\n\n"
770+
"xarray wrapper: same arguments as "
771+
f"``dataretrieval.waterdata.{func.__name__}``, but returns {returns}. "
772+
"Hash-valued ID columns are always omitted here; the ``include_hash`` "
773+
"flag does not apply."
769774
)
770-
return note + (func.__doc__ or "")
775+
body = _inspect.cleandoc(func.__doc__) if func.__doc__ else ""
776+
return f"{note}\n\n{body}" if body else note
771777

772778

773779
@dataclass(frozen=True)

0 commit comments

Comments
 (0)