Skip to contentSkip to conversation

Extend automarkup support for ABI symbols

PATCH In review Mauro Carvalho Chehab 5 participants 15 messages Feb 11, 2025 – Feb 18, 2025

Subsystems (16)
lore
Share & tools
lore
#0 lore raw

cover Extend automarkup support for ABI symbols

Now that ABI creates a python dictionary, use automarkup to create cross references for ABI symbols as well.

Mauro Carvalho Chehab (9):
docs: media: Allow creating cross-references for RC ABI
docs: automarkup: drop legacy support
docs: thunderbolt: Allow creating cross-references for ABI
docs: arm: asymmetric-32bit: Allow creating cross-references for ABI
docs: arm: generic-counter: Allow creating cross-references for ABI
docs: iio: Allow creating cross-references ABI
docs: networking: Allow creating cross-references statistics ABI
docs: submit-checklist: Allow creating cross-references for ABI README
docs: translations: Allow creating cross-references for ABI README

 Documentation/admin-guide/thunderbolt.rst     |  2 +-
 Documentation/arch/arm64/asymmetric-32bit.rst |  2 +-
 Documentation/driver-api/generic-counter.rst  |  4 +-
 Documentation/driver-api/iio/core.rst         |  2 +-
 Documentation/iio/iio_devbuf.rst              |  2 +-
 Documentation/networking/statistics.rst       |  2 +-
 Documentation/process/submit-checklist.rst    |  2 +-
 Documentation/sphinx/automarkup.py            | 47 ++++++++-----------
 .../it_IT/process/submit-checklist.rst        |  2 +-
 .../sp_SP/process/submit-checklist.rst        |  2 +-
 .../zh_CN/process/submit-checklist.rst        |  2 +-
 .../zh_TW/process/submit-checklist.rst        |  2 +-
 .../userspace-api/media/rc/rc-sysfs-nodes.rst |  2 +-
 13 files changed, 32 insertions(+), 41 deletions(-)
Signature · 1 line
2.48.1
#1 lore raw

PATCH 1/9 docs: media: Allow creating cross-references for RC ABI

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for RC sysfs devnodes.

---
 Documentation/sphinx/automarkup.py              | 17 +++++++++++++----
 .../userspace-api/media/rc/rc-sysfs-nodes.rst   |  2 +-
 2 files changed, 14 insertions(+), 5 deletions(-)
