Johannes Berg reported that struct names are not highlighted (bold, italic, etc.) in html kernel-doc output. (Also not in text-mode output, but I don't see that changing.) This patch adds the following: - highlight struct names in html output mode - highlight environment var. names in html output mode - indent struct fields in the original struct layout
Showing the changes to scripts/kernel-doc (1 of 1 file). Show all
Unified · Split
| @@ -159,7 +159,8 @@ my $warnings = 0; · 158 unmodified lines | ||
| 159 | 159 | my $type_constant = '\%([-_\w]+)'; |
| 160 | 160 | my $type_func = '(\w+)\(\)'; |
| 161 | 161 | my $type_param = '\@(\w+)'; |
| 162 | −my $type_struct = '\&((struct\s*)?[_\w]+)'; | |
| 162 | +my $type_struct = '\&((struct\s*)*[_\w]+)'; | |
| 163 | +my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)'; | |
| 163 | 164 | my $type_env = '(\$\w+)'; |
| 164 | 165 | |
| 165 | 166 | # Output conversion substitutions. |
| @@ -168,7 +169,8 @@ my $type_env = '(\$\w+)'; · 2 unmodified lines | ||
| 168 | 169 | # these work fairly well |
| 169 | 170 | my %highlights_html = ( $type_constant, "<i>\$1</i>", |
| 170 | 171 | $type_func, "<b>\$1</b>", |
| 171 | − $type_struct, "<i>\$1</i>", | |
| 172 | + $type_struct_xml, "<i>\$1</i>", | |
| 173 | + $type_env, "<b><i>\$1</i></b>", | |
| 172 | 174 | $type_param, "<tt><b>\$1</b></tt>" ); |
| 173 | 175 | my $blankline_html = "<p>"; |
| 174 | 176 | |
| @@ -331,7 +333,7 @@ while ($ARGV[0] =~ m/^-(.*)/) { · 156 unmodified lines | ||
| 331 | 333 | # using the s// operator. |
| 332 | 334 | my $dohighlight = ""; |
| 333 | 335 | foreach my $pattern (keys %highlights) { |
| 334 | −# print "scanning pattern $pattern ($highlights{$pattern})\n"; | |
| 336 | +# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n"; | |
| 335 | 337 | $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n"; |
| 336 | 338 | } |
| 337 | 339 | |
| @@ -378,8 +380,14 @@ sub output_highlight { · 40 unmodified lines | ||
| 378 | 380 | # confess "output_highlight got called with no args?\n"; |
| 379 | 381 | # } |
| 380 | 382 | |
| 383 | +# print STDERR "contents b4:$contents\n"; | |
| 381 | 384 | eval $dohighlight; |
| 382 | 385 | die $@ if $@; |
| 386 | + if ($output_mode eq "html") { | |
| 387 | + $contents =~ s/\\\\//; | |
| 388 | + } | |
| 389 | +# print STDERR "contents af:$contents\n"; | |
| 390 | + | |
| 383 | 391 | foreach $line (split "\n", $contents) { |
| 384 | 392 | if ($line eq ""){ |
| 385 | 393 | print $lineprefix, $blankline; |
| @@ -466,11 +474,12 @@ sub output_struct_html(%) { · 80 unmodified lines | ||
| 466 | 474 | $type = $args{'parametertypes'}{$parameter}; |
| 467 | 475 | if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) { |
| 468 | 476 | # pointer-to-function |
| 469 | − print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n"; | |
| 477 | + print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n"; | |
| 470 | 478 | } elsif ($type =~ m/^(.*?)\s*(:.*)/) { |
| 471 | − print " <i>$1</i> <b>$parameter</b>$2;<br>\n"; | |
| 479 | + # bitfield | |
| 480 | + print " <i>$1</i> <b>$parameter</b>$2;<br>\n"; | |
| 472 | 481 | } else { |
| 473 | − print " <i>$type</i> <b>$parameter</b>;<br>\n"; | |
| 482 | + print " <i>$type</i> <b>$parameter</b>;<br>\n"; | |
| 474 | 483 | } |
| 475 | 484 | } |
| 476 | 485 | print "};<br>\n"; |