aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDaniel Santos <daniel.santos@pobox.com>2012-10-04 20:15:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-05 14:05:13 -0400
commit12ae6779332181432a7feda740735ffa5bb3d32d (patch)
tree06faa8cb0e478646260826063b2dd45f3417502a /scripts
parente314ba3130940cb58b533b20969a6ee9b12435ed (diff)
kernel-doc: don't mangle whitespace in Example section
A section with the name "Example" (case-insensitive) has a special meaning to kernel-doc. These sections are output using mono-type fonts. However, leading whitespace is stripped, thus robbing a lot of meaning from this, as indented code examples will be mangled. This patch preserves the leading whitespace for "Example" sections. More accurately, it preserves it for all sections, but removes it later if the section isn't an "Example" section. Signed-off-by: Daniel Santos <daniel.santos@pobox.com> Cc: Randy Dunlap <rdunlap@xenotime.net> Cc: Michal Marek <mmarek@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/kernel-doc9
1 files changed, 7 insertions, 2 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index c7109ca40ba4..01e8a8e22602 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -281,9 +281,10 @@ my $doc_special = "\@\%\$\&";
281my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start. 281my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
282my $doc_end = '\*/'; 282my $doc_end = '\*/';
283my $doc_com = '\s*\*\s*'; 283my $doc_com = '\s*\*\s*';
284my $doc_com_body = '\s*\* ?';
284my $doc_decl = $doc_com . '(\w+)'; 285my $doc_decl = $doc_com . '(\w+)';
285my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)'; 286my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)';
286my $doc_content = $doc_com . '(.*)'; 287my $doc_content = $doc_com_body . '(.*)';
287my $doc_block = $doc_com . 'DOC:\s*(.*)?'; 288my $doc_block = $doc_com . 'DOC:\s*(.*)?';
288 289
289my %constants; 290my %constants;
@@ -460,6 +461,9 @@ sub output_highlight {
460# print STDERR "contents af:$contents\n"; 461# print STDERR "contents af:$contents\n";
461 462
462 foreach $line (split "\n", $contents) { 463 foreach $line (split "\n", $contents) {
464 if (! $output_preformatted) {
465 $line =~ s/^\s*//;
466 }
463 if ($line eq ""){ 467 if ($line eq ""){
464 if (! $output_preformatted) { 468 if (! $output_preformatted) {
465 print $lineprefix, local_unescape($blankline); 469 print $lineprefix, local_unescape($blankline);
@@ -2085,7 +2089,7 @@ sub process_file($) {
2085 $descr= $1; 2089 $descr= $1;
2086 $descr =~ s/^\s*//; 2090 $descr =~ s/^\s*//;
2087 $descr =~ s/\s*$//; 2091 $descr =~ s/\s*$//;
2088 $descr =~ s/\s+/ /; 2092 $descr =~ s/\s+/ /g;
2089 $declaration_purpose = xml_escape($descr); 2093 $declaration_purpose = xml_escape($descr);
2090 $in_purpose = 1; 2094 $in_purpose = 1;
2091 } else { 2095 } else {
@@ -2177,6 +2181,7 @@ sub process_file($) {
2177 # Continued declaration purpose 2181 # Continued declaration purpose
2178 chomp($declaration_purpose); 2182 chomp($declaration_purpose);
2179 $declaration_purpose .= " " . xml_escape($1); 2183 $declaration_purpose .= " " . xml_escape($1);
2184 $declaration_purpose =~ s/\s+/ /g;
2180 } else { 2185 } else {
2181 $contents .= $1 . "\n"; 2186 $contents .= $1 . "\n";
2182 } 2187 }