Skip to content

Commit 6a1c49a

Browse files
hugovkCAM-Gerlachencukou
authored
gh-101100: Test docs in nit-picky mode (#102513)
Co-authored-by: C.A.M. Gerlach <[email protected]> Co-authored-by: Petr Viktorin <[email protected]>
1 parent d494091 commit 6a1c49a

File tree

8 files changed

+116
-46
lines changed

8 files changed

+116
-46
lines changed

.github/workflows/doc.yml

+22
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ jobs:
5353
- name: 'Build HTML documentation'
5454
run: make -C Doc/ SPHINXOPTS="-q" SPHINXERRORHANDLING="-W --keep-going" html
5555

56+
# Add pull request annotations for Sphinx nitpicks (missing references)
57+
- name: 'Get list of changed files'
58+
id: changed_files
59+
uses: Ana06/[email protected]
60+
- name: 'Build changed files in nit-picky mode'
61+
continue-on-error: true
62+
run: |
63+
# Mark files the pull request modified
64+
touch ${{ steps.changed_files.outputs.added_modified }}
65+
# Build docs with the '-n' (nit-picky) option; convert warnings to annotations
66+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n --keep-going" html 2>&1 |
67+
python Doc/tools/warnings-to-gh-actions.py
68+
69+
# Ensure some files always pass Sphinx nit-picky mode (no missing references)
70+
- name: 'Build known-good files in nit-picky mode'
71+
run: |
72+
# Mark files that must pass nit-picky
73+
touch Doc/whatsnew/3.12.rst
74+
touch Doc/library/sqlite3.rst
75+
# Build docs with the '-n' (nit-picky) option, convert warnings to errors (-W)
76+
make -C Doc/ PYTHON=../python SPHINXOPTS="-q -n -W --keep-going" html 2>&1
77+
5678
# Run "doctest" on HEAD as new syntax doesn't exist in the latest stable release
5779
doctest:
5880
name: 'Doctest'

Doc/c-api/exceptions.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Printing and clearing
8686
8787
An exception must be set when calling this function.
8888
89-
.. c:function: void PyErr_DisplayException(PyObject *exc)
89+
.. c:function:: void PyErr_DisplayException(PyObject *exc)
9090
9191
Print the standard traceback display of ``exc`` to ``sys.stderr``, including
9292
chained exceptions and notes.

Doc/c-api/weakref.rst

+10
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,13 @@ as much as it can.
6767
.. c:function:: PyObject* PyWeakref_GET_OBJECT(PyObject *ref)
6868
6969
Similar to :c:func:`PyWeakref_GetObject`, but does no error checking.
70+
71+
72+
.. c:function:: void PyObject_ClearWeakRefs(PyObject *object)
73+
74+
This function is called by the :c:member:`~PyTypeObject.tp_dealloc` handler
75+
to clear weak references.
76+
77+
This iterates through the weak references for *object* and calls callbacks
78+
for those references which have one. It returns when all callbacks have
79+
been attempted.

Doc/library/asyncio-task.rst

+7
Original file line numberDiff line numberDiff line change
@@ -960,6 +960,13 @@ Introspection
960960
.. versionadded:: 3.7
961961

962962

963+
.. function:: iscoroutine(obj)
964+
965+
Return ``True`` if *obj* is a coroutine object.
966+
967+
.. versionadded:: 3.4
968+
969+
963970
Task Object
964971
===========
965972

Doc/library/gzip.rst

+6
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ The module defines the following items:
143143
:func:`time.time` and the :attr:`~os.stat_result.st_mtime` attribute of
144144
the object returned by :func:`os.stat`.
145145

146+
.. attribute:: name
147+
148+
The path to the gzip file on disk, as a :class:`str` or :class:`bytes`.
149+
Equivalent to the output of :func:`os.fspath` on the original input path,
150+
with no other normalization, resolution or expansion.
151+
146152
.. versionchanged:: 3.1
147153
Support for the :keyword:`with` statement was added, along with the
148154
*mtime* constructor argument and :attr:`mtime` attribute.

Doc/tools/warnings-to-gh-actions.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
3+
"""
4+
Convert Sphinx warning messages to GitHub Actions.
5+
6+
Converts lines like:
7+
.../Doc/library/cgi.rst:98: WARNING: reference target not found
8+
to:
9+
::warning file=.../Doc/library/cgi.rst,line=98::reference target not found
10+
11+
Non-matching lines are echoed unchanged.
12+
13+
see: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
14+
"""
15+
16+
import re
17+
import sys
18+
19+
pattern = re.compile(r'(?P<file>[^:]+):(?P<line>\d+): WARNING: (?P<msg>.+)')
20+
21+
for line in sys.stdin:
22+
if match := pattern.fullmatch(line.strip()):
23+
print('::warning file={file},line={line}::{msg}'.format_map(match))
24+
else:
25+
print(line)

Doc/whatsnew/3.12.rst

+44-44
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ inspect
248248
-------
249249

250250
* Add :func:`inspect.markcoroutinefunction` to mark sync functions that return
251-
a :term:`coroutine` for use with :func:`iscoroutinefunction`.
251+
a :term:`coroutine` for use with :func:`inspect.iscoroutinefunction`.
252252
(Contributed Carlton Gibson in :gh:`99247`.)
253253

254254
* Add :func:`inspect.getasyncgenstate` and :func:`inspect.getasyncgenlocals`
@@ -277,7 +277,7 @@ dis
277277
* Pseudo instruction opcodes (which are used by the compiler but
278278
do not appear in executable bytecode) are now exposed in the
279279
:mod:`dis` module.
280-
:data:`~dis.HAVE_ARGUMENT` is still relevant to real opcodes,
280+
:opcode:`HAVE_ARGUMENT` is still relevant to real opcodes,
281281
but it is not useful for pseudo instructions. Use the new
282282
:data:`~dis.hasarg` collection instead.
283283
(Contributed by Irit Katriel in :gh:`94216`.)
@@ -422,7 +422,7 @@ Optimizations
422422
(Contributed by Kevin Modzelewski in :gh:`90536`.)
423423

424424
* Speed up the regular expression substitution (functions :func:`re.sub` and
425-
:func:`re.subn` and corresponding :class:`re.Pattern` methods) for
425+
:func:`re.subn` and corresponding :class:`!re.Pattern` methods) for
426426
replacement strings containing group references by 2--3 times.
427427
(Contributed by Serhiy Storchaka in :gh:`91524`.)
428428

