(fn)
| 19 | |
| 20 | def replace_example_docstring(example_docstring): |
| 21 | def docstring_decorator(fn): |
| 22 | func_doc = fn.__doc__ |
| 23 | lines = func_doc.split("\n") |
| 24 | i = 0 |
| 25 | while i < len(lines) and re.search(r"^\s*Examples?:\s*$", lines[i]) is None: |
| 26 | i += 1 |
| 27 | if i < len(lines): |
| 28 | lines[i] = example_docstring |
| 29 | func_doc = "\n".join(lines) |
| 30 | else: |
| 31 | raise ValueError( |
| 32 | f"The function {fn} should have an empty 'Examples:' in its docstring as placeholder, " |
| 33 | f"current docstring is:\n{func_doc}" |
| 34 | ) |
| 35 | fn.__doc__ = func_doc |
| 36 | return fn |
| 37 | |
| 38 | return docstring_decorator |
nothing calls this directly
no outgoing calls
no test coverage detected