From 493ff87d80ac581ea08cf7cb7ca83ebb28cd090d Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 6 Dec 2022 10:47:38 +0100 Subject: [PATCH 1/5] TMP: Fail docs build on repeated name components --- Doc/tools/extensions/c_annotations.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Doc/tools/extensions/c_annotations.py b/Doc/tools/extensions/c_annotations.py index 9defb24a0331ef..643e05e65d155c 100644 --- a/Doc/tools/extensions/c_annotations.py +++ b/Doc/tools/extensions/c_annotations.py @@ -96,6 +96,10 @@ def add_annotations(self, app, doctree): if name.startswith("c."): name = name[2:] + components = name.split('.') + if len(set(components)) != len(components): + raise ValueError(f'repeated name components: {name}') + objtype = par['objtype'] # Stable ABI annotation. These have two forms: From e2867fdadf982b209b703f0502798daf16c6fc26 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 6 Dec 2022 11:00:50 +0100 Subject: [PATCH 2/5] Remove duplicate struct names from member docs --- Doc/c-api/structures.rst | 12 ++++++------ Doc/c-api/type.rst | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 827d624fc99edb..be739103ba9045 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -394,7 +394,7 @@ Accessing attributes of extension types The string should be static, no copy is made of it. - .. c:member:: Py_ssize_t PyMemberDef.offset + .. c:member:: Py_ssize_t offset The offset in bytes that the member is located on the type’s object struct. @@ -608,23 +608,23 @@ Defining Getters and Setters Structure to define property-like access for a type. See also description of the :c:member:`PyTypeObject.tp_getset` slot. - .. c:member:: const char* PyGetSetDef.name + .. c:member:: const char* name attribute name - .. c:member:: getter PyGetSetDef.get + .. c:member:: getter get C funtion to get the attribute. - .. c:member:: setter PyGetSetDef.set + .. c:member:: setter set Optional C function to set or delete the attribute, if omitted the attribute is readonly. - .. c:member:: const char* PyGetSetDef.doc + .. c:member:: const char* doc optional docstring - .. c:member:: void* PyGetSetDef.closure + .. c:member:: void* closure Optional function pointer, providing additional data for getter and setter. diff --git a/Doc/c-api/type.rst b/Doc/c-api/type.rst index 7b5d1fac40ed87..172e310bea6a26 100644 --- a/Doc/c-api/type.rst +++ b/Doc/c-api/type.rst @@ -322,25 +322,25 @@ The following functions and structs are used to create Structure defining a type's behavior. - .. c:member:: const char* PyType_Spec.name + .. c:member:: const char* name Name of the type, used to set :c:member:`PyTypeObject.tp_name`. - .. c:member:: int PyType_Spec.basicsize - .. c:member:: int PyType_Spec.itemsize + .. c:member:: int basicsize + .. c:member:: int itemsize Size of the instance in bytes, used to set :c:member:`PyTypeObject.tp_basicsize` and :c:member:`PyTypeObject.tp_itemsize`. - .. c:member:: int PyType_Spec.flags + .. c:member:: int flags Type flags, used to set :c:member:`PyTypeObject.tp_flags`. If the ``Py_TPFLAGS_HEAPTYPE`` flag is not set, :c:func:`PyType_FromSpecWithBases` sets it automatically. - .. c:member:: PyType_Slot *PyType_Spec.slots + .. c:member:: PyType_Slot *slots Array of :c:type:`PyType_Slot` structures. Terminated by the special slot value ``{0, NULL}``. @@ -352,7 +352,7 @@ The following functions and structs are used to create Structure defining optional functionality of a type, containing a slot ID and a value pointer. - .. c:member:: int PyType_Slot.slot + .. c:member:: int slot A slot ID. @@ -396,7 +396,7 @@ The following functions and structs are used to create :c:member:`~PyBufferProcs.bf_releasebuffer` are now available under the limited API. - .. c:member:: void *PyType_Slot.pfunc + .. c:member:: void *pfunc The desired value of the slot. In most cases, this is a pointer to a function. From 14c2ae7a66b3698ae19e21769a57fd8477ecc061 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 6 Dec 2022 11:06:01 +0100 Subject: [PATCH 3/5] Add raw HTML fragments to keep old links working --- Doc/c-api/structures.rst | 18 ++++++++++++++++++ Doc/c-api/type.rst | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index be739103ba9045..3e376774eacadc 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -382,6 +382,15 @@ definition with the same method name. Accessing attributes of extension types --------------------------------------- +.. raw:: html + + + + + + + + .. c:type:: PyMemberDef Structure which describes an attribute of a type which corresponds to a C @@ -603,6 +612,15 @@ Macro name C type Python type Defining Getters and Setters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. raw:: html + + + + + + + + .. c:type:: PyGetSetDef Structure to define property-like access for a type. See also description of diff --git a/Doc/c-api/type.rst b/Doc/c-api/type.rst index 172e310bea6a26..a1b77475e2ee89 100644 --- a/Doc/c-api/type.rst +++ b/Doc/c-api/type.rst @@ -318,6 +318,15 @@ The following functions and structs are used to create base classes provided in *Py_tp_base[s]* slots. Previously, only :class:`type` instances were returned. +.. raw:: html + + + + + + + + .. c:type:: PyType_Spec Structure defining a type's behavior. @@ -347,6 +356,12 @@ The following functions and structs are used to create Each slot ID should be specified at most once. +.. raw:: html + + + + + .. c:type:: PyType_Slot Structure defining optional functionality of a type, containing a slot ID From 26e095e04b4cd5795330c168e49a866e9ee7027d Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 6 Dec 2022 11:06:43 +0100 Subject: [PATCH 4/5] Remove hack to find repeated struct names --- Doc/tools/extensions/c_annotations.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Doc/tools/extensions/c_annotations.py b/Doc/tools/extensions/c_annotations.py index 643e05e65d155c..9defb24a0331ef 100644 --- a/Doc/tools/extensions/c_annotations.py +++ b/Doc/tools/extensions/c_annotations.py @@ -96,10 +96,6 @@ def add_annotations(self, app, doctree): if name.startswith("c."): name = name[2:] - components = name.split('.') - if len(set(components)) != len(components): - raise ValueError(f'repeated name components: {name}') - objtype = par['objtype'] # Stable ABI annotation. These have two forms: From cc57955612ed971eddb7363e6014c4179fe0e09d Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 6 Dec 2022 17:20:54 +0100 Subject: [PATCH 5/5] Don't add "old" fragments for PyMemberDef and PyGetSetDef These were only marked up in 3.12 (gh-97909), so they don't need backcompat backflips. --- Doc/c-api/structures.rst | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/Doc/c-api/structures.rst b/Doc/c-api/structures.rst index 3e376774eacadc..be739103ba9045 100644 --- a/Doc/c-api/structures.rst +++ b/Doc/c-api/structures.rst @@ -382,15 +382,6 @@ definition with the same method name. Accessing attributes of extension types --------------------------------------- -.. raw:: html - - - - - - - - .. c:type:: PyMemberDef Structure which describes an attribute of a type which corresponds to a C @@ -612,15 +603,6 @@ Macro name C type Python type Defining Getters and Setters ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. raw:: html - - - - - - - - .. c:type:: PyGetSetDef Structure to define property-like access for a type. See also description of