@@ -435,7 +435,7 @@ CPython bytecode changes
435435
:opcode:`LOAD_METHOD` instruction if the low bit of its oparg is set.
436436
(Contributed by Ken Jin in :gh:`93429`.)
437437

438-
* Removed the :opcode:`JUMP_IF_FALSE_OR_POP` and :opcode:`JUMP_IF_TRUE_OR_POP`
438+
* Removed the :opcode:`!JUMP_IF_FALSE_OR_POP` and :opcode:`!JUMP_IF_TRUE_OR_POP`
439439
instructions. (Contributed by Irit Katriel in :gh:`102859`.)
440440

441441

@@ -482,7 +482,7 @@ Deprecated
482482
:exc:`ImportWarning`).
483483
(Contributed by Brett Cannon in :gh:`65961`.)
484484

485-
* The :meth:`~asyncio.DefaultEventLoopPolicy.get_event_loop` method of the
485+
* The :meth:`~asyncio.get_event_loop` method of the
486486
default event loop policy now emits a :exc:`DeprecationWarning` if there
487487
is no current event loop set and it decides to create one.
488488
(Contributed by Serhiy Storchaka and Guido van Rossum in :gh:`100160`.)
@@ -541,23 +541,23 @@ Modules (see :pep:`594`):
541541

542542
APIs:
543543

