MCPcopy Index your code
hub / github.com/python/cpython / docstring_append

Method docstring_append

Tools/clinic/libclinic/dsl_parser.py:1288–1305  ·  view source on GitHub ↗

Add a rstripped line to the current docstring.

(self, obj: Function | Parameter, line: str)

Source from the content-addressed store, hash-verified

1286 return self.next(self.state_parameter_docstring, line)
1287
1288 def docstring_append(self, obj: Function | Parameter, line: str) -> None:
1289 """Add a rstripped line to the current docstring."""
1290 # gh-80282: We filter out non-ASCII characters from the docstring,
1291 # since historically, some compilers may balk on non-ASCII input.
1292 # If you're using Argument Clinic in an external project,
1293 # you may not need to support the same array of platforms as CPython,
1294 # so you may be able to remove this restriction.
1295 matches = re.finditer(r'[^\x00-\x7F]', line)
1296 if offending := ", ".join([repr(m[0]) for m in matches]):
1297 warn("Non-ascii characters are not allowed in docstrings:",
1298 offending)
1299
1300 docstring = obj.docstring
1301 if docstring:
1302 docstring += "\n"
1303 if stripped := line.rstrip():
1304 docstring += self.indent.dedent(stripped)
1305 obj.docstring = docstring
1306
1307 # every line of the docstring must start with at least F spaces,
1308 # where F > P.

Callers 2

Calls 4

warnFunction · 0.90
joinMethod · 0.45
rstripMethod · 0.45
dedentMethod · 0.45

Tested by

no test coverage detected