mirror of https://gitee.com/openkylin/linux.git
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 Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Cc: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
3361c7bebb
commit
3eb014a103
|
@ -159,7 +159,8 @@ my $warnings = 0;
|
||||||
my $type_constant = '\%([-_\w]+)';
|
my $type_constant = '\%([-_\w]+)';
|
||||||
my $type_func = '(\w+)\(\)';
|
my $type_func = '(\w+)\(\)';
|
||||||
my $type_param = '\@(\w+)';
|
my $type_param = '\@(\w+)';
|
||||||
my $type_struct = '\&((struct\s*)?[_\w]+)';
|
my $type_struct = '\&((struct\s*)*[_\w]+)';
|
||||||
|
my $type_struct_xml = '\\\amp;((struct\s*)*[_\w]+)';
|
||||||
my $type_env = '(\$\w+)';
|
my $type_env = '(\$\w+)';
|
||||||
|
|
||||||
# Output conversion substitutions.
|
# Output conversion substitutions.
|
||||||
|
@ -168,7 +169,8 @@ my $type_env = '(\$\w+)';
|
||||||
# these work fairly well
|
# these work fairly well
|
||||||
my %highlights_html = ( $type_constant, "<i>\$1</i>",
|
my %highlights_html = ( $type_constant, "<i>\$1</i>",
|
||||||
$type_func, "<b>\$1</b>",
|
$type_func, "<b>\$1</b>",
|
||||||
$type_struct, "<i>\$1</i>",
|
$type_struct_xml, "<i>\$1</i>",
|
||||||
|
$type_env, "<b><i>\$1</i></b>",
|
||||||
$type_param, "<tt><b>\$1</b></tt>" );
|
$type_param, "<tt><b>\$1</b></tt>" );
|
||||||
my $blankline_html = "<p>";
|
my $blankline_html = "<p>";
|
||||||
|
|
||||||
|
@ -331,7 +333,7 @@ while ($ARGV[0] =~ m/^-(.*)/) {
|
||||||
# using the s// operator.
|
# using the s// operator.
|
||||||
my $dohighlight = "";
|
my $dohighlight = "";
|
||||||
foreach my $pattern (keys %highlights) {
|
foreach my $pattern (keys %highlights) {
|
||||||
# print "scanning pattern $pattern ($highlights{$pattern})\n";
|
# print STDERR "scanning pattern:$pattern, highlight:($highlights{$pattern})\n";
|
||||||
$dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
|
$dohighlight .= "\$contents =~ s:$pattern:$highlights{$pattern}:gs;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,8 +380,14 @@ sub output_highlight {
|
||||||
# confess "output_highlight got called with no args?\n";
|
# confess "output_highlight got called with no args?\n";
|
||||||
# }
|
# }
|
||||||
|
|
||||||
|
# print STDERR "contents b4:$contents\n";
|
||||||
eval $dohighlight;
|
eval $dohighlight;
|
||||||
die $@ if $@;
|
die $@ if $@;
|
||||||
|
if ($output_mode eq "html") {
|
||||||
|
$contents =~ s/\\\\//;
|
||||||
|
}
|
||||||
|
# print STDERR "contents af:$contents\n";
|
||||||
|
|
||||||
foreach $line (split "\n", $contents) {
|
foreach $line (split "\n", $contents) {
|
||||||
if ($line eq ""){
|
if ($line eq ""){
|
||||||
print $lineprefix, $blankline;
|
print $lineprefix, $blankline;
|
||||||
|
@ -466,11 +474,12 @@ sub output_struct_html(%) {
|
||||||
$type = $args{'parametertypes'}{$parameter};
|
$type = $args{'parametertypes'}{$parameter};
|
||||||
if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
|
if ($type =~ m/([^\(]*\(\*)\s*\)\s*\(([^\)]*)\)/) {
|
||||||
# pointer-to-function
|
# pointer-to-function
|
||||||
print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
|
print " <i>$1</i><b>$parameter</b>) <i>($2)</i>;<br>\n";
|
||||||
} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
|
} elsif ($type =~ m/^(.*?)\s*(:.*)/) {
|
||||||
print " <i>$1</i> <b>$parameter</b>$2;<br>\n";
|
# bitfield
|
||||||
|
print " <i>$1</i> <b>$parameter</b>$2;<br>\n";
|
||||||
} else {
|
} else {
|
||||||
print " <i>$type</i> <b>$parameter</b>;<br>\n";
|
print " <i>$type</i> <b>$parameter</b>;<br>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "};<br>\n";
|
print "};<br>\n";
|
||||||
|
|
Loading…
Reference in New Issue