Skip to content

Commit

Permalink
pythongh-109634: Use :samp: role (pythonGH-109635)
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka authored Sep 23, 2023
1 parent 5e7ea95 commit 92af0cc
Show file tree
Hide file tree
Showing 30 changed files with 99 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Doc/extending/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,4 @@ modules (including Python) to be able to see your identifiers, you have to say
Developer Studio will throw in a lot of import libraries that you do not really
need, adding about 100K to your executable. To get rid of them, use the Project
Settings dialog, Link tab, to specify *ignore default libraries*. Add the
correct :file:`msvcrtxx.lib` to the list of libraries.
correct :file:`msvcrt{xx}.lib` to the list of libraries.
4 changes: 2 additions & 2 deletions Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ when (and if) the logged message is actually about to be output to a log by a
handler. So the only slightly unusual thing which might trip you up is that the
parentheses go around the format string and the arguments, not just the format
string. That's because the __ notation is just syntax sugar for a constructor
call to one of the XXXMessage classes.
call to one of the :samp:`{XXX}Message` classes.

If you prefer, you can use a :class:`LoggerAdapter` to achieve a similar effect
to the above, as in the following example::
Expand Down Expand Up @@ -2644,7 +2644,7 @@ when (and if) the logged message is actually about to be output to a log by a
handler. So the only slightly unusual thing which might trip you up is that the
parentheses go around the format string and the arguments, not just the format
string. That’s because the __ notation is just syntax sugar for a constructor
call to one of the ``XXXMessage`` classes shown above.
call to one of the :samp:`{XXX}Message` classes shown above.


.. _filters-dictconfig:
Expand Down
2 changes: 1 addition & 1 deletion Doc/howto/logging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ provided:

#. :class:`NullHandler` instances do nothing with error messages. They are used
by library developers who want to use logging, but want to avoid the 'No
handlers could be found for logger XXX' message which can be displayed if
handlers could be found for logger *XXX*' message which can be displayed if
the library user has not configured logging. See :ref:`library-config` for
more information.

