diff options
| author | Jani Nikula <jani.nikula@intel.com> | 2016-05-27 17:41:50 -0400 |
|---|---|---|
| committer | Jani Nikula <jani.nikula@intel.com> | 2016-05-30 06:39:01 -0400 |
| commit | b7886de43c9f8a19685cd6e81135de63b9529911 (patch) | |
| tree | 75267ed0f3de1d668bfee489ce34a7430e15d115 /scripts/kernel-doc | |
| parent | 0a7263014b3a0e05b52ccef314e2ccf6f4550a8b (diff) | |
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: Jani Nikula <jani.nikula@intel.com>
Diffstat (limited to 'scripts/kernel-doc')
| -rwxr-xr-x | scripts/kernel-doc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index e93e796b17ce..f6f37e71dc08 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -2701,6 +2701,7 @@ sub process_file($) { | |||
| 2701 | my $in_purpose = 0; | 2701 | my $in_purpose = 0; |
| 2702 | my $initial_section_counter = $section_counter; | 2702 | my $initial_section_counter = $section_counter; |
| 2703 | my ($orig_file) = @_; | 2703 | my ($orig_file) = @_; |
| 2704 | my $leading_space; | ||
| 2704 | 2705 | ||
| 2705 | if (defined($ENV{'SRCTREE'})) { | 2706 | if (defined($ENV{'SRCTREE'})) { |
| 2706 | $file = "$ENV{'SRCTREE'}" . "/" . $orig_file; | 2707 | $file = "$ENV{'SRCTREE'}" . "/" . $orig_file; |
| @@ -2822,6 +2823,7 @@ sub process_file($) { | |||
| 2822 | $contents .= "\n"; | 2823 | $contents .= "\n"; |
| 2823 | } | 2824 | } |
| 2824 | $section = $newsection; | 2825 | $section = $newsection; |
| 2826 | $leading_space = undef; | ||
| 2825 | } elsif (/$doc_end/) { | 2827 | } elsif (/$doc_end/) { |
| 2826 | if (($contents ne "") && ($contents ne "\n")) { | 2828 | if (($contents ne "") && ($contents ne "\n")) { |
| 2827 | dump_section($file, $section, xml_escape($contents)); | 2829 | dump_section($file, $section, xml_escape($contents)); |
| @@ -2856,7 +2858,19 @@ sub process_file($) { | |||
| 2856 | $declaration_purpose .= " " . xml_escape($1); | 2858 | $declaration_purpose .= " " . xml_escape($1); |
| 2857 | $declaration_purpose =~ s/\s+/ /g; | 2859 | $declaration_purpose =~ s/\s+/ /g; |
| 2858 | } else { | 2860 | } else { |
| 2859 | $contents .= $1 . "\n"; | 2861 | my $cont = $1; |
| 2862 | if ($section =~ m/^@/ || $section eq $section_context) { | ||
| 2863 | if (!defined $leading_space) { | ||
| 2864 | if ($cont =~ m/^(\s+)/) { | ||
| 2865 | $leading_space = $1; | ||
| 2866 | } else { | ||
| 2867 | $leading_space = ""; | ||
| 2868 | } | ||
| 2869 | } | ||
| 2870 | |||
| 2871 | $cont =~ s/^$leading_space//; | ||
| 2872 | } | ||
| 2873 | $contents .= $cont . "\n"; | ||
| 2860 | } | 2874 | } |
| 2861 | } else { | 2875 | } else { |
| 2862 | # i dont know - bad line? ignore. | 2876 | # i dont know - bad line? ignore. |
