Skip to content

Commit 29fa7af

Browse files
erlend-aaslandAlexWaygoodAA-Turner
authored
Docs: Fix Sphinx warnings in sys.rst (#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. Co-authored-by: Alex Waygood <[email protected]> Co-authored-by: Adam Turner <[email protected]>
1 parent beffb30 commit 29fa7af

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
@@ -333,23 +333,21 @@ always available.
333333
*wasm32-emscripten* platform. The named tuple is provisional and may change
334334
in the future.
335335

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

354352
.. availability:: Emscripten.
355353

@@ -515,28 +513,62 @@ always available.
515513
The :term:`named tuple` *flags* exposes the status of command line
516514
flags. The attributes are read only.
517515

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

541573
.. versionchanged:: 3.2
542574
Added ``quiet`` attribute for the new :option:`-q` flag.
@@ -923,8 +955,8 @@ always available.
923955
| | a domain controller. |
924956
+---------------------------------------+---------------------------------+
925957

926-
This function wraps the Win32 :c:func:`GetVersionEx` function; see the
927-
Microsoft documentation on :c:func:`OSVERSIONINFOEX` for more information
958+
This function wraps the Win32 :c:func:`!GetVersionEx` function; see the
959+
Microsoft documentation on :c:func:`!OSVERSIONINFOEX` for more information
928960
about these fields.
929961

930962
*platform_version* returns the major version, minor version and
@@ -982,28 +1014,37 @@ always available.
9821014
implementation. For more details about hashing of numeric types, see
9831015
:ref:`numeric-hash`.
9841016

985-
+---------------------+--------------------------------------------------+
986-
| attribute | explanation |
987-
+=====================+==================================================+
988-
| :const:`width` | width in bits used for hash values |
989-
+---------------------+--------------------------------------------------+
990-
| :const:`modulus` | prime modulus P used for numeric hash scheme |
991-
+---------------------+--------------------------------------------------+
992-
| :const:`inf` | hash value returned for a positive infinity |
993-
+---------------------+--------------------------------------------------+
994-
| :const:`nan` | (this attribute is no longer used) |
995-
+---------------------+--------------------------------------------------+
996-
| :const:`imag` | multiplier used for the imaginary part of a |
997-
| | complex number |
998-
+---------------------+--------------------------------------------------+
999-
| :const:`algorithm` | name of the algorithm for hashing of str, bytes, |
1000-
| | and memoryview |
1001-
+---------------------+--------------------------------------------------+
1002-
| :const:`hash_bits` | internal output size of the hash algorithm |
1003-
+---------------------+--------------------------------------------------+
1004-
| :const:`seed_bits` | size of the seed key of the hash algorithm |
1005-
+---------------------+--------------------------------------------------+
1017+
.. attribute:: hash_info.width
1018+
1019+
The width in bits used for hash values
1020+
1021+
.. attribute:: hash_info.modulus
10061022

1023+
The prime modulus P used for numeric hash scheme
1024+
1025+
.. attribute:: hash_info.inf
1026+
1027+
The hash value returned for a positive infinity
1028+
1029+
.. attribute:: hash_info.nan
1030+
1031+
(This attribute is no longer used)
1032+
1033+
.. attribute:: hash_info.imag
1034+
1035+
The multiplier used for the imaginary part of a complex number
1036+
1037+
.. attribute:: hash_info.algorithm
1038+
1039+
The name of the algorithm for hashing of str, bytes, and memoryview
1040+
1041+
.. attribute:: hash_info.hash_bits
1042+
1043+
The internal output size of the hash algorithm
1044+
1045+
.. attribute:: hash_info.seed_bits
1046+
1047+
The size of the seed key of the hash algorithm
10071048

10081049
.. versionadded:: 3.2
10091050

@@ -1081,32 +1122,31 @@ always available.
10811122
A :term:`named tuple` that holds information about Python's internal
10821123
representation of integers. The attributes are read only.
10831124

1084-
.. tabularcolumns:: |l|L|
1085-
1086-
+----------------------------------------+-----------------------------------------------+
1087-
| Attribute | Explanation |
1088-
+========================================+===============================================+
1089-
| :const:`bits_per_digit` | number of bits held in each digit. Python |
1090-
| | integers are stored internally in base |
1091-
| | ``2**int_info.bits_per_digit`` |
1092-
+----------------------------------------+-----------------------------------------------+
1093-
| :const:`sizeof_digit` | size in bytes of the C type used to |
1094-
| | represent a digit |
1095-
+----------------------------------------+-----------------------------------------------+
1096-
| :const:`default_max_str_digits` | default value for |
1097-
| | :func:`sys.get_int_max_str_digits` when it |
1098-
| | is not otherwise explicitly configured. |
1099-
+----------------------------------------+-----------------------------------------------+
1100-
| :const:`str_digits_check_threshold` | minimum non-zero value for |
1101-
| | :func:`sys.set_int_max_str_digits`, |
1102-
| | :envvar:`PYTHONINTMAXSTRDIGITS`, or |
1103-
| | :option:`-X int_max_str_digits <-X>`. |
1104-
+----------------------------------------+-----------------------------------------------+
1125+
.. attribute:: int_info.bits_per_digit
1126+
1127+
The number of bits held in each digit.
1128+
Python integers are stored internally in base ``2**int_info.bits_per_digit``.
1129+
1130+
.. attribute:: int_info.sizeof_digit
1131+
1132+
The size in bytes of the C type used to represent a digit.
1133+
1134+
.. attribute:: int_info.default_max_str_digits
1135+
1136+
The default value for :func:`sys.get_int_max_str_digits`
1137+
when it is not otherwise explicitly configured.
1138+
1139+
.. attribute:: int_info.str_digits_check_threshold
1140+
1141+
The minimum non-zero value for :func:`sys.set_int_max_str_digits`,
1142+
:envvar:`PYTHONINTMAXSTRDIGITS`, or :option:`-X int_max_str_digits <-X>`.
11051143

11061144
.. versionadded:: 3.1
11071145

11081146
.. versionchanged:: 3.11
1109-
Added ``default_max_str_digits`` and ``str_digits_check_threshold``.
1147+
1148+
Added :attr:`~int_info.default_max_str_digits` and
1149+
:attr:`~int_info.str_digits_check_threshold`.
11101150

11111151

11121152
.. data:: __interactivehook__
@@ -1533,7 +1573,7 @@ always available.
15331573
:file:`Objects/lnotab_notes.txt` for a detailed explanation of how this
15341574
works.
15351575
Per-line events may be disabled for a frame by setting
1536-
:attr:`f_trace_lines` to :const:`False` on that frame.
1576+
:attr:`!f_trace_lines` to :const:`False` on that :ref:`frame <frame-objects>`.
15371577

15381578
``'return'``
15391579
A function (or other code block) is about to return. The local trace
@@ -1551,8 +1591,8 @@ always available.
15511591
opcode details). The local trace function is called; *arg* is
15521592
``None``; the return value specifies the new local trace function.
15531593
Per-opcode events are not emitted by default: they must be explicitly
1554-
requested by setting :attr:`f_trace_opcodes` to :const:`True` on the
1555-
frame.
1594+
requested by setting :attr:`!f_trace_opcodes` to :const:`True` on the
1595+
:ref:`frame <frame-objects>`.
15561596

