Skip to content

Commit 80b6bf9

Browse files
committed
Remove unnecessary templates
1 parent 5f672dc commit 80b6bf9

File tree

7 files changed

+12
-93
lines changed

7 files changed

+12
-93
lines changed

doc/source/conf.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -696,45 +696,6 @@ def remove_flags_docstring(app, what, name, obj, options, lines):
696696
del lines[:]
697697

698698

699-
def process_class_docstrings(app, what, name, obj, options, lines):
700-
"""
701-
For those classes for which we use ::
702-
703-
:template: autosummary/class_without_autosummary.rst
704-
705-
the documented attributes/methods have to be listed in the class
706-
docstring. However, if one of those lists is empty, we use 'None',
707-
which then generates warnings in sphinx / ugly html output.
708-
This "autodoc-process-docstring" event connector removes that part
709-
from the processed docstring.
710-
711-
"""
712-
if what == "class":
713-
joined = "\n".join(lines)
714-
715-
templates = [
716-
""".. rubric:: Attributes
717-
718-
.. autosummary::
719-
:toctree:
720-
721-
None
722-
""",
723-
""".. rubric:: Methods
724-
725-
.. autosummary::
726-
:toctree:
727-
728-
None
729-
""",
730-
]
731-
732-
for template in templates:
733-
if template in joined:
734-
joined = joined.replace(template, "")
735-
lines[:] = joined.split("\n")
736-
737-
738699
_BUSINED_ALIASES = [
739700
"pandas.tseries.offsets." + name
740701
for name in [
@@ -787,7 +748,6 @@ def rstjinja(app, docname, source):
787748
def setup(app):
788749
app.connect("source-read", rstjinja)
789750
app.connect("autodoc-process-docstring", remove_flags_docstring)
790-
app.connect("autodoc-process-docstring", process_class_docstrings)
791751
app.connect("autodoc-process-docstring", process_business_alias_docstrings)
792752
app.add_autodocumenter(AccessorDocumenter)
793753
app.add_autodocumenter(AccessorAttributeDocumenter)

doc/source/development/contributing_documentation.rst

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,20 @@ Some other important things to know about the docs:
7373

7474
* Our API documentation files in ``doc/source/reference`` house the auto-generated
7575
documentation from the docstrings. For classes, there are a few subtleties
76-
around controlling which methods and attributes have pages auto-generated.
77-
78-
We have two autosummary templates for classes.
79-
80-
1. ``_templates/autosummary/class.rst``. Use this when you want to
81-
automatically generate a page for every public method and attribute on the
82-
class. The ``Attributes`` and ``Methods`` sections will be automatically
83-
added to the class' rendered documentation by numpydoc. See ``DataFrame``
84-
for an example.
85-
86-
2. ``_templates/autosummary/class_without_autosummary``. Use this when you
87-
want to pick a subset of methods / attributes to auto-generate pages for.
88-
When using this template, you should include an ``Attributes`` and
89-
``Methods`` section in the class docstring. See ``CategoricalIndex`` for an
90-
example.
76+
around controlling which methods and attributes have pages auto-generated. The
77+
default autosummary template will generate pages for all public methods and
78+
attributes of classes. ``numpydoc`` will also automatically generate an
79+
``Attributes`` and ``Methods`` section for the class, leading to a redundant
80+
specification. To prevent this duplication, we have a custom autosummary
81+
template ``_templates/autosummary/class.rst`` that will generate class pages
82+
without any method or attribute documentation.
83+
84+
For some classes we only want to document a subset of APIs. For those, the
85+
you should include an ``Attributes`` and ``Methods`` section in the class
86+
docstring. See ``CategoricalIndex`` for an example.
9187

9288
Every method should be included in a ``toctree`` in one of the documentation files in
93-
``doc/source/reference``, else Sphinx
94-
will emit a warning.
89+
``doc/source/reference``, otherwise Sphinx will emit a warning.
9590

9691
The utility script ``scripts/validate_docstrings.py`` can be used to get a csv
9792
summary of the API documentation. And also validate common errors in the docstring

doc/source/reference/arrays.rst

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ values.
104104

105105
.. autosummary::
106106
:toctree: api/
107-
:template: autosummary/class_without_autosummary.rst
108107

109108
arrays.ArrowExtensionArray
110109

111110
.. autosummary::
112111
:toctree: api/
113-
:template: autosummary/class_without_autosummary.rst
114112

115113
ArrowDtype
116114

@@ -233,13 +231,11 @@ If the data are timezone-aware, then every value in the array must have the same
233231

234232
.. autosummary::
235233
:toctree: api/
236-
:template: autosummary/class_without_autosummary.rst
237234

238235
arrays.DatetimeArray
239236

240237
.. autosummary::
241238
:toctree: api/
242-
:template: autosummary/class_without_autosummary.rst
243239

244240
DatetimeTZDtype
245241

@@ -299,7 +295,6 @@ A collection of :class:`Timedelta` may be stored in a :class:`TimedeltaArray`.
299295

300296
.. autosummary::
301297
:toctree: api/
302-
:template: autosummary/class_without_autosummary.rst
303298

304299
arrays.TimedeltaArray
305300

@@ -361,13 +356,11 @@ Every period in a :class:`arrays.PeriodArray` must have the same ``freq``.
361356

362357
.. autosummary::
363358
:toctree: api/
364-
:template: autosummary/class_without_autosummary.rst
365359

366360
arrays.PeriodArray
367361

368362
.. autosummary::
369363
:toctree: api/
370-
:template: autosummary/class_without_autosummary.rst
371364

372365
PeriodDtype
373366

@@ -404,13 +397,11 @@ A collection of intervals may be stored in an :class:`arrays.IntervalArray`.
404397

405398
.. autosummary::
406399
:toctree: api/
407-
:template: autosummary/class_without_autosummary.rst
408400

409401
arrays.IntervalArray
410402

411403
.. autosummary::
412404
:toctree: api/
413-
:template: autosummary/class_without_autosummary.rst
414405

415406
IntervalDtype
416407

@@ -449,13 +440,11 @@ pandas provides this through :class:`arrays.IntegerArray`.
449440

450441
.. autosummary::
451442
:toctree: api/
452-
:template: autosummary/class_without_autosummary.rst
453443

454444
arrays.IntegerArray
455445

456446
.. autosummary::
457447
:toctree: api/
458-
:template: autosummary/class_without_autosummary.rst
459448

460449
Int8Dtype
461450
Int16Dtype
@@ -474,13 +463,11 @@ Nullable float
474463

475464
.. autosummary::
476465
:toctree: api/
477-
:template: autosummary/class_without_autosummary.rst
478466

479467
arrays.FloatingArray
480468

481469
.. autosummary::
482470
:toctree: api/
483-
:template: autosummary/class_without_autosummary.rst
484471

485472
Float32Dtype
486473
Float64Dtype
@@ -497,7 +484,6 @@ a :class:`CategoricalDtype`.
497484

498485
.. autosummary::
499486
:toctree: api/
500-
:template: autosummary/class_without_autosummary.rst
501487

502488
CategoricalDtype
503489

@@ -511,7 +497,6 @@ Categorical data can be stored in a :class:`pandas.Categorical`
511497

512498
.. autosummary::
513499
:toctree: api/
514-
:template: autosummary/class_without_autosummary.rst
515500

516501
Categorical
517502

@@ -561,13 +546,11 @@ be stored efficiently as a :class:`arrays.SparseArray`.
561546

562547
.. autosummary::
563548
:toctree: api/
564-
:template: autosummary/class_without_autosummary.rst
565549

566550
arrays.SparseArray
567551

568552
.. autosummary::
569553
:toctree: api/
570-
:template: autosummary/class_without_autosummary.rst
571554

572555
SparseDtype
573556

@@ -586,14 +569,12 @@ we recommend using :class:`StringDtype` (with the alias ``"string"``).
586569

587570
.. autosummary::
588571
:toctree: api/
589-
:template: autosummary/class_without_autosummary.rst
590572

591573
arrays.StringArray
592574
arrays.ArrowStringArray
593575

594576
.. autosummary::
595577
:toctree: api/
596-
:template: autosummary/class_without_autosummary.rst
597578

598579
StringDtype
599580

@@ -612,13 +593,11 @@ with a bool :class:`numpy.ndarray`.
612593

613594
.. autosummary::
614595
:toctree: api/
615-
:template: autosummary/class_without_autosummary.rst
616596

617597
arrays.BooleanArray
618598

619599
.. autosummary::
620600
:toctree: api/
621-
:template: autosummary/class_without_autosummary.rst
622601

623602
BooleanDtype
624603
NA

doc/source/reference/extensions.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ objects.
2121

2222
.. autosummary::
2323
:toctree: api/
24-
:template: autosummary/class_without_autosummary.rst
2524

2625
api.extensions.ExtensionArray
2726
arrays.NumpyExtensionArray

doc/source/reference/groupby.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Indexing, iteration
2929

3030
.. autosummary::
3131
:toctree: api/
32-
:template: autosummary/class_without_autosummary.rst
3332

3433
Grouper
3534

doc/source/reference/indexing.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ Numeric Index
163163
-------------
164164
.. autosummary::
165165
:toctree: api/
166-
:template: autosummary/class_without_autosummary.rst
167166

168167
RangeIndex
169168

@@ -184,7 +183,6 @@ CategoricalIndex
184183
----------------
185184
.. autosummary::
186185
:toctree: api/
187-
:template: autosummary/class_without_autosummary.rst
188186

189187
CategoricalIndex
190188

@@ -219,7 +217,6 @@ IntervalIndex
219217
-------------
220218
.. autosummary::
221219
:toctree: api/
222-
:template: autosummary/class_without_autosummary.rst
223220

224221
IntervalIndex
225222

@@ -254,7 +251,6 @@ MultiIndex
254251

255252
.. autosummary::
256253
:toctree: api/
257-
:template: autosummary/class_without_autosummary.rst
258254

259255
MultiIndex
260256

@@ -321,7 +317,6 @@ DatetimeIndex
321317
-------------
322318
.. autosummary::
323319
:toctree: api/
324-
:template: autosummary/class_without_autosummary.rst
325320

326321
DatetimeIndex
327322

@@ -407,7 +402,6 @@ TimedeltaIndex
407402
--------------
408403
.. autosummary::
409404
:toctree: api/
410-
:template: autosummary/class_without_autosummary.rst
411405

412406
TimedeltaIndex
413407

@@ -449,7 +443,6 @@ PeriodIndex
449443
-----------
450444
.. autosummary::
451445
:toctree: api/
452-
:template: autosummary/class_without_autosummary.rst
453446

454447
PeriodIndex
455448

doc/source/reference/offset_frequency.rst

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Alias:
5656

5757
.. autosummary::
5858
:toctree: api/
59-
:template: autosummary/class_without_autosummary.rst
6059

6160
BDay
6261

@@ -143,7 +142,6 @@ Alias:
143142

144143
.. autosummary::
145144
:toctree: api/
146-
:template: autosummary/class_without_autosummary.rst
147145

148146
CDay
149147

@@ -300,7 +298,6 @@ Alias:
300298

301299
.. autosummary::
302300
:toctree: api/
303-
:template: autosummary/class_without_autosummary.rst
304301

305302
BMonthEnd
306303

@@ -344,7 +341,6 @@ Alias:
344341

345342
.. autosummary::
346343
:toctree: api/
347-
:template: autosummary/class_without_autosummary.rst
348344

349345
BMonthBegin
350346

@@ -388,7 +384,6 @@ Alias:
388384

389385
.. autosummary::
390386
:toctree: api/
391-
:template: autosummary/class_without_autosummary.rst
392387

393388
CBMonthEnd
394389

@@ -436,7 +431,6 @@ Alias:
436431

437432
.. autosummary::
438433
:toctree: api/
439-
:template: autosummary/class_without_autosummary.rst
440434

441435
CBMonthBegin
442436

0 commit comments

Comments
 (0)