aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/kernel-doc
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2017-01-02 10:22:27 -0500
committerJonathan Corbet <corbet@lwn.net>2017-01-04 17:08:14 -0500
commitdf31175bb4d372b99410034a8ac23ae5526f49d2 (patch)
tree40cd025d35f1245875def8fd3b92ed095727ad4e /scripts/kernel-doc
parent5267dd354bcd267f76d0f97193fe8a93899f8986 (diff)
kernel-doc: make highlights more homogenous for the various backends
$type_struct_full and friends are only used by the restructuredText backend, because it needs to separate enum/struct/typedef/union from the name of the type. However, $type_struct is *also* used by the rST backend. This is confusing. This patch replaces $type_struct's use in the rST backend with a new $type_fallback; it modifies $type_struct so that it can be used in the rST backend; and creates regular expressions like $type_struct for enum/typedef/union, for use in all backends. Note that, compared to $type_*_full, in the new regexes $1 includes both the "kind" and the name (before, $1 was pretty much a constant). Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'scripts/kernel-doc')
-rwxr-xr-xscripts/kernel-doc68
1 files changed, 50 insertions, 18 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index d5e9f765b4fc..4c9ada36fe6b 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -214,15 +214,19 @@ my $type_constant = '\%([-_\w]+)';
214my $type_func = '(\w+)\(\)'; 214my $type_func = '(\w+)\(\)';
215my $type_param = '\@(\w+(\.\.\.)?)'; 215my $type_param = '\@(\w+(\.\.\.)?)';
216my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params 216my $type_fp_param = '\@(\w+)\(\)'; # Special RST handling for func ptr params
217my $type_struct = '\&((struct\s*)*[_\w]+)';
218my $type_struct_xml = '\\&amp;((struct\s*)*[_\w]+)';
219my $type_env = '(\$\w+)'; 217my $type_env = '(\$\w+)';
220my $type_enum_full = '\&(enum)\s*([_\w]+)'; 218my $type_enum = '\&(enum\s*([_\w]+))';
221my $type_struct_full = '\&(struct)\s*([_\w]+)'; 219my $type_struct = '\&(struct\s*([_\w]+))';
222my $type_typedef_full = '\&(typedef)\s*([_\w]+)'; 220my $type_typedef = '\&(typedef\s*([_\w]+))';
223my $type_union_full = '\&(union)\s*([_\w]+)'; 221my $type_union = '\&(union\s*([_\w]+))';
224my $type_member = '\&([_\w]+)(\.|->)([_\w]+)'; 222my $type_member = '\&([_\w]+)(\.|->)([_\w]+)';
223my $type_fallback = '\&([_\w]+)';
224my $type_enum_xml = '\&amp;(enum\s*([_\w]+))';
225my $type_struct_xml = '\&amp;(struct\s*([_\w]+))';
226my $type_typedef_xml = '\&amp;(typedef\s*([_\w]+))';
227my $type_union_xml = '\&amp;(union\s*([_\w]+))';
225my $type_member_xml = '\&amp;([_\w]+)(\.|-\&gt;)([_\w]+)'; 228my $type_member_xml = '\&amp;([_\w]+)(\.|-\&gt;)([_\w]+)';
229my $type_fallback_xml = '\&amp([_\w]+)';
226my $type_member_func = $type_member . '\(\)'; 230my $type_member_func = $type_member . '\(\)';
227 231
228# Output conversion substitutions. 232# Output conversion substitutions.
@@ -232,10 +236,14 @@ my $type_member_func = $type_member . '\(\)';
232my @highlights_html = ( 236my @highlights_html = (
233 [$type_constant, "<i>\$1</i>"], 237 [$type_constant, "<i>\$1</i>"],
234 [$type_func, "<b>\$1</b>"], 238 [$type_func, "<b>\$1</b>"],
239 [$type_enum_xml, "<i>\$1</i>"],
235 [$type_struct_xml, "<i>\$1</i>"], 240 [$type_struct_xml, "<i>\$1</i>"],
241 [$type_typedef_xml, "<i>\$1</i>"],
242 [$type_union_xml, "<i>\$1</i>"],
236 [$type_env, "<b><i>\$1</i></b>"], 243 [$type_env, "<b><i>\$1</i></b>"],
237 [$type_param, "<tt><b>\$1</b></tt>"], 244 [$type_param, "<tt><b>\$1</b></tt>"],
238 [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"] 245 [$type_member_xml, "<tt><i>\$1</i>\$2\$3</tt>"],
246 [$type_fallback_xml, "<i>\$1</i>"]
239 ); 247 );
240my $local_lt = "\\\\\\\\lt:"; 248my $local_lt = "\\\\\\\\lt:";
241my $local_gt = "\\\\\\\\gt:"; 249my $local_gt = "\\\\\\\\gt:";
@@ -245,10 +253,14 @@ my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"
245my @highlights_html5 = ( 253my @highlights_html5 = (
246 [$type_constant, "<span class=\"const\">\$1</span>"], 254 [$type_constant, "<span class=\"const\">\$1</span>"],
247 [$type_func, "<span class=\"func\">\$1</span>"], 255 [$type_func, "<span class=\"func\">\$1</span>"],
256 [$type_enum_xml, "<span class=\"enum\">\$1</span>"],
248 [$type_struct_xml, "<span class=\"struct\">\$1</span>"], 257 [$type_struct_xml, "<span class=\"struct\">\$1</span>"],
258 [$type_typedef_xml, "<span class=\"typedef\">\$1</span>"],
259 [$type_union_xml, "<span class=\"union\">\$1</span>"],
249 [$type_env, "<span class=\"env\">\$1</span>"], 260 [$type_env, "<span class=\"env\">\$1</span>"],
250 [$type_param, "<span class=\"param\">\$1</span>]"], 261 [$type_param, "<span class=\"param\">\$1</span>]"],
251 [$type_member_xml, "<span class=\"literal\"><span class=\"struct\">\$1</span>\$2<span class=\"member\">\$3</span></span>"] 262 [$type_member_xml, "<span class=\"literal\"><span class=\"struct\">\$1</span>\$2<span class=\"member\">\$3</span></span>"],
263 [$type_fallback_xml, "<span class=\"struct\">\$1</span>"]
252 ); 264 );
253my $blankline_html5 = $local_lt . "br /" . $local_gt; 265my $blankline_html5 = $local_lt . "br /" . $local_gt;
254 266
@@ -256,11 +268,15 @@ my $blankline_html5 = $local_lt . "br /" . $local_gt;
256my @highlights_xml = ( 268my @highlights_xml = (
257 ["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"], 269 ["([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>"],
258 [$type_constant, "<constant>\$1</constant>"], 270 [$type_constant, "<constant>\$1</constant>"],
271 [$type_enum_xml, "<type>\$1</type>"],
259 [$type_struct_xml, "<structname>\$1</structname>"], 272 [$type_struct_xml, "<structname>\$1</structname>"],
273 [$type_typedef_xml, "<type>\$1</type>"],
274 [$type_union_xml, "<structname>\$1</structname>"],
260 [$type_param, "<parameter>\$1</parameter>"], 275 [$type_param, "<parameter>\$1</parameter>"],
261 [$type_func, "<function>\$1</function>"], 276 [$type_func, "<function>\$1</function>"],
262 [$type_env, "<envar>\$1</envar>"], 277 [$type_env, "<envar>\$1</envar>"],
263 [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] 278 [$type_member_xml, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"],
279 [$type_fallback_xml, "<structname>\$1</structname>"]
264 ); 280 );
265my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; 281my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n";
266 282
@@ -268,10 +284,14 @@ my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $loca
268my @highlights_gnome = ( 284my @highlights_gnome = (
269 [$type_constant, "<replaceable class=\"option\">\$1</replaceable>"], 285 [$type_constant, "<replaceable class=\"option\">\$1</replaceable>"],
270 [$type_func, "<function>\$1</function>"], 286 [$type_func, "<function>\$1</function>"],
287 [$type_enum, "<type>\$1</type>"],
271 [$type_struct, "<structname>\$1</structname>"], 288 [$type_struct, "<structname>\$1</structname>"],
289 [$type_typedef, "<type>\$1</type>"],
290 [$type_union, "<structname>\$1</structname>"],
272 [$type_env, "<envar>\$1</envar>"], 291 [$type_env, "<envar>\$1</envar>"],
273 [$type_param, "<parameter>\$1</parameter>" ], 292 [$type_param, "<parameter>\$1</parameter>" ],
274 [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"] 293 [$type_member, "<literal><structname>\$1</structname>\$2<structfield>\$3</structfield></literal>"],
294 [$type_fallback, "<structname>\$1</structname>"]
275 ); 295 );
276my $blankline_gnome = "</para><para>\n"; 296my $blankline_gnome = "</para><para>\n";
277 297
@@ -279,9 +299,13 @@ my $blankline_gnome = "</para><para>\n";
279my @highlights_man = ( 299my @highlights_man = (
280 [$type_constant, "\$1"], 300 [$type_constant, "\$1"],
281 [$type_func, "\\\\fB\$1\\\\fP"], 301 [$type_func, "\\\\fB\$1\\\\fP"],
302 [$type_enum, "\\\\fI\$1\\\\fP"],
282 [$type_struct, "\\\\fI\$1\\\\fP"], 303 [$type_struct, "\\\\fI\$1\\\\fP"],
304 [$type_typedef, "\\\\fI\$1\\\\fP"],
305 [$type_union, "\\\\fI\$1\\\\fP"],
283 [$type_param, "\\\\fI\$1\\\\fP"], 306 [$type_param, "\\\\fI\$1\\\\fP"],
284 [$type_member, "\\\\fI\$1\$2\$3\\\\fP"] 307 [$type_member, "\\\\fI\$1\$2\$3\\\\fP"],
308 [$type_fallback, "\\\\fI\$1\\\\fP"]
285 ); 309 );
286my $blankline_man = ""; 310my $blankline_man = "";
287 311
@@ -289,9 +313,13 @@ my $blankline_man = "";
289my @highlights_text = ( 313my @highlights_text = (
290 [$type_constant, "\$1"], 314 [$type_constant, "\$1"],
291 [$type_func, "\$1"], 315 [$type_func, "\$1"],
316 [$type_enum, "\$1"],
292 [$type_struct, "\$1"], 317 [$type_struct, "\$1"],
318 [$type_typedef, "\$1"],
319 [$type_union, "\$1"],
293 [$type_param, "\$1"], 320 [$type_param, "\$1"],
294 [$type_member, "\$1\$2\$3"] 321 [$type_member, "\$1\$2\$3"],
322 [$type_fallback, "\$1"]
295 ); 323 );
296my $blankline_text = ""; 324my $blankline_text = "";
297 325
@@ -303,12 +331,12 @@ my @highlights_rst = (
303 [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"], 331 [$type_member, "\\:c\\:type\\:`\$1\$2\$3 <\$1>`"],
304 [$type_fp_param, "**\$1\\\\(\\\\)**"], 332 [$type_fp_param, "**\$1\\\\(\\\\)**"],
305 [$type_func, "\\:c\\:func\\:`\$1()`"], 333 [$type_func, "\\:c\\:func\\:`\$1()`"],
306 [$type_struct_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 334 [$type_enum, "\\:c\\:type\\:`\$1 <\$2>`"],
307 [$type_enum_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 335 [$type_struct, "\\:c\\:type\\:`\$1 <\$2>`"],
308 [$type_typedef_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 336 [$type_typedef, "\\:c\\:type\\:`\$1 <\$2>`"],
309 [$type_union_full, "\\:c\\:type\\:`\$1 \$2 <\$2>`"], 337 [$type_union, "\\:c\\:type\\:`\$1 <\$2>`"],
310 # in rst this can refer to any type 338 # in rst this can refer to any type
311 [$type_struct, "\\:c\\:type\\:`\$1`"], 339 [$type_fallback, "\\:c\\:type\\:`\$1`"],
312 [$type_param, "**\$1**"] 340 [$type_param, "**\$1**"]
313 ); 341 );
314my $blankline_rst = "\n"; 342my $blankline_rst = "\n";
@@ -317,9 +345,13 @@ my $blankline_rst = "\n";
317my @highlights_list = ( 345my @highlights_list = (
318 [$type_constant, "\$1"], 346 [$type_constant, "\$1"],
319 [$type_func, "\$1"], 347 [$type_func, "\$1"],
348 [$type_enum, "\$1"],
320 [$type_struct, "\$1"], 349 [$type_struct, "\$1"],
350 [$type_typedef, "\$1"],
351 [$type_union, "\$1"],
321 [$type_param, "\$1"], 352 [$type_param, "\$1"],
322 [$type_member, "\$1"] 353 [$type_member, "\$1"],
354 [$type_fallback, "\$1"]
323 ); 355 );
324my $blankline_list = ""; 356my $blankline_list = "";
325 357