Skip to content

Commit 6423133

Browse files
hnaztorvalds
authored andcommitted
kernel-doc: allow multi-line declaration purpose descriptions
Allow the short description after symbol name and dash in a kernel-doc comment to span multiple lines, e.g. like this: /** * unmap_mapping_range - unmap the portion of all mmaps in the * specified address_space corresponding to the specified * page range in the underlying file. * @mapping: the address space containing mmaps to be unmapped. * ... */ The short description ends with a parameter description, an empty line or the end of the comment block. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 27f5de7 commit 6423133

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

Documentation/kernel-doc-nano-HOWTO.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ Example kernel-doc function comment:
6666
* The longer description can have multiple paragraphs.
6767
*/
6868

69-
The first line, with the short description, must be on a single line.
69+
The short description following the subject can span multiple lines
70+
and ends with an @argument description, an empty line or the end of
71+
the comment block.
7072

7173
The @argument descriptions must begin on the very next line following
7274
this opening short function description line, with no intervening

scripts/kernel-doc

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,6 +1995,7 @@ sub process_file($) {
19951995
my $identifier;
19961996
my $func;
19971997
my $descr;
1998+
my $in_purpose = 0;
19981999
my $initial_section_counter = $section_counter;
19992000

20002001
if (defined($ENV{'SRCTREE'})) {
@@ -2044,6 +2045,7 @@ sub process_file($) {
20442045
$descr =~ s/\s*$//;
20452046
$descr =~ s/\s+/ /;
20462047
$declaration_purpose = xml_escape($descr);
2048+
$in_purpose = 1;
20472049
} else {
20482050
$declaration_purpose = "";
20492051
}
@@ -2090,6 +2092,7 @@ sub process_file($) {
20902092
}
20912093

20922094
$in_doc_sect = 1;
2095+
$in_purpose = 0;
20932096
$contents = $newcontents;
20942097
if ($contents ne "") {
20952098
while ((substr($contents, 0, 1) eq " ") ||
@@ -2119,11 +2122,19 @@ sub process_file($) {
21192122
} elsif (/$doc_content/) {
21202123
# miguel-style comment kludge, look for blank lines after
21212124
# @parameter line to signify start of description
2122-
if ($1 eq "" &&
2123-
($section =~ m/^@/ || $section eq $section_context)) {
2124-
dump_section($file, $section, xml_escape($contents));
2125-
$section = $section_default;
2126-
$contents = "";
2125+
if ($1 eq "") {
2126+
if ($section =~ m/^@/ || $section eq $section_context) {
2127+
dump_section($file, $section, xml_escape($contents));
2128+
$section = $section_default;
2129+
$contents = "";
2130+
} else {
2131+
$contents .= "\n";
2132+
}
2133+
$in_purpose = 0;
2134+
} elsif ($in_purpose == 1) {
2135+
# Continued declaration purpose
2136+
chomp($declaration_purpose);
2137+
$declaration_purpose .= " " . xml_escape($1);
21272138
} else {
21282139
$contents .= $1 . "\n";
21292140
}

0 commit comments

Comments
 (0)