8000 Fix doc building with numpydoc 0.9 · matplotlib/matplotlib@6f4058b · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f4058b

Browse files
committed
Fix doc building with numpydoc 0.9
1 parent 44952ed commit 6f4058b

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

lib/matplotlib/__init__.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,12 @@ def _label_from_arg(y, default_name):
14501450
return None
14511451

14521452

1453+
_DATA_DOC_TITLE = """
1454+
1455+
Notes
1456+
-----
1457+
"""
1458+
14531459
_DATA_DOC_APPENDIX = """
14541460
14551461
.. note::
@@ -1487,7 +1493,10 @@ def _add_data_doc(docstring, replace_names):
14871493
if len(replace_names) == 0 else
14881494
"* All arguments with the following names: {}.".format(
14891495
", ".join(map(repr, sorted(replace_names)))))
1490-
return docstring + _DATA_DOC_APPENDIX.format(replaced=repl)
1496+
addendum = _DATA_DOC_APPENDIX.format(replaced=repl)
1497+
if _DATA_DOC_TITLE not in docstring:
1498+
addendum = _DATA_DOC_TITLE + addendum
1499+
return docstring + addendum
14911500

14921501

14931502
def _preprocess_data(func=None, *, replace_names=None, label_namer=None):

lib/matplotlib/cbook/deprecation.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,15 @@ def wrapper(*args, **kwargs):
249249
old_doc = inspect.cleandoc(old_doc or '').strip('\n')
250250

251251
message = message.strip()
252-
new_doc = ('[*Deprecated*] {old_doc}\n'
253-
'\n'
254-
'.. deprecated:: {since}\n'
255-
' {message}'
256-
.format(since=since, message=message, old_doc=old_doc))
252+
# Add "Deprecated" to top of docstring
253+
new_doc = '[*Deprecated*] {old_doc}\n\n'.format(old_doc=old_doc)
254+
# Add a notes section if one isn't already present
255+
note_section = 'Notes\n-----'
256+
if note_section not in new_doc:
257+
new_doc += note_section
258+
# Add deprecated message
259+
new_doc += ('\n.. deprecated:: {since}\n'
260+
' {message}'.format(since=since, message=message))
257261
if not old_doc:
258262
# This is to prevent a spurious 'unexpected unindent' warning from
259263
# docutils when the original docstring was blank.

requirements/doc/doc-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ sphinx>=1.8.1,<2.0.0
1111
colorspacious
1212
ipython
1313
ipywidgets
14-
numpydoc>=0.8,<0.9
14+
numpydoc>=0.8
1515
pillow>=3.4,!=5.4.0
1616
sphinx-gallery>=0.2
1717
sphinx-copybutton

0 commit comments

Comments
 (0)
0