Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7886de4 authored by Jani Nikula's avatar Jani Nikula
Browse files

kernel-doc: strip leading whitespace from continued param descs



If a param description spans multiple lines, check any leading
whitespace in the first continuation line, and remove same amount of
whitespace from following lines.

This allows indentation in the multi-line parameter descriptions for
aesthetical reasons while not causing accidentally significant
indentation in the rst output.

Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 0a726301
Loading
Loading
Loading
Loading
+15 −1
Original line number Original line Diff line number Diff line
@@ -2701,6 +2701,7 @@ sub process_file($) {
    my $in_purpose = 0;
    my $in_purpose = 0;
    my $initial_section_counter = $section_counter;
    my $initial_section_counter = $section_counter;
    my ($orig_file) = @_;
    my ($orig_file) = @_;
    my $leading_space;


    if (defined($ENV{'SRCTREE'})) {
    if (defined($ENV{'SRCTREE'})) {
	$file = "$ENV{'SRCTREE'}" . "/" . $orig_file;
	$file = "$ENV{'SRCTREE'}" . "/" . $orig_file;
@@ -2822,6 +2823,7 @@ sub process_file($) {
		    $contents .= "\n";
		    $contents .= "\n";
		}
		}
		$section = $newsection;
		$section = $newsection;
		$leading_space = undef;
	    } elsif (/$doc_end/) {
	    } elsif (/$doc_end/) {
		if (($contents ne "") && ($contents ne "\n")) {
		if (($contents ne "") && ($contents ne "\n")) {
		    dump_section($file, $section, xml_escape($contents));
		    dump_section($file, $section, xml_escape($contents));
@@ -2856,7 +2858,19 @@ sub process_file($) {
		    $declaration_purpose .= " " . xml_escape($1);
		    $declaration_purpose .= " " . xml_escape($1);
		    $declaration_purpose =~ s/\s+/ /g;
		    $declaration_purpose =~ s/\s+/ /g;
		} else {
		} else {
		    $contents .= $1 . "\n";
		    my $cont = $1;
		    if ($section =~ m/^@/ || $section eq $section_context) {
			if (!defined $leading_space) {
			    if ($cont =~ m/^(\s+)/) {
				$leading_space = $1;
			    } else {
				$leading_space = "";
			    }
			}

			$cont =~ s/^$leading_space//;
		    }
		    $contents .= $cont . "\n";
		}
		}
	    } else {
	    } else {
		# i dont know - bad line?  ignore.
		# i dont know - bad line?  ignore.