* [PATCH 0/3] kernel-doc bug fixes
@ 2012-09-28 23:32 Daniel Santos
2012-09-28 23:32 ` [PATCH 1/3] kernel-doc: bugfix - multi-line macros Daniel Santos
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Santos @ 2012-09-28 23:32 UTC (permalink / raw)
To: LKML, linux-doc, Randy Dunlap
Fixes breakages exposed by doc-comments used in the generic red-black
tree patch set.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] kernel-doc: bugfix - multi-line macros
2012-09-28 23:32 [PATCH 0/3] kernel-doc bug fixes Daniel Santos
@ 2012-09-28 23:32 ` Daniel Santos
2012-09-28 23:32 ` [PATCH 2/3] kernel-doc: bugfix - empty line in Example section Daniel Santos
2012-09-28 23:32 ` [PATCH 3/3] kernel-doc: Don't mangle whitespace " Daniel Santos
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Santos @ 2012-09-28 23:32 UTC (permalink / raw)
To: LKML, linux-doc, Randy Dunlap; +Cc: Daniel Santos
Prior to this patch the following code breaks:
/**
* multiline_example - this breaks kernel-doc
*/
#define multiline_example( \
myparam)
Producing this error:
Error(somefile.h:983): cannot understand prototype: 'multiline_example( \ '
This patch fixes the issue by appending all lines ending in a blackslash
(optionally followed by whitespace), removing the backslash and any
whitespace after it prior to appending (just like the C pre-processor
would).
This fixes a break in kerel-doc introduced by the additions to rbtree.h.
Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
---
scripts/kernel-doc | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 5ee8e91..e6bc9db 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -2305,6 +2305,9 @@ sub process_file($) {
$section_counter = 0;
while (<IN>) {
+ while (s/\\\s*$//) {
+ $_ .= <IN>;
+ }
if ($state == 0) {
if (/$doc_start/o) {
$state = 1; # next line is always the function name
--
1.7.3.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] kernel-doc: bugfix - empty line in Example section
2012-09-28 23:32 [PATCH 0/3] kernel-doc bug fixes Daniel Santos
2012-09-28 23:32 ` [PATCH 1/3] kernel-doc: bugfix - multi-line macros Daniel Santos
@ 2012-09-28 23:32 ` Daniel Santos
2012-09-28 23:32 ` [PATCH 3/3] kernel-doc: Don't mangle whitespace " Daniel Santos
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Santos @ 2012-09-28 23:32 UTC (permalink / raw)
To: LKML, linux-doc, Randy Dunlap; +Cc: Daniel Santos
If you have a section named "Example" that contains an empty line,
attempting to generate htmldocs give you the error:
/path/Documentation/DocBook/kernel-api.xml:3455: parser error : Opening and ending tag mismatch: programlisting line 3449 and para
</para><para>
^
/path/Documentation/DocBook/kernel-api.xml:3473: parser error : Opening and ending tag mismatch: para line 3467 and programlisting
</programlisting></informalexample>
^
/path/Documentation/DocBook/kernel-api.xml:3678: parser error : Opening and ending tag mismatch: programlisting line 3672 and para
</para><para>
^
/path/Documentation/DocBook/kernel-api.xml:3701: parser error : Opening and ending tag mismatch: para line 3690 and programlisting
</programlisting></informalexample>
^
unable to parse
/path/Documentation/DocBook/kernel-api.xml
Essentially, the script attempts to close a <programlisting> with a
closing tag for a <para> block. This patch corrects the problem by
simply not outputting anything extra when we're dumping pre-formatted
text, since the empty line will be rendered correctly anyway.
Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
---
scripts/kernel-doc | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index e6bc9db..2be2078 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -245,6 +245,7 @@ my $dohighlight = "";
my $verbose = 0;
my $output_mode = "man";
+my $output_preformatted = 0;
my $no_doc_sections = 0;
my %highlights = %highlights_man;
my $blankline = $blankline_man;
@@ -486,7 +487,9 @@ sub output_highlight {
}
foreach $line (split "\n", $contents) {
if ($line eq ""){
- print $lineprefix, local_unescape($blankline);
+ if (! $output_preformatted) {
+ print $lineprefix, local_unescape($blankline);
+ }
} else {
$line =~ s/\\\\\\/\&/g;
if ($output_mode eq "man" && substr($line, 0, 1) eq ".") {
@@ -902,10 +905,12 @@ sub output_section_xml(%) {
print "<title>$section</title>\n";
if ($section =~ m/EXAMPLE/i) {
print "<informalexample><programlisting>\n";
+ $output_preformatted = 1;
} else {
print "<para>\n";
}
output_highlight($args{'sections'}{$section});
+ $output_preformatted = 0;
if ($section =~ m/EXAMPLE/i) {
print "</programlisting></informalexample>\n";
} else {
@@ -1208,10 +1213,12 @@ sub output_blockhead_xml(%) {
}
if ($section =~ m/EXAMPLE/i) {
print "<example><para>\n";
+ $output_preformatted = 1;
} else {
print "<para>\n";
}
output_highlight($args{'sections'}{$section});
+ $output_preformatted = 0;
if ($section =~ m/EXAMPLE/i) {
print "</para></example>\n";
} else {
@@ -1287,10 +1294,12 @@ sub output_function_gnome {
print "<simplesect>\n <title>$section</title>\n";
if ($section =~ m/EXAMPLE/i) {
print "<example><programlisting>\n";
+ $output_preformatted = 1;
} else {
}
print "<para>\n";
output_highlight($args{'sections'}{$section});
+ $output_preformatted = 0;
print "</para>\n";
if ($section =~ m/EXAMPLE/i) {
print "</programlisting></example>\n";
--
1.7.3.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] kernel-doc: Don't mangle whitespace in Example section
2012-09-28 23:32 [PATCH 0/3] kernel-doc bug fixes Daniel Santos
2012-09-28 23:32 ` [PATCH 1/3] kernel-doc: bugfix - multi-line macros Daniel Santos
2012-09-28 23:32 ` [PATCH 2/3] kernel-doc: bugfix - empty line in Example section Daniel Santos
@ 2012-09-28 23:32 ` Daniel Santos
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Santos @ 2012-09-28 23:32 UTC (permalink / raw)
To: LKML, linux-doc, Randy Dunlap; +Cc: Daniel Santos
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>
---
scripts/kernel-doc | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 2be2078..46e7aff 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -296,9 +296,10 @@ my $doc_special = "\@\%\$\&";
my $doc_start = '^/\*\*\s*$'; # Allow whitespace at end of comment start.
my $doc_end = '\*/';
my $doc_com = '\s*\*\s*';
+my $doc_com_body = '\s*\* ?';
my $doc_decl = $doc_com . '(\w+)';
my $doc_sect = $doc_com . '([' . $doc_special . ']?[\w\s]+):(.*)';
-my $doc_content = $doc_com . '(.*)';
+my $doc_content = $doc_com_body . '(.*)';
my $doc_block = $doc_com . 'DOC:\s*(.*)?';
my %constants;
@@ -486,6 +487,9 @@ sub output_highlight {
$contents =~ s/\s+$//;
}
foreach $line (split "\n", $contents) {
+ if (! $output_preformatted) {
+ $line =~ s/^\s*//;
+ }
if ($line eq ""){
if (! $output_preformatted) {
print $lineprefix, local_unescape($blankline);
@@ -2344,7 +2348,7 @@ sub process_file($) {
$descr= $1;
$descr =~ s/^\s*//;
$descr =~ s/\s*$//;
- $descr =~ s/\s+/ /;
+ $descr =~ s/\s+/ /g;
$declaration_purpose = xml_escape($descr);
$in_purpose = 1;
} else {
@@ -2436,6 +2440,7 @@ sub process_file($) {
# Continued declaration purpose
chomp($declaration_purpose);
$declaration_purpose .= " " . xml_escape($1);
+ $declaration_purpose =~ s/\s+/ /g;
} else {
$contents .= $1 . "\n";
}
--
1.7.3.4
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-28 23:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-28 23:32 [PATCH 0/3] kernel-doc bug fixes Daniel Santos
2012-09-28 23:32 ` [PATCH 1/3] kernel-doc: bugfix - multi-line macros Daniel Santos
2012-09-28 23:32 ` [PATCH 2/3] kernel-doc: bugfix - empty line in Example section Daniel Santos
2012-09-28 23:32 ` [PATCH 3/3] kernel-doc: Don't mangle whitespace " Daniel Santos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®