[PATCH for-10.2 1/8] docs/sphinx/kerneldoc.py: Handle new LINENO syntax

Peter Maydell posted 8 patches 3 months ago
[PATCH for-10.2 1/8] docs/sphinx/kerneldoc.py: Handle new LINENO syntax
Posted by Peter Maydell 3 months ago
The new upstream kernel-doc that we plan to update to uses a different
syntax for the LINENO directives that the Sphinx extension parses:
instead of
  #define LINENO 86
it has
  .. LINENO 86

Update the kerneldoc.py extension to handle both syntaxes, so
that it will work with both the old and the new kernel-doc.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 docs/sphinx/kerneldoc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
index 3aa972f2e89..30bb3431983 100644
--- a/docs/sphinx/kerneldoc.py
+++ b/docs/sphinx/kerneldoc.py
@@ -127,7 +127,7 @@ def run(self):
             result = ViewList()
 
             lineoffset = 0;
-            line_regex = re.compile("^#define LINENO ([0-9]+)$")
+            line_regex = re.compile(r"^(?:\.\.|#define) LINENO ([0-9]+)$")
             for line in lines:
                 match = line_regex.search(line)
                 if match:
-- 
2.43.0
Re: [PATCH for-10.2 1/8] docs/sphinx/kerneldoc.py: Handle new LINENO syntax
Posted by Mauro Carvalho Chehab 3 months ago
Em Thu, 14 Aug 2025 18:13:16 +0100
Peter Maydell <peter.maydell@linaro.org> escreveu:

> The new upstream kernel-doc that we plan to update to uses a different
> syntax for the LINENO directives that the Sphinx extension parses:
> instead of
>   #define LINENO 86
> it has
>   .. LINENO 86
> 
> Update the kerneldoc.py extension to handle both syntaxes, so
> that it will work with both the old and the new kernel-doc.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

LGTM.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

> ---
>  docs/sphinx/kerneldoc.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/docs/sphinx/kerneldoc.py b/docs/sphinx/kerneldoc.py
> index 3aa972f2e89..30bb3431983 100644
> --- a/docs/sphinx/kerneldoc.py
> +++ b/docs/sphinx/kerneldoc.py
> @@ -127,7 +127,7 @@ def run(self):
>              result = ViewList()
>  
>              lineoffset = 0;
> -            line_regex = re.compile("^#define LINENO ([0-9]+)$")
> +            line_regex = re.compile(r"^(?:\.\.|#define) LINENO ([0-9]+)$")
>              for line in lines:
>                  match = line_regex.search(line)
>                  if match:



Thanks,
Mauro