MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / replace_example_docstring

Function replace_example_docstring

src/diffusers/utils/doc_utils.py:20–38  ·  view source on GitHub ↗
(example_docstring)

Source from the content-addressed store, hash-verified

18
19
20def 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected