Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: automarkup: linkify git revs

There aren't a ton of references to commits in the documentation, but
they do exist, and we can use automarkup to linkify them to make them
easier to follow.

Use something like this to find references to commits:

git grep -P 'commit.*[0-9a-f]{8,}' Documentation/

Also fix a few of these to standardize on the exact format that is
already used in changelogs.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20231027115420.205279-1-vegard.nossum@oracle.com

authored by

Vegard Nossum and committed by
Jonathan Corbet
86b17aaf d591aefc

+39 -18
+1 -1
Documentation/arch/x86/boot.rst
··· 71 71 72 72 Protocol 2.14 BURNT BY INCORRECT COMMIT 73 73 ae7e1238e68f2a472a125673ab506d49158c1889 74 - (x86/boot: Add ACPI RSDP address to setup_header) 74 + ("x86/boot: Add ACPI RSDP address to setup_header") 75 75 DO NOT USE!!! ASSUME SAME AS 2.13. 76 76 77 77 Protocol 2.15 (Kernel 5.5) Added the kernel_info and kernel_info.setup_type_max.
+2 -4
Documentation/bpf/btf.rst
··· 272 272 * ``BTF_INT_OFFSET()`` must be 0. 273 273 * ``BTF_INT_BITS()`` must be equal to ``{1,2,4,8,16} * 8``. 274 274 275 - The following kernel patch introduced ``kind_flag`` and explained why both 276 - modes exist: 277 - 278 - https://github.com/torvalds/linux/commit/9d5f9f701b1891466fb3dbb1806ad97716f95cc3#diff-fa650a64fdd3968396883d2fe8215ff3 275 + Commit 9d5f9f701b18 introduced ``kind_flag`` and explains why both modes 276 + exist. 279 277 280 278 2.2.6 BTF_KIND_ENUM 281 279 ~~~~~~~~~~~~~~~~~~~
+9
Documentation/doc-guide/sphinx.rst
··· 435 435 For information on cross-referencing to kernel-doc functions or types, see 436 436 Documentation/doc-guide/kernel-doc.rst. 437 437 438 + Referencing commits 439 + ~~~~~~~~~~~~~~~~~~~ 440 + 441 + References to git commits are automatically hyperlinked given that they are 442 + written in one of these formats:: 443 + 444 + commit 72bf4f1767f0 445 + commit 72bf4f1767f0 ("net: do not leave an empty skb in write queue") 446 + 438 447 .. _sphinx_kfigure: 439 448 440 449 Figures & Images
+2 -2
Documentation/livepatch/callbacks.rst
··· 110 110 ------------------ 111 111 112 112 A pre-patch callback can be useful to update a global variable. For 113 - example, 75ff39ccc1bd ("tcp: make challenge acks less predictable") 113 + example, commit 75ff39ccc1bd ("tcp: make challenge acks less predictable") 114 114 changes a global sysctl, as well as patches the tcp_send_challenge_ack() 115 115 function. 116 116 ··· 126 126 may be possible to implement similar updates via pre/post-patch 127 127 callbacks. 128 128 129 - The commit ``48900cb6af42 ("virtio-net: drop NETIF_F_FRAGLIST")`` change the way that 129 + The commit 48900cb6af42 ("virtio-net: drop NETIF_F_FRAGLIST") change the way that 130 130 virtnet_probe() initialized its driver's net_device features. A 131 131 pre/post-patch callback could iterate over all such devices, making a 132 132 similar change to their hw_features value. (Client functions of the
+6 -10
Documentation/networking/snmp_counter.rst
··· 313 313 314 314 * TcpExtTCPOrigDataSent 315 315 316 - This counter is explained by `kernel commit f19c29e3e391`_, I pasted the 316 + This counter is explained by kernel commit f19c29e3e391, I pasted the 317 317 explanation below:: 318 318 319 319 TCPOrigDataSent: number of outgoing packets with original data (excluding ··· 323 323 324 324 * TCPSynRetrans 325 325 326 - This counter is explained by `kernel commit f19c29e3e391`_, I pasted the 326 + This counter is explained by kernel commit f19c29e3e391, I pasted the 327 327 explanation below:: 328 328 329 329 TCPSynRetrans: number of SYN and SYN/ACK retransmits to break down ··· 331 331 332 332 * TCPFastOpenActiveFail 333 333 334 - This counter is explained by `kernel commit f19c29e3e391`_, I pasted the 334 + This counter is explained by kernel commit f19c29e3e391, I pasted the 335 335 explanation below:: 336 336 337 337 TCPFastOpenActiveFail: Fast Open attempts (SYN/data) failed because 338 338 the remote does not accept it or the attempts timed out. 339 - 340 - .. _kernel commit f19c29e3e391: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f19c29e3e391a66a273e9afebaf01917245148cd 341 339 342 340 * TcpExtListenOverflows and TcpExtListenDrops 343 341 ··· 696 698 of the function tcp_is_sackblock_valid in the kernel source code. A 697 699 SACK option could have up to 4 blocks, they are checked 698 700 individually. E.g., if 3 blocks of a SACk is invalid, the 699 - corresponding counter would be updated 3 times. The comment of the 700 - `Add counters for discarded SACK blocks`_ patch has additional 701 - explanation: 702 - 703 - .. _Add counters for discarded SACK blocks: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=18f02545a9a16c9a89778b91a162ad16d510bb32 701 + corresponding counter would be updated 3 times. The comment of commit 702 + 18f02545a9a1 ("[TCP] MIB: Add counters for discarded SACK blocks") 703 + has additional explanation: 704 704 705 705 * TcpExtTCPSACKDiscard 706 706
+19 -1
Documentation/sphinx/automarkup.py
··· 74 74 75 75 c_namespace = '' 76 76 77 + # 78 + # Detect references to commits. 79 + # 80 + RE_git = re.compile(r'commit\s+(?P<rev>[0-9a-f]{12,40})(?:\s+\(".*?"\))?', 81 + flags=re.IGNORECASE | re.DOTALL) 82 + 77 83 def markup_refs(docname, app, node): 78 84 t = node.astext() 79 85 done = 0 ··· 96 90 RE_struct: markup_c_ref, 97 91 RE_union: markup_c_ref, 98 92 RE_enum: markup_c_ref, 99 - RE_typedef: markup_c_ref} 93 + RE_typedef: markup_c_ref, 94 + RE_git: markup_git} 100 95 101 96 if sphinx.version_info[0] >= 3: 102 97 markup_func = markup_func_sphinx3 ··· 282 275 if match: 283 276 return match.group(1) 284 277 return '' 278 + 279 + def markup_git(docname, app, match): 280 + # While we could probably assume that we are running in a git 281 + # repository, we can't know for sure, so let's just mechanically 282 + # turn them into git.kernel.org links without checking their 283 + # validity. (Maybe we can do something in the future to warn about 284 + # these references if this is explicitly requested.) 285 + text = match.group(0) 286 + rev = match.group('rev') 287 + return nodes.reference('', nodes.Text(text), 288 + refuri=f'https://git.kernel.org/torvalds/c/{rev}') 285 289 286 290 def auto_markup(app, doctree, name): 287 291 global c_namespace