Skip to content

Commit ced8810

Browse files
committed
More compact doc formatting
1 parent 93e873b commit ced8810

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/matplotlib/cbook/deprecation.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,12 @@ def wrapper(*args, **kwargs):
248248

249249
old_doc = inspect.cleandoc(old_doc or '').strip('\n')
250250

251-
message = message.strip()
252-
# Add "Deprecated" to top of docstring
253-
new_doc = '[*Deprecated*] {old_doc}\n'.format(old_doc=old_doc)
254-
# Add a notes section if one isn't already present
255-
note_section = '\nNotes\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))
251+
notes_header = '\nNotes\n-----'
252+
new_doc = (f"[*Deprecated*] {old_doc}\n"
253+
f"{notes_header if notes_header not in old_doc else ''}\n"
254+
f".. deprecated:: {since}\n"
255+
f" {message.strip()}")
256+
261257
if not old_doc:
262258
# This is to prevent a spurious 'unexpected unindent' warning from
263259
# docutils when the original docstring was blank.

0 commit comments

Comments
 (0)