From a8a22fcfcb7311f5f1be61c4e7c9dd99d639c758 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Wed, 23 Dec 2020 23:37:04 +0100 Subject: [PATCH] Backport PR #38657: DOC/CI: fix class alias docstrings for sphinx 3.4 + unpin sphinx --- doc/source/conf.py | 25 +++++++++++++++++++++++++ environment.yml | 2 +- requirements-dev.txt | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 15e7a13ff5b72..951a6d4043786 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -687,6 +687,30 @@ def process_class_docstrings(app, what, name, obj, options, lines): lines[:] = joined.split("\n") +_BUSINED_ALIASES = [ + "pandas.tseries.offsets." + name + for name in [ + "BDay", + "CDay", + "BMonthEnd", + "BMonthBegin", + "CBMonthEnd", + "CBMonthBegin", + ] +] + + +def process_business_alias_docstrings(app, what, name, obj, options, lines): + """ + Starting with sphinx 3.4, the "autodoc-process-docstring" event also + gets called for alias classes. This results in numpydoc adding the + methods/attributes to the docstring, which we don't want (+ this + causes warnings with sphinx). + """ + if name in _BUSINED_ALIASES: + lines[:] = [] + + suppress_warnings = [ # We "overwrite" autosummary with our PandasAutosummary, but # still want the regular autosummary setup to run. So we just @@ -716,6 +740,7 @@ def setup(app): app.connect("source-read", rstjinja) app.connect("autodoc-process-docstring", remove_flags_docstring) app.connect("autodoc-process-docstring", process_class_docstrings) + app.connect("autodoc-process-docstring", process_business_alias_docstrings) app.add_autodocumenter(AccessorDocumenter) app.add_autodocumenter(AccessorAttributeDocumenter) app.add_autodocumenter(AccessorMethodDocumenter) diff --git a/environment.yml b/environment.yml index 1ac190830c132..b99b856187fb6 100644 --- a/environment.yml +++ b/environment.yml @@ -31,7 +31,7 @@ dependencies: # documentation - gitpython # obtain contributors from git for whatsnew - gitdb - - sphinx=3.3.1 + - sphinx # documentation (jupyter notebooks) - nbconvert>=5.4.1 diff --git a/requirements-dev.txt b/requirements-dev.txt index 137c0db5f4408..17ca6b8401501 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -17,7 +17,7 @@ pycodestyle pyupgrade gitpython gitdb -sphinx==3.3.1 +sphinx nbconvert>=5.4.1 nbsphinx pandoc