Documentation/sphinx/automarkup.py +13 -4
index 22defc18d6d2..03bb7020f5cb 100644
@@ -88,13 +88,13 @@ def markup_refs(docname, app, node):
     # Associate each regex with the function that will markup its matches
     #
     markup_func_sphinx2 = {RE_doc: markup_doc_ref,
-                           RE_abi_file: markup_abi_ref,
+                           RE_abi_file: markup_abi_file_ref,
                            RE_abi_symbol: markup_abi_ref,
                            RE_function: markup_c_ref,
                            RE_generic_type: markup_c_ref}
 
     markup_func_sphinx3 = {RE_doc: markup_doc_ref,
-                           RE_abi_file: markup_abi_ref,
+                           RE_abi_file: markup_abi_file_ref,
                            RE_abi_symbol: markup_abi_ref,
                            RE_function: markup_func_ref_sphinx3,
                            RE_struct: markup_c_ref,
@@ -279,10 +279,10 @@ def markup_doc_ref(docname, app, match):
         return nodes.Text(match.group(0))
 
 #
-# Try to replace a documentation reference of the form Documentation/ABI/...
+# Try to replace a documentation reference for ABI symbols and files
 # with a cross reference to that page
 #
-def markup_abi_ref(docname, app, match):
+def markup_abi_ref(docname, app, match, warning=False):
     stddom = app.env.domains['std']
     #
     # Go through the dance of getting an xref out of the std domain
@@ -294,6 +294,8 @@ def markup_abi_ref(docname, app, match):
 
     # Kernel ABI doesn't describe such file or symbol
     if not target:
+        if warning:
+            kernel_abi.log.warning("%s not found", fname)
         return nodes.Text(match.group(0))
 
     pxref = addnodes.pending_xref('', refdomain = 'std', reftype = 'ref',
@@ -317,6 +319,13 @@ def markup_abi_ref(docname, app, match):
     else:
         return nodes.Text(match.group(0))
 
+#
+# Variant of markup_abi_ref() that warns whan a reference is not found
+#
+def markup_abi_file_ref(docname, app, match):
+    return markup_abi_ref(docname, app, match, warning=True)
+
+
 def get_c_namespace(app, docname):
     source = app.env.doc2path(docname)
     with open(source) as f:
Documentation/userspace-api/media/rc/rc-sysfs-nodes.rst +1 -1
index 34d6a0a1f4d3..70b5966aaff8 100644
@@ -6,7 +6,7 @@
 Remote Controller's sysfs nodes
 *******************************
 
-As defined at ``Documentation/ABI/testing/sysfs-class-rc``, those are
+As defined at Documentation/ABI/testing/sysfs-class-rc, those are
 the sysfs nodes that control the Remote Controllers:
 
 
Signature · 1 line
2.48.1
#2 lore raw

PATCH 2/9 docs: automarkup: drop legacy support

In reply to Mauro Carvalho Chehab

Python 2 is already EOL for quite some time. Drop support for it.

Also, the minimal Sphinx version is now 3.4.3. So, we can drop support for Sphinx < 3.

---
 Documentation/sphinx/automarkup.py | 32 +++++++-----------------------
 1 file changed, 7 insertions(+), 25 deletions(-)
Documentation/sphinx/automarkup.py +7 -25
index 03bb7020f5cb..ecf54d22e9dc 100644
@@ -13,14 +13,6 @@ from itertools import chain
 
 from kernel_abi import get_kernel_abi
 
-#
-# Python 2 lacks re.ASCII...
-#
-try:
-    ascii_p3 = re.ASCII
-except AttributeError:
-    ascii_p3 = 0
-
 #
 # Regex nastiness.  Of course.
 # Try to identify "function()" that's not already marked up some
@@ -28,22 +20,22 @@ except AttributeError:
 # :c:func: block (i.e. ":c:func:`mmap()`s" flakes out), so the last
 # bit tries to restrict matches to things that won't create trouble.
 #
-RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=ascii_p3)
+RE_function = re.compile(r'\b(([a-zA-Z_]\w+)\(\))', flags=re.ASCII)
 
 #
 # Sphinx 2 uses the same :c:type role for struct, union, enum and typedef
 #
 RE_generic_type = re.compile(r'\b(struct|union|enum|typedef)\s+([a-zA-Z_]\w+)',
-                             flags=ascii_p3)
+                             flags=re.ASCII)
 
 #
 # Sphinx 3 uses a different C role for each one of struct, union, enum and
 # typedef
 #
-RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
-RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
-RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
-RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=ascii_p3)
+RE_struct = re.compile(r'\b(struct)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
+RE_union = re.compile(r'\b(union)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
+RE_enum = re.compile(r'\b(enum)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
+RE_typedef = re.compile(r'\b(typedef)\s+([a-zA-Z_]\w+)', flags=re.ASCII)
 
 #
 # Detects a reference to a documentation page of the form Documentation/... with
@@ -87,13 +79,8 @@ def markup_refs(docname, app, node):
     #
     # Associate each regex with the function that will markup its matches
     #
-    markup_func_sphinx2 = {RE_doc: markup_doc_ref,
-                           RE_abi_file: markup_abi_file_ref,
-                           RE_abi_symbol: markup_abi_ref,
-                           RE_function: markup_c_ref,
-                           RE_generic_type: markup_c_ref}
 
-    markup_func_sphinx3 = {RE_doc: markup_doc_ref,
+    markup_func = {RE_doc: markup_doc_ref,
                            RE_abi_file: markup_abi_file_ref,
                            RE_abi_symbol: markup_abi_ref,
                            RE_function: markup_func_ref_sphinx3,
@@ -103,11 +90,6 @@ def markup_refs(docname, app, node):
                            RE_typedef: markup_c_ref,
                            RE_git: markup_git}
 
-    if sphinx.version_info[0] >= 3:
-        markup_func = markup_func_sphinx3
-    else:
-        markup_func = markup_func_sphinx2
-
     match_iterators = [regex.finditer(t) for regex in markup_func]
     #
     # Sort all references by the starting position in text
Signature · 1 line
2.48.1
#3 lore raw

PATCH 3/9 docs: thunderbolt: Allow creating cross-references for ABI

In reply to Mauro Carvalho Chehab

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for the corresponding ABI file.

---
 Documentation/admin-guide/thunderbolt.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/admin-guide/thunderbolt.rst +1 -1
index 2ed79f41a411..d0502691dfa1 100644
@@ -28,7 +28,7 @@ should be a userspace tool that handles all the low-level details, keeps
 a database of the authorized devices and prompts users for new connections.
 
 More details about the sysfs interface for Thunderbolt devices can be
-found in ``Documentation/ABI/testing/sysfs-bus-thunderbolt``.
+found in Documentation/ABI/testing/sysfs-bus-thunderbolt.
 
 Those users who just want to connect any device without any sort of
 manual work can add following line to
Signature · 1 line
2.48.1
#4 lore raw

PATCH 4/9 docs: arm: asymmetric-32bit: Allow creating cross-references for ABI

In reply to Mauro Carvalho Chehab

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for the corresponding ABI file.

---
 Documentation/arch/arm64/asymmetric-32bit.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/arch/arm64/asymmetric-32bit.rst +1 -1
index 1ca2b359a907..57b8d7476f71 100644
@@ -55,7 +55,7 @@ sysfs
 
 The subset of CPUs capable of running 32-bit tasks is described in
 ``/sys/devices/system/cpu/aarch32_el0`` and is documented further in
-``Documentation/ABI/testing/sysfs-devices-system-cpu``.
+Documentation/ABI/testing/sysfs-devices-system-cpu.
 
 **Note:** CPUs are advertised by this file as they are detected and so
 late-onlining of 32-bit-capable CPUs can result in the file contents
Signature · 1 line
2.48.1
#5 lore raw

PATCH 5/9 docs: arm: generic-counter: Allow creating cross-references for ABI

In reply to Mauro Carvalho Chehab

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for the corresponding ABI file.

---
 Documentation/driver-api/generic-counter.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Documentation/driver-api/generic-counter.rst +2 -2
index 71ccc30e586b..e826f16ea43d 100644
@@ -467,7 +467,7 @@ Counter sysfs
 Translates counter data to the standard Counter sysfs interface format
 and vice versa.
 
-Please refer to the ``Documentation/ABI/testing/sysfs-bus-counter`` file
+Please refer to the Documentation/ABI/testing/sysfs-bus-counter file
 for a detailed breakdown of the available Generic Counter interface
 sysfs attributes.
 
@@ -483,7 +483,7 @@ Sysfs Interface
 Several sysfs attributes are generated by the Generic Counter interface,
 and reside under the ``/sys/bus/counter/devices/counterX`` directory,
 where ``X`` is to the respective counter device id. Please see
-``Documentation/ABI/testing/sysfs-bus-counter`` for detailed information
+Documentation/ABI/testing/sysfs-bus-counter for detailed information
 on each Generic Counter interface sysfs attribute.
 
 Through these sysfs attributes, programs and scripts may interact with
Signature · 1 line
2.48.1
#6 lore raw

PATCH 6/9 docs: iio: Allow creating cross-references ABI

In reply to Mauro Carvalho Chehab

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for the corresponding ABI file.

---
 Documentation/driver-api/iio/core.rst | 2 +-
 Documentation/iio/iio_devbuf.rst      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/driver-api/iio/core.rst +1 -1
index dfe438dc91a7..42b580fb2989 100644
@@ -60,7 +60,7 @@ directory.  Common attributes are:
 * :file:`sampling_frequency_available`, available discrete set of sampling
   frequency values for device.
 * Available standard attributes for IIO devices are described in the
-  :file:`Documentation/ABI/testing/sysfs-bus-iio` file in the Linux kernel
+  :file:Documentation/ABI/testing/sysfs-bus-iio file in the Linux kernel
   sources.
 
 IIO device channels
Documentation/iio/iio_devbuf.rst +1 -1
index 9919e4792d0e..dca1f0200b0d 100644
@@ -148,5 +148,5 @@ applied), however there are corner cases in which the buffered data may be found
 in a processed form. Please note that these corner cases are not addressed by
 this documentation.
 
-Please see ``Documentation/ABI/testing/sysfs-bus-iio`` for a complete
+Please see Documentation/ABI/testing/sysfs-bus-iio for a complete
 description of the attributes.
Signature · 1 line
2.48.1
#7 lore raw

PATCH 7/9 docs: networking: Allow creating cross-references statistics ABI

In reply to Mauro Carvalho Chehab

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for the corresponding ABI file.

---
 Documentation/networking/statistics.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/networking/statistics.rst +1 -1
index 75e017dfa825..518284e287b0 100644
@@ -143,7 +143,7 @@ reading multiple stats as it internally performs a full dump of
 and reports only the stat corresponding to the accessed file.
 
 Sysfs files are documented in
-`Documentation/ABI/testing/sysfs-class-net-statistics`.
+Documentation/ABI/testing/sysfs-class-net-statistics.
 
 
 netlink
Signature · 1 line
2.48.1
maintainer Acked-by on v1 7/9
#8 lore raw

Re: [PATCH 7/9] docs: networking: Allow creating cross-references statistics ABI

Quoted 2 lines · On Tue, 11 Feb 2025 07:23:01 +0100 Mauro Carvalho Chehab wrote:

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for the corresponding ABI file.

#9 lore raw

PATCH 8/9 docs: submit-checklist: Allow creating cross-references for ABI README

In reply to Mauro Carvalho Chehab

Now that Documentation/ABI is processed by automarkup, let it generate cross-references for the ABI README file.

---
 Documentation/process/submit-checklist.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/process/submit-checklist.rst +1 -1
index 88b6358258d7..2abf8831cf74 100644
@@ -52,7 +52,7 @@ Provide documentation
 4) All new module parameters are documented with ``MODULE_PARM_DESC()``
 
 5) All new userspace interfaces are documented in ``Documentation/ABI/``.
-   See ``Documentation/ABI/README`` for more information.
+   See Documentation/ABI/README for more information.
    Patches that change userspace interfaces should be CCed to
    [email protected].
 
Signature · 1 line
2.48.1
#10 lore raw

PATCH 9/9 docs: translations: Allow creating cross-references for ABI README

In reply to Mauro Carvalho Chehab

Update translations to also generate cross references for the ABI readme file.

---
 Documentation/translations/it_IT/process/submit-checklist.rst | 2 +-
 Documentation/translations/sp_SP/process/submit-checklist.rst | 2 +-
 Documentation/translations/zh_CN/process/submit-checklist.rst | 2 +-
 Documentation/translations/zh_TW/process/submit-checklist.rst | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
Documentation/translations/it_IT/process/submit-checklist.rst +1 -1
index 692be4af9c9b..3308c3084c60 100644
@@ -58,7 +58,7 @@ Fornite documentazione
 4) Tutti i nuovi parametri dei moduli sono documentati con ``MODULE_PARM_DESC()``.
 
 5) Tutte le nuove interfacce verso lo spazio utente sono documentate in
