[PATCH v2] Sphinx error fixed for inline literal end-string by changing $type_constant2 in kernel-doc script to include "*" unicode character in highlights_rst.

From: Utkarsh Tripathi
Date: Wed May 01 2024 - 14:06:10 EST


Hello,

On Wed, 1 May 2024 19:02:40 +0530, Utkarsh Tripathi wrote:
> Fixed Error in Workqueue Documentation in the kernel-doc comment
> for alloc_workqueue function in include/linux/workqueue.h,
> the error was "Inline literal start-string without end-string"
> which was fixed by removing the inline literal.
> Kernel Version - 6.9.0-rc5
>
> Signed-off-by: Utkarsh Tripathi <utripathi2002@xxxxxxxxx>

There was a slightly different patch submission on the same issue the
other day. You might be interested in seeing my response to it [1].

[1]: https://lore.kernel.org/r/6875fb17-f781-4594-803a-c11969f36022@xxxxxxxxx/

Quoting below for your convenience:

> In my opinion, reST-specific clutters like these should be avoided in
> kernel-doc comments as far as possible.
>
> Instead, I think you can educate kernel-doc (script) so that "*" is
> allowed in the %CONSTANT pattern, meaning %WQ_* can be converted
> to ``WQ_*`` in reST.
>
> For similar changes made against the @param pattern, see commits
> 69fc23efc7e5 ("kernel-doc: Add unary operator * to $type_param_ref")
> and 8aaf297a0dd6 ("docs: scripts: kernel-doc: accept bitwise negation
> like ~@var").
>
> I guess it is $type_constant2 that needs a tweak in this case.

Unfortunately, there's been no patch submission in this direction so far.
I'd be delighted if you can try this approach instead.

Thanks, Akira

The kernel-doc script uses the $type_constant2 variable to match
expressions used to find embedded type information. The current
implementation of $type_constant2 does not include the "*" unicode
character, which is used to highlight inline literals in the
documentation. This causes a Sphinx error when the inline literal
end-string is used in the documentation.

This commit follows the pattern of the commit
8aaf297a0dd6 ("docs: scripts: kernel-doc: accept bitwise negation like ~@var")
and takes inspiration from the following commit
69fc23efc7e5 ("kernel-doc: Add unary operator * to $type_param_ref").

Thanks Akira, for your suggestions, I have made the required changes.
I am fairly new to the kernel community, so if I am making
any mistakes while making patches and replying to mails,
please let me know, it will be very helpful.
Sorry, I mailed without adding the previous replies in the mail.

Signed-off-by: Utkarsh Tripathi <utripathi2002@xxxxxxxxx>
Reviewed-by: Akira Yokosawa <akiyks@xxxxxxxxx>
Suggested-by: Akira Yokosawa <akiyks@xxxxxxxxx>
---
scripts/kernel-doc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index cb1be22afc65..58129b1cf3f4 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -62,7 +62,7 @@ my $anon_struct_union = 0;

# match expressions used to find embedded type information
my $type_constant = '\b``([^\`]+)``\b';
-my $type_constant2 = '\%([-_\w]+)';
+my $type_constant2 = '\%([-_*\w]+)';
my $type_func = '(\w+)\(\)';
my $type_param = '\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';
my $type_param_ref = '([\!~\*]?)\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)';

base-commit: 4d2008430ce87061c9cefd4f83daf2d5bb323a96
--
2.34.1