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/kernel-doc (1 of 1 file). Show all

Unified · Split

scripts/kernel-doc+15−6
@@ -159,7 +159,8 @@ my $warnings = 0; · 158 unmodified lines
159159 my $type_constant = '\%([-_\w]+)';
160160 my $type_func = '(\w+)\(\)';
161161 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]+)';
163164 my $type_env = '(\$\w+)';
164165
165166 # Output conversion substitutions.
@@ -168,7 +169,8 @@ my $type_env = '(\$\w+)'; · 2 unmodified lines
168169 # these work fairly well
169170 my %highlights_html = ( $type_constant, "<i>\$1</i>",
170171 $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>",
172174 $type_param, "<tt><b>\$1</b></tt>" );
173175 my $blankline_html = "<p>";
174176
@@ -331,7 +333,7 @@ while ($ARGV[0] =~ m/^-(.*)/) { · 156 unmodified lines
331333 # using the s// operator.
332334 my $dohighlight = "";
333335 foreach my $pattern (keys %highlights) {
334−# print "scanning pattern $pattern ($highlights{$pattern})\n";
336+# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
335337 $dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
336338 }
337339
@@ -378,8 +380,14 @@ sub output_highlight { · 40 unmodified lines
378380 # confess "output_highlight got called with no args?\n";
379381 # }
380382
383+# print STDERR "contents b4:$contents\n";
381384 eval $dohighlight;
382385 die $@ if $@;
386+ if ($output_mode eq "html") {
387+ $contents =~ s/\\\\//;
388+ }
389+# print STDERR "contents af:$contents\n";
390+
383391 foreach $line (split "\n", $contents) {
384392 if ($line eq ""){
385393 print $lineprefix, $blankline;
@@ -466,11 +474,12 @@ sub output_struct_html(%) { · 80 unmodified lines
466474 $type = $args{'parametertypes'}{$parameter};
467475 if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
468476 # 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";
470478 } 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";
472481 } else {
473− print " <i>$type</i> <b>$parameter</b>;<br>\n";
482+ print "&nbsp; &nbsp; <i>$type</i> <b>$parameter</b>;<br>\n";
474483 }
475484 }
476485 print "};<br>\n";