544-
* :class:`configparser.LegacyInterpolation` (:gh:`90765`)
544+
* :class:`!configparser.LegacyInterpolation` (:gh:`90765`)
545545
* :func:`locale.getdefaultlocale` (:gh:`90817`)
546-
* :meth:`turtle.RawTurtle.settiltangle` (:gh:`50096`)
547-
* :func:`unittest.findTestCases` (:gh:`50096`)
548-
* :func:`unittest.makeSuite` (:gh:`50096`)
549-
* :func:`unittest.getTestCaseNames` (:gh:`50096`)
550-
* :class:`webbrowser.MacOSX` (:gh:`86421`)
546+
* :meth:`!turtle.RawTurtle.settiltangle` (:gh:`50096`)
547+
* :func:`!unittest.findTestCases` (:gh:`50096`)
548+
* :func:`!unittest.makeSuite` (:gh:`50096`)
549+
* :func:`!unittest.getTestCaseNames` (:gh:`50096`)
550+
* :class:`!webbrowser.MacOSX` (:gh:`86421`)
551551

552552
Pending Removal in Python 3.14
553553
------------------------------
554554

555555
* Deprecated the following :mod:`importlib.abc` classes, scheduled for removal in
556556
Python 3.14:
557557

558-
* :class:`importlib.abc.ResourceReader`
559-
* :class:`importlib.abc.Traversable`
560-
* :class:`importlib.abc.TraversableResources`
558+
* :class:`!importlib.abc.ResourceReader`
559+
* :class:`!importlib.abc.Traversable`
560+
* :class:`!importlib.abc.TraversableResources`
561561

562562
Use :mod:`importlib.resources.abc` classes instead:
563563

@@ -566,7 +566,7 @@ Pending Removal in Python 3.14
566566

567567
(Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.)
568568

569-
* Creating :c:data:`immutable types <Py_TPFLAGS_IMMUTABLETYPE>` with mutable
569+
* Creating immutable types (:data:`Py_TPFLAGS_IMMUTABLETYPE`) with mutable
570570
bases using the C API.
571571

572572
* Deprecated the *isdst* parameter in :func:`email.utils.localtime`.
@@ -701,11 +701,11 @@ Removed
701701

702702
* Remove ``io.OpenWrapper`` and ``_pyio.OpenWrapper``, deprecated in Python
703703
3.10: just use :func:`open` instead. The :func:`open` (:func:`io.open`)
704-
function is a built-in function. Since Python 3.10, :func:`_pyio.open` is
704+
function is a built-in function. Since Python 3.10, :func:`!_pyio.open` is
705705
also a static method.
706706
(Contributed by Victor Stinner in :gh:`94169`.)
707707

708-
* Remove the :func:`ssl.RAND_pseudo_bytes` function, deprecated in Python 3.6:
708+
* Remove the :func:`!ssl.RAND_pseudo_bytes` function, deprecated in Python 3.6:
709709
use :func:`os.urandom` or :func:`ssl.RAND_bytes` instead.
710710
(Contributed by Victor Stinner in :gh:`94199`.)
711711

@@ -715,13 +715,13 @@ Removed
715715
extension if it was not present.
716716
(Contributed by Victor Stinner in :gh:`94196`.)
717717

718-
* Remove the :func:`ssl.match_hostname` function. The
719-
:func:`ssl.match_hostname` was deprecated in Python 3.7. OpenSSL performs
718+
* Remove the :func:`!ssl.match_hostname` function.
719+
It was deprecated in Python 3.7. OpenSSL performs
720720
hostname matching since Python 3.7, Python no longer uses the
721-
:func:`ssl.match_hostname` function.
721+
:func:`!ssl.match_hostname` function.
722722
(Contributed by Victor Stinner in :gh:`94199`.)
723723

724-
* Remove the :func:`locale.format` function, deprecated in Python 3.7:
724+
* Remove the :func:`!locale.format` function, deprecated in Python 3.7:
725725
use :func:`locale.format_string` instead.
726726
(Contributed by Victor Stinner in :gh:`94226`.)
727727

@@ -731,9 +731,9 @@ Removed
731731
a C implementation of :func:`~hashlib.pbkdf2_hmac()` which is faster.
732732
(Contributed by Victor Stinner in :gh:`94199`.)
733733

734-
* :mod:`xml.etree`: Remove the ``ElementTree.Element.copy()`` method of the
734+
* :mod:`xml.etree.ElementTree`: Remove the ``ElementTree.Element.copy()`` method of the
735735
pure Python implementation, deprecated in Python 3.10, use the
736-
:func:`copy.copy` function instead. The C implementation of :mod:`xml.etree`
736+
:func:`copy.copy` function instead. The C implementation of :mod:`xml.etree.ElementTree`
737737
has no ``copy()`` method, only a ``__copy__()`` method.
738738
(Contributed by Victor Stinner in :gh:`94383`.)
739739

@@ -742,10 +742,10 @@ Removed
742742
:pep:`451` for the rationale.
743743
(Contributed by Victor Stinner in :gh:`94379`.)
744744

745-
* Remove the :func:`ssl.wrap_socket` function, deprecated in Python 3.7:
745+
* Remove the :func:`!ssl.wrap_socket` function, deprecated in Python 3.7:
746746
instead, create a :class:`ssl.SSLContext` object and call its
747747
:class:`ssl.SSLContext.wrap_socket` method. Any package that still uses
748-
:func:`ssl.wrap_socket` is broken and insecure. The function neither sends a
748+
:func:`!ssl.wrap_socket` is broken and insecure. The function neither sends a
749749
SNI TLS extension nor validates server hostname. Code is subject to `CWE-295
750750
<https://cwe.mitre.org/data/definitions/295.html>`_: Improper Certificate
751751
Validation.
@@ -912,7 +912,7 @@ New Features
912912
The :const:`Py_TPFLAGS_HAVE_VECTORCALL` flag is now removed from a class
913913
when the class's :py:meth:`~object.__call__` method is reassigned.
914914
This makes vectorcall safe to use with mutable types (i.e. heap types
915-
without the :const:`immutable <Py_TPFLAGS_IMMUTABLETYPE>` flag).
915+
without the immutable flag, :const:`Py_TPFLAGS_IMMUTABLETYPE`).
916916
Mutable types that do not override :c:member:`~PyTypeObject.tp_call` now
917917
inherit the ``Py_TPFLAGS_HAVE_VECTORCALL`` flag.
918918
(Contributed by Petr Viktorin in :gh:`93274`.)
@@ -945,7 +945,7 @@ New Features
945945
(Contributed by Andrew Frost in :gh:`92257`.)
946946

947947
* The C API now permits registering callbacks via :c:func:`PyDict_AddWatcher`,
948-
:c:func:`PyDict_AddWatch` and related APIs to be called whenever a dictionary
948+
:c:func:`PyDict_Watch` and related APIs to be called whenever a dictionary
949949
is modified. This is intended for use by optimizing interpreters, JIT
950950
compilers, or debuggers.
951951
(Contributed by Carl Meyer in :gh:`91052`.)
@@ -977,7 +977,7 @@ New Features
977977
(Contributed by Mark Shannon in :gh:`101578`.)
978978

