Jonathan Corbet
e4153a2255
docs: kdoc: separate out the handling of the declaration phase
...
The BODY_MAYBE state really describes the "we are in a declaration" state.
Rename it accordingly, and split the handling of this state out from that
of the other BODY* states. This change introduces a fair amount of
duplicated code that will be coalesced in a later patch.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250621203512.223189-4-corbet@lwn.net
2025-06-25 11:30:26 -06:00
Jonathan Corbet
df27552694
docs: kdoc: consolidate the "begin section" logic
...
Pull the repeated "begin a section" logic into a single place and hide it
within the KernelEntry class.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250621203512.223189-3-corbet@lwn.net
2025-06-25 11:30:26 -06:00
Jonathan Corbet
823d6f9566
docs: kdoc: Make body_with_blank_line parsing more flexible
...
The regex in the BODY_WITH_BLANK_LINE case was looking for lines starting
with " * ", where exactly one space was allowed before the following text.
There are many kerneldoc comments where the authors have put multiple
spaces instead, leading to mis-formatting of the documentation.
Specifically, in this case, the description portion is associated with the
last of the parameters.
Allow multiple spaces in this context.
See, for example, synchronize_hardirq() and how its documentation is
formatted before and after the change.
Acked-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Tested-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250621203512.223189-2-corbet@lwn.net
2025-06-25 11:30:26 -06:00
Jonathan Corbet
8666a352dc
docs: kdoc: some final touches for process_name()
...
Add some comments to process_name() to cover its broad phases of operation,
and slightly restructure the if/then/else structure to remove some early
returns.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-10-corbet@lwn.net
2025-06-09 14:37:17 -06:00
Jonathan Corbet
0682bde2c7
docs: kdoc: move the declaration regexes out of process_name()
...
Move two complex regexes up with the other patterns, decluttering this
function and allowing the compilation to be done once rather than for every
kerneldoc comment.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-9-corbet@lwn.net
2025-06-09 14:37:17 -06:00
Jonathan Corbet
b23c71080b
docs: kdoc: remove some ineffective code
...
The code testing for a pointer declaration in process_name() has no actual
effect on subsequent actions; remove it.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-8-corbet@lwn.net
2025-06-09 14:37:17 -06:00
Jonathan Corbet
f9b4cf2e85
docs: kdoc: remove the KernelEntry::descr pseudo member
...
The entry.descr value used in process_name() is not actually a member of
the KernelEntry class; it is a bit of local state. So just manage it
locally.
A trim_whitespace() helper was added to clean up the code slightly.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-7-corbet@lwn.net
2025-06-09 14:37:17 -06:00
Jonathan Corbet
8f4650fe1a
docs: kdoc: remove the KernelEntry::is_kernel_comment member
...
entry::is_kernel_comment never had anything to do with the entry itself; it
is a bit of local state in one branch of process_name(). It can, in fact,
be removed entirely; rework the code slightly so that it is no longer
needed.
No change in the rendered output.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-6-corbet@lwn.net
2025-06-09 14:37:17 -06:00
Jonathan Corbet
e76a1d2b26
docs: kdoc: simplify the kerneldoc recognition code
...
process_name() looks for the first line of a kerneldoc comment. It
contains two nearly identical regular expressions, the second of which only
catches six cases in the kernel, all of the form:
define SOME_MACRO_NAME - description
Simply put the "define" into the regex and discard it, eliminating the loop
and the code to remove it specially.
Note that this still treats these defines as if they were functions, but
that's a separate issue.
There is no change in the generated output.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-5-corbet@lwn.net
2025-06-09 14:37:17 -06:00
Jonathan Corbet
42592bd46d
docs: kdoc: remove the section_intro variable
...
It is only used in one place, so just put the constant string
"Introduction" there so people don't have to go looking for it.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-4-corbet@lwn.net
2025-06-09 14:37:16 -06:00
Jonathan Corbet
cef8c781ca
docs: kdoc: move the core dispatch into a state table
...
Since all of the handlers already nicely have the same prototype, put them
into a table and call them from there and take out the extended
if-then-else series.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-3-corbet@lwn.net
2025-06-09 14:37:16 -06:00
Jonathan Corbet
e8f0303e8b
docs: kdoc: simplify the PROTO continuation logic
...
Remove the unneeded "cont" variable and tighten up the code slightly.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606163438.229916-2-corbet@lwn.net
2025-06-09 14:37:16 -06:00
Matthew Wilcox (Oracle)
27ad33b6b3
kernel-doc: Fix symbol matching for dropped suffixes
...
The support for dropping "_noprof" missed dropping the suffix from
exported symbols. That meant that using the :export: feature would
look for kernel-doc for (eg) krealloc_noprof() and not find the
kernel-doc for krealloc().
Fixes: 51a7bf0238 (scripts/kernel-doc: drop "_noprof" on function prototypes)
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org >
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/20250606141543.1285671-1-willy@infradead.org
2025-06-09 12:36:40 -06:00
Mauro Carvalho Chehab
27565cfcd7
scripts: kernel-doc: prevent a KeyError when checking output
...
If a file sent to KernelFiles.msg() method doesn't exist, instead
of producing a KeyError, output an error message.
Reported-by: Randy Dunlap <rdunlap@infradead.org >
Closes: https://lore.kernel.org/linux-doc/cover.1747719873.git.mchehab+huawei@kernel.org/T/#ma43ae9d8d0995b535cf5099e5381dace0410de04
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Acked-by: Akira Yokosawa <akiyks@gmail.com >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Message-ID: <4efa177f2157a7ec009cc197dfc2d87e6f32b165.1747817887.git.mchehab+huawei@kernel.org >
2025-05-21 03:53:40 -06:00
Mauro Carvalho Chehab
e3b42e94cf
scripts/lib/kdoc/kdoc_parser.py: move kernel entry to a class
...
The KernelDoc class is too complex. Start optimizing it by
placing the kernel-doc parser entry to a separate class.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Message-ID: <28b456f726a022011f0ce5810dbcc26827c1403a.1745564565.git.mchehab+huawei@kernel.org >
2025-04-28 17:28:14 -06:00
Mauro Carvalho Chehab
a4bd43d6f7
scripts/lib/kdoc: change mode to 0644
...
The script library here contain just classes. Remove execution
permission.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Message-ID: <be0b0a5bde82fa09027a5083f8202f150581eb4e.1745564565.git.mchehab+huawei@kernel.org >
2025-04-28 17:28:14 -06:00
Mauro Carvalho Chehab
47c2d4168b
scripts:kdoc_files.py: use glob for export_file seek
...
As filenames are expanded using kernel-doc glob, just in case,
use it also when checking for exported symbols.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/21657afdd4f8effe0752a5ec258d74b8a4101f55.1744685912.git.mchehab+huawei@kernel.org
2025-04-21 10:39:17 -06:00
Mauro Carvalho Chehab
f9cdbc5781
scripts/lib/kdoc/kdoc_parser.py: move states to a separate class
...
States are really enums. on Python, enums are actually classes,
as can be seen at:
https://docs.python.org/3/library/enum.html
Yet, I can't see any advantage of derivating the class from
enum class here. So, just place the states on a separate class.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/00cb4e0b8a1545bf7c4401b58213841db5cba2e2.1744685912.git.mchehab+huawei@kernel.org
2025-04-21 10:39:17 -06:00
Mauro Carvalho Chehab
439111ee0c
scripts/lib/kdoc/kdoc_files.py: don't try to join None
...
If out_msg() returns None, it means that an unknown declaration
was found. Avoid letting the script crash on such case.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/4334d16f14cfd93e611b290fb56c35d236cadcb7.1744685912.git.mchehab+huawei@kernel.org
2025-04-21 10:39:17 -06:00
Sean Anderson
de258fa8ca
scripts: kernel-doc: fix parsing function-like typedefs (again)
...
Typedefs like
typedef struct phylink_pcs *(*pcs_xlate_t)(const u64 *args);
have a typedef_type that ends with a * and therefore has no word
boundary. Add an extra clause for the final group of the typedef_type so
we only require a word boundary if we match a word.
[mchehab: modify also kernel-doc.py, as we're deprecating the perl version]
Fixes: 7d2c6b1edf ("scripts: kernel-doc: fix parsing function-like typedefs")
Signed-off-by: Sean Anderson <sean.anderson@linux.dev >
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/e0abb103c73a96d76602d909f60ab8fd6e2fd0bd.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
04a383ced6
scripts/kernel-doc.py: Rename the kernel doc Re class to KernRe
...
Using just "Re" makes it harder to distinguish from the native
"re" class. So, let's rename it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/4e095ecd5235a3e811ddcf5bad4cfb92f1da0a4a.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
16740c29db
scripts/kernel_doc.py: better handle exported symbols
...
Change the logic which detects internal/external symbols in a way
that we can re-use it when calling via Sphinx extension.
While here, remove an unused self.config var and let it clearer
that self.config variables are read-only. This helps to allow
handling multiple times in parallel if ever needed.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/6a69ba8d2b7ee6a6427abb53e60d09bd4d3565ee.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
a566ba5af5
scripts/lib/kdoc/kdoc_files.py: allow filtering output per fname
...
For kerneldoc Sphinx extension, it is useful to display
parsed results only from a single file. Change the logic at
KernelFiles.msg() to allow such usage.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/9f5c0ff2568f34532ca99465fb378241d831d39f.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
11afeab6d7
scripts/kernel-doc.py: Properly handle Werror and exit codes
...
The original kernel-doc script has a logic to return warnings
as errors, and to report the number of warnings found, if in
verbose mode.
Implement it to be fully compatible with the original script.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/de33b0cebd9fdf82d8b221bcfe41db7269286222.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
e4b2bd908c
scripts/lib/kdoc/kdoc_parser.py: remove a python 3.9 dependency
...
str.removesuffix() was added on Python 3.9, but rstrip()
actually does the same thing, as we just want to remove a single
character. It is also shorter.
So, use it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/f64cc4adef107ada26da4bfb7e4b7002dd783173.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
91d00bd54f
scripts/kernel-doc.py: properly handle KBUILD_BUILD_TIMESTAMP
...
The logic that handles KBUILD_BUILD_TIMESTAMP is wrong, and adds
a dependency of a third party module (dateutil).
Fix it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/ffc70a1b741b010365ed82f31611018f24f91ce7.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
2ab867a494
scripts/kernel-doc.py: move modulename to man class
...
Only man output requires a modulename. Move its definition
to the man class.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/583085e3885b0075d16ef9961b4f2ad870f30a55.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
78ea748f79
scripts/lib/kdoc/kdoc_parser.py: fix Python compat with < v3.13
...
- str.replace count was introduced only in Python 3.13;
- before Python 3.13, f-string dict arguments can't use the same
delimiter of the main string.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/e2b8e8361294558dae09236e4b8fbea5d86be5a3.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
485f6f7960
scripts/kernel-doc.py: adjust some coding style issues
...
Make pylint happier by adding some missing documentation and
addressing a couple of pylint warnings.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/0f9d5473105e4c09c6c41e3db72cc63f1d4d55f9.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
43ecfe6bc2
scripts/kernel-doc.py: Set an output format for --none
...
Now that warnings output is deferred to the output plugin, we
need to have an output style for none as well.
So, use the OutputFormat base class on such cases.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/caa1089e16f4609f792ff26731ad9e9c3a6f6b1d.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:34 -06:00
Mauro Carvalho Chehab
9cbc2d3b13
scripts/kernel-doc.py: postpone warnings to the output plugin
...
We don't want to have warnings displayed for symbols that
weren't output. So, postpone warnings print to the output
plugin, where symbol output is validated.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/e6344711e390cf22af02a56bb5dd51ca67c0afb6.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
9235ec5e2b
scripts/kernel-doc.py: properly handle out_section for ReST
...
There is a difference at the way DOC sections are output with
the include mode. Handle such difference properly.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/935d00c6a7c45b25a8be72fad6183fe5a8476cd2.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
408269ae35
scripts/kernel-doc.py: fix handling of doc output check
...
The filtering logic was seeking for the DOC name to check for
symbols, but such data is stored only inside a section. Add it
to the output_declaration, as it is quicker/easier to check
the declaration name than to check inside each section.
While here, make sure that the output for both ReST and man
after filtering will be similar to what kernel-doc Perl
version does.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/6d8b77af85295452c0191863ea1041f4195aeaaf.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
c3597ab27b
scripts/kernel-doc.py: fix line number output
...
With the Pyhton version, the actual output happens after parsing,
from records stored at self.entries.
Ensure that line numbers will be properly stored there and
that they'll produce the desired results at the ReST output.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/5182a531d14b5fe9e1fc5da5f9dae05d66852a60.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
0873e55433
scripts/kernel-doc.py: implement support for -no-doc-sections
...
The venerable kernel-doc Perl script has a number of options that
aren't properly documented. Among them, there is -no-doc-sections,
which is used by the Sphinx extension.
Implement support for it.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/06b18a32142b44d5ba8b41ac64a76c02b03b4969.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
799b0d2a2a
scripts/kernel-doc.py: move file lists to the parser function
...
Instead of setting file lists at __init__ time, move it to
the actual parsing function. This allows adding more files
to be parsed in real time, by calling parse function multiple
times.
With the new way, the export_files logic was rewritten to
avoid parsing twice EXPORT_SYMBOL for partial matches.
Please notice that, with this logic, it can still read the
same file twice when export_file is used.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/ab10bc94050406ce6536d4944b5d718ecd70812f.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
4fa5e41137
scripts/kernel-doc.py: convert message output to an interactor
...
Instead of directly printing output messages, change kdoc classes
to return an interactor with the output message, letting the
actual display to happen at the command-line command.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/557304c8458f1fb4aa2e833f4bdaff953094ddcb.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
1d6fea640e
scripts/kernel-doc.py: move output classes to a separate file
...
In preparation for letting kerneldoc Sphinx extension to import
Python libraries, move kernel-doc output logic to a separate file.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/81087eff25d11c265019a8631f7fc8d3904795d0.1744106242.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
ee13b3f35c
scripts/kernel-doc.py: move KernelFiles class to a separate file
...
The KernelFiles class is the main dispatcher which parses each
source file.
In preparation for letting kerneldoc Sphinx extension to import
Python libraries, move regex ancillary classes to a separate
file.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/80bc855e128a9ff0a11df5afe9ba71775dfc9a0f.1744106241.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
d966dc658c
scripts/kernel-doc.py: move KernelDoc class to a separate file
...
In preparation for letting kerneldoc Sphinx extension to import
Python libraries, move regex ancillary classes to a separate
file.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/c76df228504e711c6b4bcd23d5a0ea1fda678cda.1744106241.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
e31fd36da9
scripts/kernel-doc.py: move regex methods to a separate file
...
In preparation for letting kerneldoc Sphinx extension to import
Python libraries, move regex ancillary classes to a separate
file.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/64f96b6744435b51894bb4ab7612851d9d054190.1744106241.git.mchehab+huawei@kernel.org
2025-04-09 12:10:33 -06:00
Mauro Carvalho Chehab
de61d6515b
docs: ABI: move README contents to the top
...
The ABI documentation looks a little bit better if it starts
with the contents of the README is placed at the beginning.
Move it to the beginning of the ABI chapter. While here, improve
the README text and change the title that will be shown at the
html/pdf output to be coherent with both ABI file contents and
with the generated documentation output.
Suggested-by: Jonathan Corbet <corbet@lwn.net >
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Link: https://lore.kernel.org/r/20250211055809.1898623-1-mchehab+huawei@kernel.org
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
2025-02-13 09:47:44 -07:00
Mauro Carvalho Chehab
0d5fd96880
scripts/get_abi.py: add support for undefined ABIs
...
The undefined logic is complex and has lots of magic on it.
Implement it, using the same algorithm we have at get_abi.pl. Yet,
some tweaks to optimize performance and to make the code simpler
were added here:
- at the perl version, the tree graph had loops, so we had to
use BFS to traverse it. On this version, the graph is a tree,
so, it simplifies the what group for sysfs aliases;
- the logic which splits regular expressions into subgroups
was re-written to make it faster;
- it may optionally use multiple processes to search for symbol
matches;
- it has some additional debug levels.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/1529c255845d117696d5af57d8dc05554663afdf.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00
Mauro Carvalho Chehab
6649b42170
scripts/lib/abi/abi_parser.py: make it backward-compatible with Python 3.6
...
Despite being introduced on Python 3.6, the original implementation
was too limited: it doesn't accept anything but the argument.
Even on python 3.10.12, support was still limited, as more complex
operations cause SyntaxError:
Exception occurred:
File ".../linux/Documentation/sphinx/kernel_abi.py", line 48, in <module>
from get_abi import AbiParser
File ".../linux/scripts/lib/abi/abi_parser.py", line 525
msg += f"{part}\n{"-" * len(part)}\n\n"
^
SyntaxError: f-string: expecting '}'
Replace f-strings by normal string concatenation when it doesn't
work on Python 3.6.
Reported-by: Akira Yokosawa <akiyks@gmail.com >
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/41d2f85df134a46db46fed73a0f9697a3d2ae9ba.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00
Mauro Carvalho Chehab
dc525a7650
scripts/lib/abi/abi_parser.py: Rename title name for ABI files
...
This makes them look better when generating cross-references.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/e44574cb2796861d6acbce839068ed3ef385d16c.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00
Mauro Carvalho Chehab
c940816968
docs: sphinx/automarkup: add cross-references for ABI
...
Now that all ABI files are handled together, we can add a feature
at automarkup for it to generate cross-references for ABI symbols.
The cross-reference logic can produce references for all existing
files, except for README (as this is not parsed).
For symbols, they need to be an exact match of what it is
described at the docs, which is not always true due to wildcards.
If symbols at /sys /proc and /config are identical, a cross-reference
will be used.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/0b97a51b68b1c20127ad4a6a55658557fe0848d0.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00
Mauro Carvalho Chehab
5d7871d77f
docs: sphinx/kernel_abi: parse ABI files only once
...
Right now, the logic parses ABI files on 4 steps, one for each
directory. While this is fine in principle, by doing that, not
all symbol cross-references will be created.
Change the logic to do the parsing only once in order to get
a global dictionary to be used when creating ABI cross-references.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/5205c53838b6ea25f4cdd4cc1e3d17c0141e75a6.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00
Mauro Carvalho Chehab
98a4324a8b
scripts/get_abi.pl: add support to parse ABI README file
...
The Documentation/ABI/README file is currently outside the
documentation tree. Yet, it may still provide some useful
information. Add it to the documentation parsing.
As a plus, this avoids a warning when detecting missing
cross-references.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/f1285dedfe4d0eb0f0af34f6a68bee6fde36dd7d.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00
Mauro Carvalho Chehab
2a21d80dfb
scripts/get_abi.pl: Add filtering capabilities to rest output
...
This way, Sphinx ABI extension can parse symbols only once, while
keep displaying results in separate files.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/41e108e816e46434aa596e5c0d25d227cb9f0fe5.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00
Mauro Carvalho Chehab
aea5e52dce
docs: sphinx/kernel_abi: reduce buffer usage for ABI messages
...
Instead of producing a big message with all ABI contents and then
parse as a whole, simplify the code by handling each ABI symbol
in separate. As an additional benefit, there's no need to place
file/line nubers inlined at the data and use a regex to convert
them.
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org >
Signed-off-by: Jonathan Corbet <corbet@lwn.net >
Link: https://lore.kernel.org/r/15be22955e3c6df49d7256c8fd24f62b397ad0ff.1739182025.git.mchehab+huawei@kernel.org
2025-02-10 11:19:57 -07:00