Skip to content

Commit ae9cf92

Browse files
committed
add new decorator for replacing docstring sections
1 parent 3014085 commit ae9cf92

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

fooof/core/modutils.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,26 @@ def wrapper(func):
297297
return func
298298

299299
return wrapper
300+
301+
302+
def replace_docstring_sections(replacements):
303+
"""Decorator to drop in docstring sections
304+
305+
Parameters
306+
----------
307+
replacements : str or list of str
308+
Section(s) to drop into the decorated function's docstring.
309+
"""
310+
311+
def wrapper(func):
312+
313+
docstring = func.__doc__
314+
315+
for replacement in [replacements] if isinstance(replacements, str) else replacements:
316+
docstring = docs_add_section(docstring, replacement)
317+
318+
func.__doc__ = docstring
319+
320+
return func
321+
322+
return wrapper

0 commit comments

Comments
 (0)