Skip to content

rest: unescape field names - #183

Merged
rr- merged 1 commit into
mainfrom
rework/41-rest-escapes
Nov 7, 2026
Merged

rr- merged 1 commit into
mainfrom
rework/41-rest-escapes

Conversation

@rr-

@rr- rr- commented Nov 7, 2026

Copy link
Copy Markdown
Owner

ReST field names now drop their backslash escapes, as docutils reads them: :param \*\*kwargs: gives the name **kwargs instead of \*\*kwargs. This applies to the name in :param:-style fields, :type x:/:vartype x: (so the type still finds its param) and :rtype name:/:ytype name:.

Compose escapes \ and * in names again, so **kwargs is written as :param \*\*kwargs:. That reads back the same, and it is what Sphinx wants, since a bare **kwargs in a field name is an unclosed strong-emphasis start. It also means a Google or Numpydoc docstring with *args now composes to ReST as \*args.

Types, and names in .. attribute:: directives, are left as they were.

Case diffs: 13 requests corpus cases (requests.api.* and Session.*) now name **kwargs instead of \*\*kwargs. New case rest/escaped_names_01.txt covers params, a type field, a literal backslash and an rtype name, parsed and composed.

Parity against origin/main: 38 of 29184 docstrings differ, case 32, generated 6. The generated ones only change in ReST compose, where a name with * is now escaped. No docstring parses only in base, so no stdlib docstring newly makes strict parse raise.

A backslash escape in a field's name, as in ":param \*\*kwargs:", was
kept in the name. Drop it as docutils does, so the name is "**kwargs",
in param, type and rtype fields alike. Compose escapes backslashes and
asterisks in names again, which reads back the same and is what Sphinx
expects.
@rr- rr- self-assigned this Nov 7, 2026
@rr-
rr- merged commit c0ee7ef into main Nov 7, 2026
26 checks passed
@rr-
rr- deleted the rework/41-rest-escapes branch November 7, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant