Add a rstripped line to the current docstring.
(self, obj: Function | Parameter, line: str)
| 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. |
no test coverage detected