Expand Down
26 changes: 15 additions & 11 deletions Doc/library/codecs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,10 @@ The following error handlers can be used with all Python
+-------------------------+-----------------------------------------------+
| ``'backslashreplace'`` | Replace with backslashed escape sequences. |
| | On encoding, use hexadecimal form of Unicode |
| | code point with formats ``\xhh`` ``\uxxxx`` |
| | ``\Uxxxxxxxx``. On decoding, use hexadecimal |
| | form of byte value with format ``\xhh``. |
| | code point with formats :samp:`\\x{hh}` |
| | :samp:`\\u{xxxx}` :samp:`\\U{xxxxxxxx}`. |
| | On decoding, use hexadecimal form of byte |
| | value with format :samp:`\\x{hh}`. |
| | Implemented in |
| | :func:`backslashreplace_errors`. |
+-------------------------+-----------------------------------------------+
Expand All @@ -373,8 +374,9 @@ The following error handlers are only applicable to encoding (within
+=========================+===============================================+
| ``'xmlcharrefreplace'`` | Replace with XML/HTML numeric character |
| | reference, which is a decimal form of Unicode |
| | code point with format ``&#num;`` Implemented |
| | in :func:`xmlcharrefreplace_errors`. |
| | code point with format :samp:`&#{num};`. |
| | Implemented in |
| | :func:`xmlcharrefreplace_errors`. |
+-------------------------+-----------------------------------------------+
| ``'namereplace'`` | Replace with ``\N{...}`` escape sequences, |
| | what appears in the braces is the Name |
Expand Down Expand Up @@ -478,8 +480,9 @@ functions:

Malformed data is replaced by a backslashed escape sequence.
On encoding, use the hexadecimal form of Unicode code point with formats
``\xhh`` ``\uxxxx`` ``\Uxxxxxxxx``. On decoding, use the hexadecimal form of
byte value with format ``\xhh``.
:samp:`\\x{hh}` :samp:`\\u{xxxx}` :samp:`\\U{xxxxxxxx}`.
On decoding, use the hexadecimal form of
byte value with format :samp:`\\x{hh}`.

.. versionchanged:: 3.5
Works with decoding and translating.
Expand All @@ -492,7 +495,7 @@ functions:

The unencodable character is replaced by an appropriate XML/HTML numeric
character reference, which is a decimal form of Unicode code point with
format ``&#num;`` .
format :samp:`&#{num};` .


.. function:: namereplace_errors(exception)
Expand Down Expand Up @@ -1346,9 +1349,10 @@ encodings.
| | | supported. |
+--------------------+---------+---------------------------+
| raw_unicode_escape | | Latin-1 encoding with |
| | | ``\uXXXX`` and |
| | | ``\UXXXXXXXX`` for other |
| | | code points. Existing |
| | | :samp:`\\u{XXXX}` and |
| | | :samp:`\\U{XXXXXXXX}`` |
| | | for other code points. |
| | | Existing |
| | | backslashes are not |
| | | escaped in any way. |
| | | It is used in the Python |
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/compileall.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ compile Python sources.

Positional arguments are files to compile or directories that contain
source files, traversed recursively. If no argument is given, behave as if
the command line was ``-l <directories from sys.path>``.
the command line was :samp:`-l {<directories from sys.path>}`.

.. cmdoption:: -l

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/ensurepip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ By default, ``pip`` is installed into the current virtual environment
active virtual environment). The installation location can be controlled
through two additional command line options:

* ``--root <dir>``: Installs ``pip`` relative to the given root directory
* :samp:`--root {dir}`: Installs ``pip`` relative to the given root directory
rather than the root of the currently active virtual environment (if any)
or the default root for the current Python installation.
* ``--user``: Installs ``pip`` into the user site packages directory rather
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/functions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,7 @@ are always available. They are listed here in alphabetical order.

* ``'xmlcharrefreplace'`` is only supported when writing to a file.
Characters not supported by the encoding are replaced with the
appropriate XML character reference ``&#nnn;``.
appropriate XML character reference :samp:`&#{nnn};`.

* ``'backslashreplace'`` replaces malformed data by Python's backslashed
escape sequences.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/html.parser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ implementations do nothing (except for :meth:`~HTMLParser.handle_startendtag`):
.. method:: HTMLParser.handle_charref(name)

This method is called to process decimal and hexadecimal numeric character
references of the form ``&#NNN;`` and ``&#xNNN;``. For example, the decimal
references of the form :samp:`&#{NNN};` and :samp:`&#x{NNN};`. For example, the decimal
equivalent for ``&gt;`` is ``&#62;``, whereas the hexadecimal is ``&#x3E;``;
in this case the method will receive ``'62'`` or ``'x3E'``. This method
is never called if *convert_charrefs* is ``True``.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/http.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ provides three different variants:
attribute holds the default values for *message* and *explain* that
will be used if no value is provided; for unknown codes the default value
for both is the string ``???``. The body will be empty if the method is
HEAD or the response code is one of the following: ``1xx``,
HEAD or the response code is one of the following: :samp:`1{xx}`,
``204 No Content``, ``205 Reset Content``, ``304 Not Modified``.

.. versionchanged:: 3.4
Expand Down
4 changes: 2 additions & 2 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ startup by the :c:func:`PyConfig_Read` function: see
On some systems, conversion using the file system encoding may fail. In this
case, Python uses the :ref:`surrogateescape encoding error handler
<surrogateescape>`, which means that undecodable bytes are replaced by a
Unicode character U+DCxx on decoding, and these are again translated to the
original byte on encoding.
Unicode character U+DC\ *xx* on decoding, and these are again
translated to the original byte on encoding.


The :term:`file system encoding <filesystem encoding and error handler>` must
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/re.rst
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ three digits in length.
Unknown escapes consisting of ``'\'`` and an ASCII letter now are errors.

.. versionchanged:: 3.8
The ``'\N{name}'`` escape sequence has been added. As in string literals,
The :samp:`'\\N\\{{name}\\}'` escape sequence has been added. As in string literals,
it expands to the named Unicode character (e.g. ``'\N{EM DASH}'``).


Expand Down
4 changes: 2 additions & 2 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ always available.

Return the current value of the flags that are used for
:c:func:`dlopen` calls. Symbolic names for the flag values can be
found in the :mod:`os` module (``RTLD_xxx`` constants, e.g.
found in the :mod:`os` module (:samp:`RTLD_{xxx}` constants, e.g.
:const:`os.RTLD_LAZY`).

.. availability:: Unix.
Expand Down Expand Up @@ -1441,7 +1441,7 @@ always available.
lazy resolving of symbols when importing a module, if called as
``sys.setdlopenflags(0)``. To share symbols across extension modules, call as
``sys.setdlopenflags(os.RTLD_GLOBAL)``. Symbolic names for the flag values
can be found in the :mod:`os` module (``RTLD_xxx`` constants, e.g.
can be found in the :mod:`os` module (:samp:`RTLD_{xxx}` constants, e.g.
:const:`os.RTLD_LAZY`).

.. availability:: Unix.
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/urllib.parse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ task isn't already covered by the URL parsing functions above.

.. function:: quote(string, safe='/', encoding=None, errors=None)

Replace special characters in *string* using the ``%xx`` escape. Letters,
Replace special characters in *string* using the :samp:`%{xx}` escape. Letters,
digits, and the characters ``'_.-~'`` are never quoted. By default, this
function is intended for quoting the path section of a URL. The optional
*safe* parameter specifies additional ASCII characters that should not be
Expand Down Expand Up @@ -645,7 +645,7 @@ task isn't already covered by the URL parsing functions above.

.. function:: unquote(string, encoding='utf-8', errors='replace')

Replace ``%xx`` escapes with their single-character equivalent.
Replace :samp:`%{xx}` escapes with their single-character equivalent.
The optional *encoding* and *errors* parameters specify how to decode
percent-encoded sequences into Unicode characters, as accepted by the
:meth:`bytes.decode` method.
Expand Down Expand Up @@ -676,7 +676,7 @@ task isn't already covered by the URL parsing functions above.

.. function:: unquote_to_bytes(string)

Replace ``%xx`` escapes with their single-octet equivalent, and return a
Replace :samp:`%{xx}` escapes with their single-octet equivalent, and return a
:class:`bytes` object.

*string* may be either a :class:`str` or a :class:`bytes` object.
Expand Down
84 changes: 42 additions & 42 deletions Doc/reference/lexical_analysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -557,51 +557,51 @@ Unless an ``'r'`` or ``'R'`` prefix is present, escape sequences in string and
bytes literals are interpreted according to rules similar to those used by
Standard C. The recognized escape sequences are:

+-----------------+---------------------------------+-------+
| Escape Sequence | Meaning | Notes |
+=================+=================================+=======+
| ``\``\ <newline>| Backslash and newline ignored | \(1) |
+-----------------+---------------------------------+-------+
| ``\\`` | Backslash (``\``) | |
+-----------------+---------------------------------+-------+
| ``\'`` | Single quote (``'``) | |
+-----------------+---------------------------------+-------+
| ``\"`` | Double quote (``"``) | |
+-----------------+---------------------------------+-------+
| ``\a`` | ASCII Bell (BEL) | |
+-----------------+---------------------------------+-------+
| ``\b`` | ASCII Backspace (BS) | |
+-----------------+---------------------------------+-------+
| ``\f`` | ASCII Formfeed (FF) | |
+-----------------+---------------------------------+-------+
| ``\n`` | ASCII Linefeed (LF) | |
+-----------------+---------------------------------+-------+
| ``\r`` | ASCII Carriage Return (CR) | |
+-----------------+---------------------------------+-------+
| ``\t`` | ASCII Horizontal Tab (TAB) | |
+-----------------+---------------------------------+-------+
| ``\v`` | ASCII Vertical Tab (VT) | |
+-----------------+---------------------------------+-------+
| ``\ooo`` | Character with octal value | (2,4) |
| | *ooo* | |
+-----------------+---------------------------------+-------+
| ``\xhh`` | Character with hex value *hh* | (3,4) |
+-----------------+---------------------------------+-------+
+-------------------------+---------------------------------+-------+
| Escape Sequence | Meaning | Notes |
+=========================+=================================+=======+
| ``\``\ <newline> | Backslash and newline ignored | \(1) |
+-------------------------+---------------------------------+-------+
| ``\\`` | Backslash (``\``) | |
+-------------------------+---------------------------------+-------+
| ``\'`` | Single quote (``'``) | |
+-------------------------+---------------------------------+-------+
| ``\"`` | Double quote (``"``) | |
+-------------------------+---------------------------------+-------+
| ``\a`` | ASCII Bell (BEL) | |
+-------------------------+---------------------------------+-------+
| ``\b`` | ASCII Backspace (BS) | |
+-------------------------+---------------------------------+-------+
| ``\f`` | ASCII Formfeed (FF) | |
+-------------------------+---------------------------------+-------+
| ``\n`` | ASCII Linefeed (LF) | |
+-------------------------+---------------------------------+-------+
| ``\r`` | ASCII Carriage Return (CR) | |
+-------------------------+---------------------------------+-------+
| ``\t`` | ASCII Horizontal Tab (TAB) | |
+-------------------------+---------------------------------+-------+
| ``\v`` | ASCII Vertical Tab (VT) | |
+-------------------------+---------------------------------+-------+
| :samp:`\\{ooo}` | Character with octal value | (2,4) |
| | *ooo* | |
+-------------------------+---------------------------------+-------+
| :samp:`\\x{hh}` | Character with hex value *hh* | (3,4) |
+-------------------------+---------------------------------+-------+