979979
* Add :c:func:`PyErr_DisplayException`, which takes an exception instance,
980-
to replace the legacy-api :c:func:`PyErr_Display`. (Contributed by
980+
to replace the legacy-api :c:func:`!PyErr_Display`. (Contributed by
981981
Irit Katriel in :gh:`102755`).
982982

983983
Porting to Python 3.12
@@ -1024,7 +1024,7 @@ Porting to Python 3.12
10241024
supported, but does not fully support multiple inheritance
10251025
(:gh:`95589`), and performance may be worse.
10261026
Classes declaring :const:`Py_TPFLAGS_MANAGED_DICT` should call
1027-
:c:func:`_PyObject_VisitManagedDict` and :c:func:`_PyObject_ClearManagedDict`
1027+
:c:func:`!_PyObject_VisitManagedDict` and :c:func:`!_PyObject_ClearManagedDict`
10281028
to traverse and clear their instance's dictionaries.
10291029
To clear weakrefs, call :c:func:`PyObject_ClearWeakRefs`, as before.
10301030

@@ -1069,17 +1069,17 @@ Deprecated
10691069
* :c:var:`Py_HashRandomizationFlag`: use :c:member:`PyConfig.use_hash_seed`
10701070
and :c:member:`PyConfig.hash_seed`
10711071
* :c:var:`Py_IsolatedFlag`: use :c:member:`PyConfig.isolated`
1072-
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyConfig.legacy_windows_fs_encoding`
1072+
* :c:var:`Py_LegacyWindowsFSEncodingFlag`: use :c:member:`PyPreConfig.legacy_windows_fs_encoding`
10731073
* :c:var:`Py_LegacyWindowsStdioFlag`: use :c:member:`PyConfig.legacy_windows_stdio`
1074-
* :c:var:`Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding`
1075-
* :c:var:`Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig.filesystem_errors`
1076-
* :c:var:`Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` (see :c:func:`Py_PreInitialize`)
1074+
* :c:var:`!Py_FileSystemDefaultEncoding`: use :c:member:`PyConfig.filesystem_encoding`
1075+
* :c:var:`!Py_FileSystemDefaultEncodeErrors`: use :c:member:`PyConfig.filesystem_errors`
1076+
* :c:var:`!Py_UTF8Mode`: use :c:member:`PyPreConfig.utf8_mode` (see :c:func:`Py_PreInitialize`)
10771077

10781078
The :c:func:`Py_InitializeFromConfig` API should be used with
10791079
:c:type:`PyConfig` instead.
10801080
(Contributed by Victor Stinner in :gh:`77782`.)
10811081

1082-
* Creating :c:data:`immutable types <Py_TPFLAGS_IMMUTABLETYPE>` with mutable
1082+
* Creating immutable types (:const:`Py_TPFLAGS_IMMUTABLETYPE`) with mutable
10831083
bases is deprecated and will be disabled in Python 3.14.
10841084

10851085
* The ``structmember.h`` header is deprecated, though it continues to be
@@ -1118,7 +1118,7 @@ Deprecated
11181118
:c:func:`PyErr_SetRaisedException` instead.
11191119
(Contributed by Mark Shannon in :gh:`101578`.)
11201120

1121-
* :c:func:`PyErr_Display` is deprecated. Use :c:func:`PyErr_DisplayException`
1121+
* :c:func:`!PyErr_Display` is deprecated. Use :c:func:`PyErr_DisplayException`
11221122
instead. (Contributed by Irit Katriel in :gh:`102755`).
11231123

11241124

@@ -1132,15 +1132,15 @@ Removed
11321132

11331133
* Legacy Unicode APIs have been removed. See :pep:`623` for detail.
11341134

1135-
* :c:macro:`PyUnicode_WCHAR_KIND`
1136-
* :c:func:`PyUnicode_AS_UNICODE`
1137-
* :c:func:`PyUnicode_AsUnicode`
1138-
* :c:func:`PyUnicode_AsUnicodeAndSize`
1139-
* :c:func:`PyUnicode_AS_DATA`
1140-
* :c:func:`PyUnicode_FromUnicode`
1141-
* :c:func:`PyUnicode_GET_SIZE`
1142-
* :c:func:`PyUnicode_GetSize`
1143-
* :c:func:`PyUnicode_GET_DATA_SIZE`
1135+
* :c:macro:`!PyUnicode_WCHAR_KIND`
1136+
* :c:func:`!PyUnicode_AS_UNICODE`
1137+
* :c:func:`!PyUnicode_AsUnicode`
1138+
* :c:func:`!PyUnicode_AsUnicodeAndSize`
1139+
* :c:func:`!PyUnicode_AS_DATA`
1140+
* :c:func:`!PyUnicode_FromUnicode`
1141+
* :c:func:`!PyUnicode_GET_SIZE`
1142+
* :c:func:`!PyUnicode_GetSize`
1143+
* :c:func:`!PyUnicode_GET_DATA_SIZE`
11441144

11451145
* Remove the ``PyUnicode_InternImmortal()`` function and the
11461146
``SSTATE_INTERNED_IMMORTAL`` macro.

Misc/NEWS.d/3.10.0a2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ file descriptors.
888888
.. nonce: JUPE59
889889
.. section: C API
890890
891-
:c:data:`Py_FileSystemDefaultEncodeErrors` and :c:data:`Py_UTF8Mode` are
891+
:c:data:`!Py_FileSystemDefaultEncodeErrors` and :c:data:`!Py_UTF8Mode` are
892892
available again in limited API.
893893

894894
..

0 commit comments

Comments
 (0)