-    ``Documentation/ABI/``.  Leggete ``Documentation/ABI/README`` per maggiori
+    ``Documentation/ABI/``.  Leggete Documentation/ABI/README per maggiori
     informazioni.  Le patch che modificano le interfacce utente dovrebbero
     essere inviate in copia anche a [email protected].
 
Documentation/translations/sp_SP/process/submit-checklist.rst +1 -1
index 0d6651f9d871..3087ba80e818 100644
@@ -97,7 +97,7 @@ y en otros lugares con respecto al envío de parches del kernel de Linux.
     ``MODULE_PARM_DESC()``.
 
 18) Todas las nuevas interfaces de espacio de usuario están documentadas
-    en ``Documentation/ABI/``. Consulte ``Documentation/ABI/README`` para
+    en ``Documentation/ABI/``. Consulte Documentation/ABI/README para
     obtener más información. Los parches que cambian las interfaces del
     espacio de usuario deben ser CCed a [email protected].
 
Documentation/translations/zh_CN/process/submit-checklist.rst +1 -1
index 10536b74aeec..5c20a7f0936b 100644
@@ -82,7 +82,7 @@ Linux内核补丁提交检查单
 17) 所有新的模块参数都记录在 ``MODULE_PARM_DESC()``
 
 18) 所有新的用户空间接口都记录在 ``Documentation/ABI/`` 中。有关详细信息,
-    请参阅 ``Documentation/ABI/README`` 。更改用户空间接口的补丁应该抄送
+    请参阅 Documentation/ABI/README 。更改用户空间接口的补丁应该抄送
     [email protected]。
 
 19) 已通过至少注入slab和page分配失败进行检查。请参阅 ``Documentation/fault-injection/`` 。