15571597
Note that as an exception is propagated down the chain of callers, an
15581598
``'exception'`` event is generated at each level.
@@ -1581,8 +1621,8 @@ always available.
15811621

15821622
.. versionchanged:: 3.7
15831623

1584-
``'opcode'`` event type added; :attr:`f_trace_lines` and
1585-
:attr:`f_trace_opcodes` attributes added to frames
1624+
``'opcode'`` event type added; :attr:`!f_trace_lines` and
1625+
:attr:`!f_trace_opcodes` attributes added to frames
15861626

15871627
.. function:: set_asyncgen_hooks(firstiter, finalizer)
15881628

@@ -1739,7 +1779,7 @@ always available.
17391779
However, if you are writing a library (and do not control in which
17401780
context its code will be executed), be aware that the standard streams
17411781
may be replaced with file-like objects like :class:`io.StringIO` which
1742-
do not support the :attr:`~io.BufferedIOBase.buffer` attribute.
1782+
do not support the :attr:!buffer` attribute.
17431783

17441784

17451785
.. data:: __stdin__
@@ -1787,29 +1827,28 @@ always available.
17871827
A :term:`named tuple` holding information about the thread
17881828
implementation.
17891829

1790-
.. tabularcolumns:: |l|p{0.7\linewidth}|
1791-
1792-
+------------------+---------------------------------------------------------+
1793-
| Attribute | Explanation |
1794-
+==================+=========================================================+
1795-
| :const:`name` | Name of the thread implementation: |
1796-
| | |
1797-
| | * ``'nt'``: Windows threads |
1798-
| | * ``'pthread'``: POSIX threads |
1799-
| | * ``'pthread-stubs'``: stub POSIX threads |
1800-
| | (on WebAssembly platforms without threading support) |
1801-
| | * ``'solaris'``: Solaris threads |
1802-
+------------------+---------------------------------------------------------+
1803-
| :const:`lock` | Name of the lock implementation: |
1804-
| | |
1805-
| | * ``'semaphore'``: a lock uses a semaphore |
1806-
| | * ``'mutex+cond'``: a lock uses a mutex |
1807-
| | and a condition variable |
1808-
| | * ``None`` if this information is unknown |
1809-
+------------------+---------------------------------------------------------+
1810-
| :const:`version` | Name and version of the thread library. It is a string, |
1811-
| | or ``None`` if this information is unknown. |
1812-
+------------------+---------------------------------------------------------+
1830+
.. attribute:: thread_info.name
1831+
1832+
The name of the thread implementation:
1833+
1834+
* ``"nt"``: Windows threads
1835+
* ``"pthread"``: POSIX threads
1836+
* ``"pthread-stubs"``: stub POSIX threads
1837+
(on WebAssembly platforms without threading support)
1838+
* ``"solaris"``: Solaris threads
1839+
1840+
.. attribute:: thread_info.lock
1841+
1842+
The name of the lock implementation:
1843+
1844+
* ``"semaphore"``: a lock uses a semaphore
1845+
* ``"mutex+cond"``: a lock uses a mutex and a condition variable
1846+
* ``None`` if this information is unknown
1847+
1848+
.. attribute:: thread_info.version
1849+
1850+
The name and version of the thread library.
1851+
It is a string, or ``None`` if this information is unknown.
18131852

18141853
.. versionadded:: 3.3
18151854

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
@@ -127,7 +127,6 @@ Doc/library/ssl.rst
127127
Doc/library/stdtypes.rst
128128
Doc/library/string.rst
129129
Doc/library/subprocess.rst
130-
Doc/library/sys.rst
131130
Doc/library/sys_path_init.rst
132131
Doc/library/syslog.rst
133132
Doc/library/tarfile.rst

0 commit comments

Comments
 (0)