MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / replace_example_docstring

Function replace_example_docstring

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected