Skip to content

Commit 5af34d2

Browse files
miss-islingtonerlend-aaslandAlexWaygoodAA-Turner
authored
[3.11] Docs: Fix Sphinx warnings in sys.rst (GH-108106) (#108166)
Docs: Fix Sphinx warnings in sys.rst (GH-108106) - Mark up named tuple attributes as attributes - Remove links for external functions - io.BufferedIOBase has no 'buffer' attribute; remove the link and mark up using :attr:`!buffer` - (Re)format some tables as bullet lists: - sys._emscripten_info - sys.hash_info - sys.int_info - sys.thread_info - In the paragraphs mentioning 'f_trace_lines' and 'f_trace_opcodes', add links to the frame objects reference. (cherry picked from commit 29fa7af) Co-authored-by: Erlend E. Aasland <[email protected]> Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent ba63706 commit 5af34d2

File tree

3 files changed

+153
-115
lines changed

3 files changed

+153
-115
lines changed

Doc/library/sys.rst

Lines changed: 152 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -329,23 +329,21 @@ always available.
329329
*wasm32-emscripten* platform. The named tuple is provisional and may change
330330
in the future.
331331

332-
.. tabularcolumns:: |l|L|
333-
334-
+-----------------------------+----------------------------------------------+
335-
| Attribute | Explanation |
336-
+=============================+==============================================+
337-
| :const:`emscripten_version` | Emscripten version as tuple of ints |
338-
| | (major, minor, micro), e.g. ``(3, 1, 8)``. |
339-
+-----------------------------+----------------------------------------------+
340-
| :const:`runtime` | Runtime string, e.g. browser user agent, |
341-
| | ``'Node.js v14.18.2'``, or ``'UNKNOWN'``. |
342-
+-----------------------------+----------------------------------------------+
343-
| :const:`pthreads` | ``True`` if Python is compiled with |
344-
| | Emscripten pthreads support. |
345-
+-----------------------------+----------------------------------------------+
346-
| :const:`shared_memory` | ``True`` if Python is compiled with shared |
347-
| | memory support. |
348-
+-----------------------------+----------------------------------------------+
332+
.. attribute:: _emscripten_info.emscripten_version
333+
334+
Emscripten version as tuple of ints (major, minor, micro), e.g. ``(3, 1, 8)``.
335+
336+
.. attribute:: _emscripten_info.runtime
337+
338+
Runtime string, e.g. browser user agent, ``'Node.js v14.18.2'``, or ``'UNKNOWN'``.
339+
340+
.. attribute:: _emscripten_info.pthreads
341+
342+
``True`` if Python is compiled with Emscripten pthreads support.
343+
344+
.. attribute:: _emscripten_info.shared_memory
345+
346+
``True`` if Python is compiled with shared memory support.
349347

350348
.. availability:: Emscripten.
351349

@@ -511,28 +509,62 @@ always available.
511509
The :term:`named tuple` *flags* exposes the status of command line
512510
flags. The attributes are read only.
513511

514-
============================== ==============================================================================================================
515-
attribute flag
516-
============================== ==============================================================================================================
517-
:const:`debug` :option:`-d`
518-
:const:`inspect` :option:`-i`
519-
:const:`interactive` :option:`-i`
520-
:const:`isolated` :option:`-I`
521-
:const:`optimize` :option:`-O` or :option:`-OO`
522-
:const:`dont_write_bytecode` :option:`-B`
523-
:const:`no_user_site` :option:`-s`
524-
:const:`no_site` :option:`-S`
525-
:const:`ignore_environment` :option:`-E`
526-
:const:`verbose` :option:`-v`
527-
:const:`bytes_warning` :option:`-b`
528-
:const:`quiet` :option:`-q`
529-
:const:`hash_randomization` :option:`-R`
530-
:const:`dev_mode` :option:`-X dev <-X>` (:ref:`Python Development Mode <devmode>`)
531-
:const:`utf8_mode` :option:`-X utf8 <-X>`
532-
:const:`safe_path` :option:`-P`
533-
:const:`int_max_str_digits` :option:`-X int_max_str_digits <-X>` (:ref:`integer string conversion length limitation <int_max_str_digits>`)
534-
:const:`warn_default_encoding` :option:`-X warn_default_encoding <-X>`
535-
============================== ==============================================================================================================
512+
.. list-table::
513+
514+
* - .. attribute:: flags.debug
515+
- :option:`-d`
516+
517+
* - .. attribute:: flags.inspect
518+
- :option:`-i`
519+
520+
* - .. attribute:: flags.interactive
521+
- :option:`-i`
522+
523+
* - .. attribute:: flags.isolated
524+
- :option:`-I`
525+
526+
* - .. attribute:: flags.optimize
527+
- :option:`-O` or :option:`-OO`
528+
529+
* - .. attribute:: flags.dont_write_bytecode
530+
- :option:`-B`
531+
532+
* - .. attribute:: flags.no_user_site
533+
- :option:`-s`
534+
535+
* - .. attribute:: flags.no_site
536+
- :option:`-S`
537+
538+
* - .. attribute:: flags.ignore_environment
539+
- :option:`-E`
540+
541+
* - .. attribute:: flags.verbose
542+
- :option:`-v`
543+
544+
* - .. attribute:: flags.bytes_warning
545+
- :option:`-b`
546+
547+
* - .. attribute:: flags.quiet
548+
- :option:`-q`
549+
550+
* - .. attribute:: flags.hash_randomization
551+
- :option:`-R`
552+
553+
* - .. attribute:: flags.dev_mode
554+
- :option:`-X dev <-X>` (:ref:`Python Development Mode <devmode>`)
555+
556+
* - .. attribute:: flags.utf8_mode
557+
- :option:`-X utf8 <-X>`
558+
559+
* - .. attribute:: flags.safe_path
560+
- :option:`-P`
561+
562+
* - .. attribute:: flags.int_max_str_digits
563+
- :option:`-X int_max_str_digits <-X>`
564+
(:ref:`integer string conversion length limitation <int_max_str_digits>`)
565+
566+
* - .. attribute:: flags.warn_default_encoding
567+
- :option:`-X warn_default_encoding <-X>`
536568

537569
.. versionchanged:: 3.2
538570
Added ``quiet`` attribute for the new :option:`-q` flag.
@@ -890,8 +922,8 @@ always available.
890922
| | a domain controller. |
891923
+---------------------------------------+---------------------------------+
892924

893-
This function wraps the Win32 :c:func:`GetVersionEx` function; see the
894-
Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information
925+
This function wraps the Win32 :c:func:`!GetVersionEx` function; see the
926+
Microsoft documentation on :c:func:`!OSVERSIONINFOEX` for more information
895927
about these fields.
896928

897929
*platform_version* returns the major version, minor version and
@@ -949,28 +981,37 @@ always available.
949981
implementation. For more details about hashing of numeric types, see
950982
:ref:`numeric-hash`.
951983

952-
+---------------------+--------------------------------------------------+
953-
| attribute | explanation |
954-
+=====================+==================================================+
955-
| :const:`width` | width in bits used for hash values |
956-
+---------------------+--------------------------------------------------+
957-
| :const:`modulus` | prime modulus P used for numeric hash scheme |
958-
+---------------------+--------------------------------------------------+
959-
| :const:`inf` | hash value returned for a positive infinity |
960-
+---------------------+--------------------------------------------------+
961-
| :const:`nan` | (this attribute is no longer used) |
962-
+---------------------+--------------------------------------------------+
963-
| :const:`imag` | multiplier used for the imaginary part of a |
964-
| | complex number |
965-
+---------------------+--------------------------------------------------+
966-
| :const:`algorithm` | name of the algorithm for hashing of str, bytes, |
967-
| | and memoryview |
968-
+---------------------+--------------------------------------------------+
969-
| :const:`hash_bits` | internal output size of the hash algorithm |
970-
+---------------------+--------------------------------------------------+
971-
| :const:`seed_bits` | size of the seed key of the hash algorithm |
972-
+---------------------+--------------------------------------------------+
984+
.. attribute:: hash_info.width
985+
986+
The width in bits used for hash values
987+
988+
.. attribute:: hash_info.modulus
973989

990+
The prime modulus P used for numeric hash scheme
991+
992+
.. attribute:: hash_info.inf
993+
994+
The hash value returned for a positive infinity
995+
996+
.. attribute:: hash_info.nan
997+
998+
(This attribute is no longer used)
999+
1000+
.. attribute:: hash_info.imag
1001+
1002+
The multiplier used for the imaginary part of a complex number
1003+
1004+
.. attribute:: hash_info.algorithm
1005+
1006+
The name of the algorithm for hashing of str, bytes, and memoryview
1007+
1008+
.. attribute:: hash_info.hash_bits
1009+
1010+
The internal output size of the hash algorithm
1011+
1012+
.. attribute:: hash_info.seed_bits
1013+
1014+
The size of the seed key of the hash algorithm
9741015

9751016
.. versionadded:: 3.2
9761017

@@ -1048,32 +1089,31 @@ always available.
10481089
A :term:`named tuple` that holds information about Python's internal
10491090
representation of integers. The attributes are read only.
10501091

1051-
.. tabularcolumns:: |l|L|
1052-
1053-
+----------------------------------------+-----------------------------------------------+
1054-
| Attribute | Explanation |
1055-
+========================================+===============================================+
1056-
| :const:`bits_per_digit` | number of bits held in each digit. Python |
1057-
| | integers are stored internally in base |
1058-
| | ``2**int_info.bits_per_digit`` |
1059-
+----------------------------------------+-----------------------------------------------+
1060-
| :const:`sizeof_digit` | size in bytes of the C type used to |
1061-
| | represent a digit |
1062-
+----------------------------------------+-----------------------------------------------+
1063-
| :const:`default_max_str_digits` | default value for |
1064-
| | :func:`sys.get_int_max_str_digits` when it |
1065-
| | is not otherwise explicitly configured. |
1066-
+----------------------------------------+-----------------------------------------------+
1067-
| :const:`str_digits_check_threshold` | minimum non-zero value for |
1068-
| | :func:`sys.set_int_max_str_digits`, |
1069-
| | :envvar:`PYTHONINTMAXSTRDIGITS`, or |
1070-
| | :option:`-X int_max_str_digits <-X>`. |
1071-
+----------------------------------------+-----------------------------------------------+
1092+
.. attribute:: int_info.bits_per_digit
1093+
1094+
The number of bits held in each digit.
1095+
Python integers are stored internally in base ``2**int_info.bits_per_digit``.
1096+
1097+
.. attribute:: int_info.sizeof_digit
1098+
1099+
The size in bytes of the C type used to represent a digit.
1100+
1101+
.. attribute:: int_info.default_max_str_digits
1102+
1103+
The default value for :func:`sys.get_int_max_str_digits`
1104+
when it is not otherwise explicitly configured.
1105+
1106+
.. attribute:: int_info.str_digits_check_threshold
1107+
1108+
The minimum non-zero value for :func:`sys.set_int_max_str_digits`,
1109+
:envvar:`PYTHONINTMAXSTRDIGITS`, or :option:`-X int_max_str_digits <-X>`.
10721110

10731111
.. versionadded:: 3.1
10741112

10751113
.. versionchanged:: 3.11
1076-
Added ``default_max_str_digits`` and ``str_digits_check_threshold``.
1114+
1115+
Added :attr:`~int_info.default_max_str_digits` and
1116+
:attr:`~int_info.str_digits_check_threshold`.
10771117

10781118

10791119
.. data:: __interactivehook__
@@ -1501,7 +1541,7 @@ always available.
15011541
:file:`Objects/lnotab_notes.txt` for a detailed explanation of how this
15021542
works.
15031543
Per-line events may be disabled for a frame by setting
1504-
:attr:`f_trace_lines` to :const:`False` on that frame.
1544+
:attr:`!f_trace_lines` to :const:`False` on that :ref:`frame <frame-objects>`.
15051545

15061546
``'return'``
15071547
A function (or other code block) is about to return. The local trace
@@ -1519,8 +1559,8 @@ always available.
15191559
opcode details). The local trace function is called; *arg* is
15201560
``None``; the return value specifies the new local trace function.
15211561
Per-opcode events are not emitted by default: they must be explicitly
1522-
requested by setting :attr:`f_trace_opcodes` to :const:`True` on the
1523-
frame.
1562+
requested by setting :attr:`!f_trace_opcodes` to :const:`True` on the
1563+
:ref:`frame <frame-objects>`.
15241564

