Skip to content

Commit b4cb528

Browse files
Backport PR #38657: DOC/CI: fix class alias docstrings for sphinx 3.4 + unpin sphinx (#38669)
Co-authored-by: Joris Van den Bossche <[email protected]>
1 parent 9c1efbb commit b4cb528

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

doc/source/conf.py

+25
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,30 @@ def process_class_docstrings(app, what, name, obj, options, lines):
687687
lines[:] = joined.split("\n")
688688

689689

690+
_BUSINED_ALIASES = [
691+
"pandas.tseries.offsets." + name
692+
for name in [
693+
"BDay",
694+
"CDay",
695+
"BMonthEnd",
696+
"BMonthBegin",
697+
"CBMonthEnd",
698+
"CBMonthBegin",
699+
]
700+
]
701+
702+
703+
def process_business_alias_docstrings(app, what, name, obj, options, lines):
704+
"""
705+
Starting with sphinx 3.4, the "autodoc-process-docstring" event also
706+
gets called for alias classes. This results in numpydoc adding the
707+
methods/attributes to the docstring, which we don't want (+ this
708+
causes warnings with sphinx).
709+
"""
710+
if name in _BUSINED_ALIASES:
711+
lines[:] = []
712+
713+
690714
suppress_warnings = [
691715
# We "overwrite" autosummary with our PandasAutosummary, but
692716
# still want the regular autosummary setup to run. So we just
@@ -716,6 +740,7 @@ def setup(app):
716740
app.connect("source-read", rstjinja)
717741
app.connect("autodoc-process-docstring", remove_flags_docstring)
718742
app.connect("autodoc-process-docstring", process_class_docstrings)
743+
app.connect("autodoc-process-docstring", process_business_alias_docstrings)
719744
app.add_autodocumenter(AccessorDocumenter)
720745
app.add_autodocumenter(AccessorAttributeDocumenter)
721746
app.add_autodocumenter(AccessorMethodDocumenter)

environment.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies:
3131
# documentation
3232
- gitpython # obtain contributors from git for whatsnew
3333
- gitdb
34-
- sphinx=3.3.1
34+
- sphinx
3535

3636
# documentation (jupyter notebooks)
3737
- nbconvert>=5.4.1

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pycodestyle
1717
pyupgrade
1818
gitpython
1919
gitdb
20-
sphinx==3.3.1
20+
sphinx
2121
nbconvert>=5.4.1
2222
nbsphinx
2323
pandoc

0 commit comments

Comments
 (0)