Documentation/translations/zh_TW/process/submit-checklist.rst +1 -1
index 0ecb187753e4..b09d29b0cc1b 100644
@@ -85,7 +85,7 @@ Linux內核補丁提交檢查單
 17) 所有新的模塊參數都記錄在 ``MODULE_PARM_DESC()``
 
 18) 所有新的用戶空間接口都記錄在 ``Documentation/ABI/`` 中。有關詳細信息,
-    請參閱 ``Documentation/ABI/README`` 。更改用戶空間接口的補丁應該抄送
+    請參閱 Documentation/ABI/README 。更改用戶空間接口的補丁應該抄送
     [email protected]。
 
 19) 已通過至少注入slab和page分配失敗進行檢查。請參閱 ``Documentation/fault-injection/`` 。
Signature · 1 line
2.48.1
#11 lore raw
In reply to Mauro Carvalho Chehab
Quoted 2 lines · Mauro Carvalho Chehab

Now that ABI creates a python dictionary, use automarkup to create cross references for ABI symbols as well.

I get three new warnings:

WARNING: /sys/devices/system/cpu/cpuX/topology/physical_package_id is defined 2 times: /home/bagas/repo/linux-kernel/Documentation/ABI/stable/sysfs-devices-system-cpu:27; /home/bagas/repo/linux-kernel/Documentation/ABI/testing/sysfs-devices-system-cpu:70
WARNING: /sys/devices/system/cpu/cpuX/topology/ppin is defined 2 times: /home/bagas/repo/linux-kernel/Documentation/ABI/stable/sysfs-devices-system-cpu:89; /home/bagas/repo/linux-kernel/Documentation/ABI/testing/sysfs-devices-system-cpu:70
WARNING: Documentation/ABI/testing/sysfs-class-cxl not found

Thanks.

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#12 lore raw

Em Wed, 12 Feb 2025 18:25:15 +0700
Bagas Sanjaya <[email protected]> escreveu:

Quoted 8 lines · Mauro Carvalho Chehab
Quoted 2 lines

Now that ABI creates a python dictionary, use automarkup to create cross references for ABI symbols as well.

I get three new warnings:

WARNING: /sys/devices/system/cpu/cpuX/topology/physical_package_id is defined 2 times: /home/bagas/repo/linux-kernel/Documentation/ABI/stable/sysfs-devices-system-cpu:27; /home/bagas/repo/linux-kernel/Documentation/ABI/testing/sysfs-devices-system-cpu:70
WARNING: /sys/devices/system/cpu/cpuX/topology/ppin is defined 2 times: /home/bagas/repo/linux-kernel/Documentation/ABI/stable/sysfs-devices-system-cpu:89; /home/bagas/repo/linux-kernel/Documentation/ABI/testing/sysfs-devices-system-cpu:70

Those two are new reports that get_abi.py detects after the recent changes. In the past, symbol duplication were detected only within the same group (testing, stable, ...). The new version can detect symbols that are duplicated on different parts of the ABI. In this specific case, the same symbols exist on both stable and testing.

There is a fix for them already at:

https://lore.kernel.org/linux-doc/673e9543783349b0fcf625018e38e4e93fe98f52.1738020236.git.mchehab+huawei@kernel.org/

Quoted 1 line

WARNING: Documentation/ABI/testing/sysfs-class-cxl not found

I need to double-check verify this one, as it didn't appear on my tests. Are you getting it against docs-next or linux-next?

Thanks,
Mauro

#13 lore raw
Quoted 5 lines · Mauro Carvalho Chehab
Quoted 1 line

WARNING: Documentation/ABI/testing/sysfs-class-cxl not found

I need to double-check verify this one, as it didn't appear on my tests. Are you getting it against docs-next or linux-next?

This is moved to obsolete/ by 5731d41af924b which was merged in rc1, and will be moved again to removed/ by [0].

Andrew

[0]
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/

Signature · 2 lines
Andrew Donnellan    OzLabs, ADL Canberra
[email protected]   IBM Australia Limited
maintainer
#14 lore raw
In reply to Mauro Carvalho Chehab
Quoted 4 lines · Mauro Carvalho Chehab
Quoted 1 line

WARNING: Documentation/ABI/testing/sysfs-class-cxl not found

I need to double-check verify this one, as it didn't appear on my tests. Are you getting it against docs-next or linux-next?

I get this one too, FWIW.

I've gone ahead and applied the series, but this would be nice to get cleaned up.

Thanks,

jon