15251565
Note that as an exception is propagated down the chain of callers, an
15261566
``'exception'`` event is generated at each level.
@@ -1549,8 +1589,8 @@ always available.
15491589

15501590
.. versionchanged:: 3.7
15511591

1552-
``'opcode'`` event type added; :attr:`f_trace_lines` and
1553-
:attr:`f_trace_opcodes` attributes added to frames
1592+
``'opcode'`` event type added; :attr:`!f_trace_lines` and
1593+
:attr:`!f_trace_opcodes` attributes added to frames
15541594

15551595
.. function:: set_asyncgen_hooks(firstiter, finalizer)
15561596

@@ -1675,7 +1715,7 @@ always available.
16751715
However, if you are writing a library (and do not control in which
16761716
context its code will be executed), be aware that the standard streams
16771717
may be replaced with file-like objects like :class:`io.StringIO` which
1678-
do not support the :attr:`~io.BufferedIOBase.buffer` attribute.
1718+
do not support the :attr:!buffer` attribute.
16791719

16801720

16811721
.. data:: __stdin__
@@ -1723,29 +1763,28 @@ always available.
17231763
A :term:`named tuple` holding information about the thread
17241764
implementation.
17251765

1726-
.. tabularcolumns:: |l|p{0.7\linewidth}|
1727-
1728-
+------------------+---------------------------------------------------------+
1729-
| Attribute | Explanation |
1730-
+==================+=========================================================+
1731-
| :const:`name` | Name of the thread implementation: |
1732-
| | |
1733-
| | * ``'nt'``: Windows threads |
1734-
| | * ``'pthread'``: POSIX threads |
1735-
| | * ``'pthread-stubs'``: stub POSIX threads |
1736-
| | (on WebAssembly platforms without threading support) |
1737-
| | * ``'solaris'``: Solaris threads |
1738-
+------------------+---------------------------------------------------------+
1739-
| :const:`lock` | Name of the lock implementation: |
1740-
| | |
1741-
| | * ``'semaphore'``: a lock uses a semaphore |
1742-
| | * ``'mutex+cond'``: a lock uses a mutex |
1743-
| | and a condition variable |
1744-
| | * ``None`` if this information is unknown |
1745-
+------------------+---------------------------------------------------------+
1746-
| :const:`version` | Name and version of the thread library. It is a string, |
1747-
| | or ``None`` if this information is unknown. |
1748-
+------------------+---------------------------------------------------------+
1766+
.. attribute:: thread_info.name
1767+
1768+
The name of the thread implementation:
1769+
1770+
* ``"nt"``: Windows threads
1771+
* ``"pthread"``: POSIX threads
1772+
* ``"pthread-stubs"``: stub POSIX threads
1773+
(on WebAssembly platforms without threading support)
1774+
* ``"solaris"``: Solaris threads
1775+
1776+
.. attribute:: thread_info.lock
1777+
1778+
The name of the lock implementation:
1779+
1780+
* ``"semaphore"``: a lock uses a semaphore
1781+
* ``"mutex+cond"``: a lock uses a mutex and a condition variable
1782+
* ``None`` if this information is unknown
1783+
1784+
.. attribute:: thread_info.version
1785+
1786+
The name and version of the thread library.
1787+
It is a string, or ``None`` if this information is unknown.
17491788

17501789
.. versionadded:: 3.3
17511790

Doc/library/textwrap.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ functions should be good enough; otherwise, you should use an instance of
6060
First the whitespace in *text* is collapsed (all whitespace is replaced by
6161
single spaces). If the result fits in the *width*, it is returned.
6262
Otherwise, enough words are dropped from the end so that the remaining words
63-
plus the :attr:`.placeholder` fit within :attr:`.width`::
63+
plus the *placeholder* fit within *width*::
6464

6565
>>> textwrap.shorten("Hello world!", width=12)
6666
'Hello world!'

Doc/tools/.nitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ Doc/library/ssl.rst
128128
Doc/library/stdtypes.rst
129129
Doc/library/string.rst
130130
Doc/library/subprocess.rst
131-
Doc/library/sys.rst
132131
Doc/library/sys_path_init.rst
133132
Doc/library/syslog.rst
134133
Doc/library/tarfile.rst

0 commit comments

Comments
 (0)