Escape sequences only recognized in string literals are:

+-----------------+---------------------------------+-------+
| Escape Sequence | Meaning | Notes |
+=================+=================================+=======+
| ``\N{name}`` | Character named *name* in the | \(5) |
| | Unicode database | |
+-----------------+---------------------------------+-------+
| ``\uxxxx`` | Character with 16-bit hex value | \(6) |
| | *xxxx* | |
+-----------------+---------------------------------+-------+
| ``\Uxxxxxxxx`` | Character with 32-bit hex value | \(7) |
| | *xxxxxxxx* | |
+-----------------+---------------------------------+-------+
+-------------------------+---------------------------------+-------+
| Escape Sequence | Meaning | Notes |
+=========================+=================================+=======+
| :samp:`\\N\\{{name}\\}` | Character named *name* in the | \(5) |
| | Unicode database | |
+-------------------------+---------------------------------+-------+
| :samp:`\\u{xxxx}` | Character with 16-bit hex value | \(6) |
| | *xxxx* | |
+-------------------------+---------------------------------+-------+
| :samp:`\\U{xxxxxxxx}` | Character with 32-bit hex value | \(7) |
| | *xxxxxxxx* | |
+-------------------------+---------------------------------+-------+

Notes:

Expand Down
10 changes: 5 additions & 5 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ differently depending if the ``Py_BUILD_CORE_MODULE`` macro is defined:
* Use ``Py_IMPORTED_SYMBOL`` otherwise.

