@@ -303,6 +303,28 @@ def _process_literal_blocks(md_text):
303
303
"Yields" ,
304
304
)
305
305
306
+ # Sourced from docutils.parsers.rst.directives._directive_registry.keys()
307
+ # and from https://docutils.sourceforge.io/docs/ref/rst/directives.html
308
+ # We hardcode a subset of this list as there is no public API in docutils
309
+ # or Sphinx to get this information directly.
310
+ # See https://docutils.sourceforge.io/docs/ref/rst/directives.html
311
+ #
312
+ # This subset is only a list of sensible defaults and widely used directives
313
+ # based on our discretion that can signify the start of a new section in a
314
+ # docstring and is not meant to be exhaustive.
315
+ _irrelevant_directives = [
316
+ "class" ,
317
+ "contents" ,
318
+ "epigraph" ,
319
+ "footer" ,
320
+ "header" ,
321
+ "highlights" ,
322
+ "parsed-literal" ,
323
+ "pull-quote" ,
324
+ "seealso" ,
325
+ "sidebar" ,
326
+ "topic" ,
327
+ ]
306
328
307
329
_examples_start_pattern = re .compile (r".. (rubric|admonition):: Examples" )
308
330
_next_section_pattern = re .compile (
@@ -315,10 +337,10 @@ def _process_literal_blocks(md_text):
315
337
+ [r"\!\! processed by numpydoc \!\!" ]
316
338
# Attributes section sometimes has no directive.
317
339
+ [r":Attributes:" ]
318
- # The See Also section shows up for old numpydoc versions such as that
319
- # of SymPy where it is accounted for as an admonition and not a rubric,
320
- # therefore we check for it as a special case for now .
321
- + [r "\.\. seealso ::" ]
340
+ # Directives that can start a new section in a docstring and are
341
+ # not handled by numpydoc in terms of reordering. Noticed in SymPy
342
+ # as it does not use modern numpydoc at the time of writing .
343
+ + [rf "\.\. ( { directive } ) ::" for directive in _irrelevant_directives ]
322
344
)
323
345
)
324
346
0 commit comments