Skip to content

Commit b97f193

Browse files
mchehabJonathan Corbet
authored andcommitted
scripts/kernel-doc: fix parser for apostrophes
On ReST, adding a text like ``literal`` is valid. However, the kernel-doc script won't handle it fine. We really need this feature, in order to escape things like %ph, with is found on some C files. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
1 parent c46988a commit b97f193

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

scripts/kernel-doc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ EOF
202202
# '&struct_name.member' - name of a structure member
203203
# '@parameter' - name of a parameter
204204
# '%CONST' - name of a constant.
205+
# '``LITERAL``' - literal string without any spaces on it.
205206

206207
## init lots of data
207208

@@ -210,7 +211,8 @@ my $warnings = 0;
210211
my $anon_struct_union = 0;
211212

212213
# match expressions used to find embedded type information
213-
my $type_constant = '\%([-_\w]+)';
214+
my $type_constant = '\b``([^\`]+)``\b';
215+
my $type_constant2 = '\%([-_\w]+)';
214216
my $type_func = '(\w+)\(\)';
215217
my $type_param = '\@(\w+(\.\.\.)?)';
216218
my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params
@@ -235,6 +237,7 @@ my $type_member_func = $type_member . '\(\)';
235237
# these work fairly well
236238
my @highlights_html = (
237239
[$type_constant, "<i>\$1</i>"],
240+
[$type_constant2, "<i>\$1</i>"],
238241
[$type_func, "<b>\$1</b>"],
239242
[$type_enum_xml, "<i>\$1</i>"],
240243
[$type_struct_xml, "<i>\$1</i>"],
@@ -252,6 +255,7 @@ my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"
252255
# html version 5
253256
my @highlights_html5 = (
254257
[$type_constant, "<span class=\"const\">\$1</span>"],
258+
[$type_constant2, "<span class=\"const\">\$1</span>"],
255259
[$type_func, "<span class=\"func\">\$1</span>"],
256260
[$type_enum_xml, "<span class=\"enum\">\$1</span>"],
257261
[$type_struct_xml, "<span class=\"struct\">\$1</span>"],
@@ -268,6 +272,7 @@ my $blankline_html5 = $local_lt . "br /" . $local_gt;
268272
my @highlights_xml = (
269273
["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"],
270274
[$type_constant, "<constant>\$1</constant>"],
275+
[$type_constant2, "<constant>\$1</constant>"],
271276
[$type_enum_xml, "<type>\$1</type>"],
272277
[$type_struct_xml, "<structname>\$1</structname>"],
273278
[$type_typedef_xml, "<type>\$1</type>"],
@@ -283,6 +288,7 @@ my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $loca
283288
# gnome, docbook format
284289
my @highlights_gnome = (
285290
[$type_constant, "<replaceable class=\"option\">\$1</replaceable>"],
291+
[$type_constant2, "<replaceable class=\"option\">\$1</replaceable>"],
286292
[$type_func, "<function>\$1</function>"],
287293
[$type_enum, "<type>\$1</type>"],
288294
[$type_struct, "<structname>\$1</structname>"],
@@ -298,6 +304,7 @@ my $blankline_gnome = "</para><para>\n";
298304
# these are pretty rough
299305
my @highlights_man = (
300306
[$type_constant, "\$1"],
307+
[$type_constant2, "\$1"],
301308
[$type_func, "\\\\fB\$1\\\\fP"],
302309
[$type_enum, "\\\\fI\$1\\\\fP"],
303310
[$type_struct, "\\\\fI\$1\\\\fP"],
@@ -312,6 +319,7 @@ my $blankline_man = "";
312319
# text-mode
313320
my @highlights_text = (
314321
[$type_constant, "\$1"],
322+
[$type_constant2, "\$1"],
315323
[$type_func, "\$1"],
316324
[$type_enum, "\$1"],
317325
[$type_struct, "\$1"],
@@ -326,6 +334,7 @@ my $blankline_text = "";
326334
# rst-mode
327335
my @highlights_rst = (
328336
[$type_constant, "``\$1``"],
337+
[$type_constant2, "``\$1``"],
329338
# Note: need to escape () to avoid func matching later
330339
[$type_member_func, "\\:c\\:type\\:`\$1\$2\$3\\\\(\\\\) <\$1>`"],
331340
[$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"],
@@ -344,6 +353,7 @@ my $blankline_rst = "\n";
344353
# list mode
345354
my @highlights_list = (
346355
[$type_constant, "\$1"],
356+
[$type_constant2, "\$1"],
347357
[$type_func, "\$1"],
348358
[$type_enum, "\$1"],
349359
[$type_struct, "\$1"],

0 commit comments

Comments
 (0)