History

kernel-doc: html mode struct highlights

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

Randy Dunlap committed 19 years ago

Commit 3eb014a1 parent 3361c7b1 file · +15 −6Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kernel-doc+15−6
@@ -159,7 +159,8 @@ my $warnings = 0; · 158 unmodified lines
159my $type_constant = '\%([-_\w]+)';159my $type_constant = '\%([-_\w]+)';
160my $type_func = '(\w+)\(\)';160my $type_func = '(\w+)\(\)';
161my $type_param = '\@(\w+)';161my $type_param = '\@(\w+)';
162my $type_struct = '\&((struct\s*)?[_\w]+)';162my $type_struct = '\&((struct\s*)*[_\w]+)';
163my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)';
163my $type_env = '(\$\w+)';164my $type_env = '(\$\w+)';
164 165
165# Output conversion substitutions.166# Output conversion substitutions.
@@ -168,7 +169,8 @@ my $type_env = '(\$\w+)'; · 2 unmodified lines
168# these work fairly well169# these work fairly well
169my %highlights_html = ( $type_constant, "<i>\$1</i>",170my %highlights_html = ( $type_constant, "<i>\$1</i>",
170 $type_func, "<b>\$1</b>",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 $type_param, "<tt><b>\$1</b></tt>" );174 $type_param, "<tt><b>\$1</b></tt>" );
173my $blankline_html = "<p>";175my $blankline_html = "<p>";
174 176
@@ -331,7 +333,7 @@ while ($ARGV[0] =~ m/^-(.*)/) { · 156 unmodified lines
331# using the s// operator.333# using the s// operator.
332my $dohighlight = "";334my $dohighlight = "";
333foreach my $pattern (keys %highlights) {335foreach my $pattern (keys %highlights) {
334# print "scanning pattern $pattern ($highlights{$pattern})\n";336# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
335 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";337 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
336}338}
337 339
@@ -378,8 +380,14 @@ sub output_highlight { · 40 unmodified lines
378# confess "output_highlight got called with no args?\n";380# confess "output_highlight got called with no args?\n";
379# }381# }
380 382
383# print STDERR "contents b4:$contents\n";
381 eval $dohighlight;384 eval $dohighlight;
382 die $@ if $@;385 die $@ if $@;
386 if ($output_mode eq "html") {
387 $contents =~ s/\\\\//;
388 }
389# print STDERR "contents af:$contents\n";
390
383 foreach $line (split "\n", $contents) {391 foreach $line (split "\n", $contents) {
384 if ($line eq ""){392 if ($line eq ""){
385 print $lineprefix, $blankline;393 print $lineprefix, $blankline;
@@ -466,11 +474,12 @@ sub output_struct_html(%) { · 80 unmodified lines
466 $type = $args{'parametertypes'}{$parameter};474 $type = $args{'parametertypes'}{$parameter};
467 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {475 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
468 # pointer-to-function476 # pointer-to-function
469 print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";477 print "&nbsp; &nbsp; <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
470 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {478 } elsif ($type =~ m/^(.*?)\s*(:.*)/) {
471 print " <i>$1</i> <b>$parameter</b>$2;<br>\n";479 # bitfield
480 print "&nbsp; &nbsp; <i>$1</i> <b>$parameter</b>$2;<br>\n";
472 } else {481 } else {
473 print " <i>$type</i> <b>$parameter</b>;<br>\n";482 print "&nbsp; &nbsp; <i>$type</i> <b>$parameter</b>;<br>\n";
474 }483 }
475 }484 }
476 print "};<br>\n";485 print "};<br>\n";