diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-01-09 02:53:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-09 02:53:59 (GMT) |
commit | 3958c7d712b2cb32cb649eee7391d8a431a9cfa9 (patch) | |
tree | 535b159251675ef622054ff8200168ec748050ee | |
parent | 73573352fc4489ab3ded61f9a55965d9913de1f5 (diff) | |
download | cpython-3958c7d712b2cb32cb649eee7391d8a431a9cfa9.zip cpython-3958c7d712b2cb32cb649eee7391d8a431a9cfa9.tar.gz cpython-3958c7d712b2cb32cb649eee7391d8a431a9cfa9.tar.bz2 |
[3.11] Docs: Link tokens in the format string grammars (GH-108184) (#113840)
Docs: Link tokens in the format string grammars (GH-108184)
(cherry picked from commit f3d5d4aa8f0388217aeff69e28d078bdda464b38)
Co-authored-by: William Andrea <william.j.andrea@gmail.com>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
-rw-r--r-- | Doc/library/string.rst | 14 | ||||
-rw-r--r-- | Doc/tools/.nitignore | 1 | ||||
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 5 |
3 files changed, 12 insertions, 8 deletions
diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 5fbd82a..5fe9d92 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -208,13 +208,13 @@ The grammar for a replacement field is as follows: .. productionlist:: format-string replacement_field: "{" [`field_name`] ["!" `conversion`] [":" `format_spec`] "}" - field_name: arg_name ("." `attribute_name` | "[" `element_index` "]")* - arg_name: [`identifier` | `digit`+] - attribute_name: `identifier` - element_index: `digit`+ | `index_string` + field_name: `arg_name` ("." `attribute_name` | "[" `element_index` "]")* + arg_name: [`~python-grammar:identifier` | `~python-grammar:digit`+] + attribute_name: `~python-grammar:identifier` + element_index: `~python-grammar:digit`+ | `index_string` index_string: <any source character except "]"> + conversion: "r" | "s" | "a" - format_spec: <described in the next section> + format_spec: `format-spec:format_spec` In less formal terms, the replacement field can start with a *field_name* that specifies the object whose value is to be formatted and inserted @@ -316,9 +316,9 @@ The general form of a *standard format specifier* is: fill: <any character> align: "<" | ">" | "=" | "^" sign: "+" | "-" | " " - width: `digit`+ + width: `~python-grammar:digit`+ grouping_option: "_" | "," - precision: `digit`+ + precision: `~python-grammar:digit`+ type: "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%" If a valid *align* value is specified, it can be preceded by a *fill* diff --git a/Doc/tools/.nitignore b/Doc/tools/.nitignore index 69e00cb..0d0d070 100644 --- a/Doc/tools/.nitignore +++ b/Doc/tools/.nitignore @@ -80,7 +80,6 @@ Doc/library/smtplib.rst Doc/library/socket.rst Doc/library/ssl.rst Doc/library/stdtypes.rst -Doc/library/string.rst Doc/library/subprocess.rst Doc/library/syslog.rst Doc/library/termios.rst diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 31c42e9..c849a4d 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -53,6 +53,11 @@ Body.enum.converters['loweralpha'] = \ Body.enum.converters['lowerroman'] = \ Body.enum.converters['upperroman'] = lambda x: None +# monkey-patch the productionlist directive to allow hyphens in group names +# https://github.com/sphinx-doc/sphinx/issues/11854 +from sphinx.domains import std + +std.token_re = re.compile(r'`((~?[\w-]*:)?\w+)`') # Support for marking up and linking to bugs.python.org issues |