@@ -552,6 +552,45 @@ def remove_flags_docstring(app, what, name, obj, options, lines):
552
552
del lines [:]
553
553
554
554
555
+ def process_class_docstrings (app , what , name , obj , options , lines ):
556
+ """
557
+ For those classes for which we use ::
558
+
559
+ :template: autosummary/class_without_autosummary.rst
560
+
561
+ the documented attributes/methods have to be listed in the class
562
+ docstring. However, if one of those lists is empty, we use 'None',
563
+ which then generates warnings in sphinx / ugly html output.
564
+ This "autodoc-process-docstring" event connector removes that part
565
+ from the processed docstring.
566
+
567
+ """
568
+ if what == "class" :
569
+ joined = '\n ' .join (lines )
570
+
571
+ templates = [
572
+ """.. rubric:: Attributes
573
+
574
+ .. autosummary::
575
+ :toctree:
576
+
577
+ None
578
+ """ ,
579
+ """.. rubric:: Methods
580
+
581
+ .. autosummary::
582
+ :toctree:
583
+
584
+ None
585
+ """
586
+ ]
587
+
588
+ for template in templates :
589
+ if template in joined :
590
+ joined = joined .replace (template , '' )
591
+ lines [:] = joined .split ('\n ' )
592
+
593
+
555
594
suppress_warnings = [
556
595
# We "overwrite" autosummary with our PandasAutosummary, but
557
596
# 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):
562
601
563
602
def setup (app ):
564
603
app .connect ("autodoc-process-docstring" , remove_flags_docstring )
604
+ app .connect ("autodoc-process-docstring" , process_class_docstrings )
565
605
app .add_autodocumenter (AccessorDocumenter )
566
606
app .add_autodocumenter (AccessorAttributeDocumenter )
567
607
app .add_autodocumenter (AccessorMethodDocumenter )
0 commit comments