From 161c1211d4c8ca51eb77970dc69b5065e540173d Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 1 Mar 2018 11:00:56 +0100 Subject: [PATCH 1/6] DOC: suppress attributes for RangeIndex api docs --- pandas/core/indexes/range.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 9d770cffb0059..7c266dc889368 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -53,6 +53,10 @@ class RangeIndex(Int64Index): Index : The base pandas Index type Int64Index : Index of int64 data + Attributes + ---------- + None + Methods ------- from_range From 5a515b2a54c4c1e53a33bf7edf66b2e8d93b8d49 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 1 Mar 2018 11:47:37 +0100 Subject: [PATCH 2/6] Add 'autodoc-process-docstring' connector to avoid warnings --- doc/source/conf.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/doc/source/conf.py b/doc/source/conf.py index 835127e5094e4..0142f7facc075 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -552,6 +552,45 @@ def remove_flags_docstring(app, what, name, obj, options, lines): del lines[:] +def process_class_docstrings(app, what, name, obj, options, lines): + """ + For those classes for which we use :: + + :template: autosummary/class_without_autosummary.rst + + the documented attributes/methods have to be listed in the class + docstring. However, if one of those lists is empty, we use 'None', + which then generates warnings in sphinx / ugly html output. + This "autodoc-process-docstring" event connector removes that part + from the processed docstring. + + """ + if what == "class": + joined = '\n'.join(lines) + + templates = + [""".. rubric:: Attributes + +.. autosummary:: + :toctree: + + None +""", + """.. rubric:: Methods + +.. autosummary:: + :toctree: + + None +""" + ] + + for template in templates: + if template in joined: + joined = joined.replace(template, '') + lines[:] = joined.split('\n') + + suppress_warnings = [ # We "overwrite" autosummary with our PandasAutosummary, but # still want the regular autosummary setup to run. So we just @@ -562,6 +601,7 @@ def remove_flags_docstring(app, what, name, obj, options, lines): def setup(app): app.connect("autodoc-process-docstring", remove_flags_docstring) + app.connect("autodoc-process-docstring", process_class_docstrings) app.add_autodocumenter(AccessorDocumenter) app.add_autodocumenter(AccessorAttributeDocumenter) app.add_autodocumenter(AccessorMethodDocumenter) From b04205f8c3001ea85fe34a00971333c345d6b9d2 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 1 Mar 2018 11:49:11 +0100 Subject: [PATCH 3/6] lint --- doc/source/conf.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 0142f7facc075..2533f046dc8e0 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -568,22 +568,22 @@ def process_class_docstrings(app, what, name, obj, options, lines): if what == "class": joined = '\n'.join(lines) - templates = - [""".. rubric:: Attributes + templates = [ + """.. rubric:: Attributes .. autosummary:: :toctree: None """, - """.. rubric:: Methods + """.. rubric:: Methods .. autosummary:: :toctree: None """ - ] + ] for template in templates: if template in joined: From 6f0e6f6024b70af7e3e92012379f2e99fee84113 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 1 Mar 2018 11:59:25 +0100 Subject: [PATCH 4/6] remove attributes/methods in numeric index classes --- pandas/core/indexes/numeric.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/pandas/core/indexes/numeric.py b/pandas/core/indexes/numeric.py index a4558116bfa63..4ce34e0005182 100644 --- a/pandas/core/indexes/numeric.py +++ b/pandas/core/indexes/numeric.py @@ -129,14 +129,6 @@ def is_all_dates(self): name : object Name to be stored in the index - Attributes - ---------- - inferred_type - - Methods - ------- - None - Notes ----- An Index instance can **only** contain hashable objects. From c109dcba19b9c1a3cd59e8858923faa02bf5ff58 Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 1 Mar 2018 13:47:00 +0100 Subject: [PATCH 5/6] try to satisfy both local linter and ci linter --- doc/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 2533f046dc8e0..c81d38db05cca 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -583,7 +583,7 @@ def process_class_docstrings(app, what, name, obj, options, lines): None """ - ] + ] for template in templates: if template in joined: From ce277116e484d6839ac419a8597760d5f127f87e Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 1 Mar 2018 13:51:02 +0100 Subject: [PATCH 6/6] keep None in numeric index --- pandas/core/indexes/numeric.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pandas/core/indexes/numeric.py b/pandas/core/indexes/numeric.py index 4ce34e0005182..1fe0c8fa289e6 100644 --- a/pandas/core/indexes/numeric.py +++ b/pandas/core/indexes/numeric.py @@ -129,6 +129,14 @@ def is_all_dates(self): name : object Name to be stored in the index + Attributes + ---------- + None + + Methods + ------- + None + Notes ----- An Index instance can **only** contain hashable objects.