If the ``Py_BUILD_CORE_BUILTIN`` macro is used by mistake on a C extension
built as a shared library, its ``PyInit_xxx()`` function is not exported,
built as a shared library, its :samp:`PyInit_{xxx}()` function is not exported,
causing an :exc:`ImportError` on import.


Expand All @@ -1033,8 +1033,8 @@ Preprocessor flags

.. envvar:: CPPFLAGS

(Objective) C/C++ preprocessor flags, e.g. ``-I<include dir>`` if you have
headers in a nonstandard directory ``<include dir>``.
(Objective) C/C++ preprocessor flags, e.g. :samp:`-I{include_dir}` if you have
headers in a nonstandard directory *include_dir*.

Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
value to be able to build extension modules using the
Expand Down Expand Up @@ -1223,8 +1223,8 @@ Linker flags

.. envvar:: LDFLAGS

Linker flags, e.g. ``-L<lib dir>`` if you have libraries in a nonstandard
directory ``<lib dir>``.
Linker flags, e.g. :samp:`-L{lib_dir}` if you have libraries in a nonstandard
directory *lib_dir*.

Both :envvar:`CPPFLAGS` and :envvar:`LDFLAGS` need to contain the shell's
value to be able to build extension modules using the
Expand Down
4 changes: 2 additions & 2 deletions Doc/using/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ minor version. I.e. ``/usr/bin/python3.7-32`` will request usage of the

The "-64" suffix is deprecated, and now implies "any architecture that is
not provably i386/32-bit". To request a specific environment, use the new
``-V:<TAG>`` argument with the complete tag.
:samp:`-V:{TAG}` argument with the complete tag.

The ``/usr/bin/env`` form of shebang line has one further special property.
Before looking for installed Python interpreters, this form will search the
Expand Down Expand Up @@ -1192,7 +1192,7 @@ non-standard paths in the registry and user site-packages.

* Adds ``._pth`` file support and removes ``applocal`` option from
``pyvenv.cfg``.
* Adds ``pythonXX.zip`` as a potential landmark when directly adjacent
* Adds :file:`python{XX}.zip` as a potential landmark when directly adjacent
to the executable.

.. deprecated::
Expand Down
4 changes: 2 additions & 2 deletions Doc/whatsnew/2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ Lundh. A detailed explanation of the interface was written up as :pep:`100`,
significant points about the Unicode interfaces.

In Python source code, Unicode strings are written as ``u"string"``. Arbitrary
Unicode characters can be written using a new escape sequence, ``\uHHHH``, where
Unicode characters can be written using a new escape sequence, :samp:`\\u{HHHH}`, where
*HHHH* is a 4-digit hexadecimal number from 0000 to FFFF. The existing
``\xHHHH`` escape sequence can also be used, and octal escapes can be used for
:samp:`\\x{HH}` escape sequence can also be used, and octal escapes can be used for
characters up to U+01FF, which is represented by ``\777``.

Unicode strings, just like regular strings, are an immutable sequence type.
Expand Down
Loading

0 comments on commit 92af0cc

Please sign in to comment.