The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Tobin C. Harding" <me@tobin.cc>
To: Jonathan Corbet <corbet@lwn.net>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	mchehab@kernel.org
Subject: Re: [PATCH 7/8] docs: kernel-doc: Finish moving STATE_* code out of process_file()
Date: Thu, 8 Feb 2018 13:29:53 +1100	[thread overview]
Message-ID: <20180208022953.GB3304@eros> (raw)
In-Reply-To: <20180207172624.24555-8-corbet@lwn.net>

On Wed, Feb 07, 2018 at 10:26:23AM -0700, Jonathan Corbet wrote:
> Move STATE_INLINE and STATE_DOCBLOCK code out of process_file(), which now
> actually fits on a single screen.  Delete an unused variable and add a
> couple of comments while I'm at it.
> 
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
> ---
>  scripts/kernel-doc | 145 ++++++++++++++++++++++++++++++-----------------------
>  1 file changed, 83 insertions(+), 62 deletions(-)
> 
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 2deddb876156..c6c9370a1e49 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -1990,10 +1990,86 @@ sub process_proto($$) {
>      }
>  }
>  
> +#
> +# STATE_DOCBLOCK: within a DOC: block.
> +#
> +sub process_docblock($$) {
> +    my $file = shift;
> +
> +    if (/$doc_end/)
> +    {
> +	dump_doc_section($file, $section, $contents);
> +	$section = $section_default;
> +	$contents = "";
> +	$function = "";
> +	%parameterdescs = ();
> +	%parametertypes = ();
> +	@parameterlist = ();
> +	%sections = ();
> +	@sectionlist = ();
> +	$prototype = "";
> +	$state = STATE_NORMAL;
> +    }
> +    elsif (/$doc_content/)
> +    {
> +	if ( $1 eq "" )
> +	{
> +	    $contents .= $blankline;
> +	}
> +	else
> +	{
> +	    $contents .= $1 . "\n";
> +	}
> +    }
> +}

It doesn't appear to be introduced by you but the brace positions are
non-uniform in this patch.

if
{
  ...
}
else
{
  ...
}

instead of

if {
  ...
} else {
  eee
}

Hope this helps,
Tobin.


(rest of patch left intentionally for reference)

> +
> +#
> +# STATE_INLINE: docbook comments within a prototype.
> +#
> +sub process_inline($$) {
> +    my $file = shift;
> +
> +    # First line (state 1) needs to be a @parameter
> +    if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) {
> +	$section = $1;
> +	$contents = $2;
> +	$new_start_line = $.;
> +	if ($contents ne "") {
> +	    while (substr($contents, 0, 1) eq " ") {
> +		$contents = substr($contents, 1);
> +	    }
> +	    $contents .= "\n";
> +	}
> +	$inline_doc_state = STATE_INLINE_TEXT;
> +	# Documentation block end */
> +    } elsif (/$doc_inline_end/) {
> +	if (($contents ne "") && ($contents ne "\n")) {
> +	    dump_section($file, $section, $contents);
> +	    $section = $section_default;
> +	    $contents = "";
> +	}
> +	$state = STATE_PROTO;
> +	$inline_doc_state = STATE_INLINE_NA;
> +	# Regular text
> +    } elsif (/$doc_content/) {
> +	if ($inline_doc_state == STATE_INLINE_TEXT) {
> +	    $contents .= $1 . "\n";
> +	    # nuke leading blank lines
> +	    if ($contents =~ /^\s*$/) {
> +		$contents = "";
> +	    }
> +	} elsif ($inline_doc_state == STATE_INLINE_NAME) {
> +	    $inline_doc_state = STATE_INLINE_ERROR;
> +	    print STDERR "${file}:$.: warning: ";
> +	    print STDERR "Incorrect use of kernel-doc format: $_";
> +	    ++$warnings;
> +	}
> +    }
> +}
> +
>  
>  sub process_file($) {
>      my $file;
> -    my $func;
>      my $initial_section_counter = $section_counter;
>      my ($orig_file) = @_;
>  
> @@ -2014,6 +2090,8 @@ sub process_file($) {
>  	}
>  	# Replace tabs by spaces
>          while ($_ =~ s/\t+/' ' x (length($&) * 8 - length($`) % 8)/e) {};
> +
> +	# Hand this line to the appropriate state handler
>  	if ($state == STATE_NORMAL) {
>  	    process_normal();
>  	} elsif ($state == STATE_NAME) {
> @@ -2021,72 +2099,15 @@ sub process_file($) {
>  	} elsif ($state == STATE_BODY || $state == STATE_BODY_MAYBE) {
>  	    process_body($file, $_);
>  	} elsif ($state == STATE_INLINE) { # scanning for inline parameters
> -	    # First line (state 1) needs to be a @parameter
> -	    if ($inline_doc_state == STATE_INLINE_NAME && /$doc_inline_sect/o) {
> -		$section = $1;
> -		$contents = $2;
> -                $new_start_line = $.;
> -		if ($contents ne "") {
> -		    while (substr($contents, 0, 1) eq " ") {
> -			$contents = substr($contents, 1);
> -		    }
> -		    $contents .= "\n";
> -		}
> -		$inline_doc_state = STATE_INLINE_TEXT;
> -	    # Documentation block end */
> -	    } elsif (/$doc_inline_end/) {
> -		if (($contents ne "") && ($contents ne "\n")) {
> -		    dump_section($file, $section, $contents);
> -		    $section = $section_default;
> -		    $contents = "";
> -		}
> -		$state = STATE_PROTO;
> -		$inline_doc_state = STATE_INLINE_NA;
> -	    # Regular text
> -	    } elsif (/$doc_content/) {
> -		if ($inline_doc_state == STATE_INLINE_TEXT) {
> -		    $contents .= $1 . "\n";
> -		    # nuke leading blank lines
> -		    if ($contents =~ /^\s*$/) {
> -			$contents = "";
> -		    }
> -		} elsif ($inline_doc_state == STATE_INLINE_NAME) {
> -		    $inline_doc_state = STATE_INLINE_ERROR;
> -		    print STDERR "${file}:$.: warning: ";
> -		    print STDERR "Incorrect use of kernel-doc format: $_";
> -		    ++$warnings;
> -		}
> -	    }
> +	    process_inline($file, $_);
>  	} elsif ($state == STATE_PROTO) {
>  	    process_proto($file, $_);
>  	} elsif ($state == STATE_DOCBLOCK) {
> -		if (/$doc_end/)
> -		{
> -			dump_doc_section($file, $section, $contents);
> -			$section = $section_default;
> -			$contents = "";
> -			$function = "";
> -			%parameterdescs = ();
> -			%parametertypes = ();
> -			@parameterlist = ();
> -			%sections = ();
> -			@sectionlist = ();
> -			$prototype = "";
> -			$state = STATE_NORMAL;
> -		}
> -		elsif (/$doc_content/)
> -		{
> -			if ( $1 eq "" )
> -			{
> -				$contents .= $blankline;
> -			}
> -			else
> -			{
> -				$contents .= $1 . "\n";
> -			}
> -		}
> +	    process_docblock($file, $_);
>  	}
>      }
> +
> +    # Make sure we got something interesting.
>      if ($initial_section_counter == $section_counter) {
>  	if ($output_mode ne "none") {
>  	    print STDERR "${file}:1: warning: no structured comments found\n";
> -- 
> 2.14.3
> 

  reply	other threads:[~2018-02-08  2:30 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 17:26 [PATCH 0/8] Clean up kernel-doc and fix literal-block handling Jonathan Corbet
2018-02-07 17:26 ` [PATCH 1/8] docs: kernel-doc: Get rid of xml_escape() and friends Jonathan Corbet
2018-02-09  9:09   ` Jani Nikula
2018-02-09 13:32     ` Jonathan Corbet
2018-02-07 17:26 ` [PATCH 2/8] docs: kernel-doc: Rename and split STATE_FIELD Jonathan Corbet
2018-02-09  9:20   ` Jani Nikula
2018-02-07 17:26 ` [PATCH 3/8] docs: kernel-doc: Move STATE_NORMAL processing into its own function Jonathan Corbet
2018-02-09  9:23   ` Jani Nikula
2018-02-07 17:26 ` [PATCH 4/8] docs: kernel-doc: Move STATE_NAME " Jonathan Corbet
2018-02-09  9:27   ` Jani Nikula
2018-02-07 17:26 ` [PATCH 5/8] docs: kernel-doc: Move STATE_BODY processing to a separate function Jonathan Corbet
2018-02-09  9:32   ` Jani Nikula
2018-02-09 17:30     ` Linus Torvalds
2018-02-13 10:01       ` Jani Nikula
2018-02-07 17:26 ` [PATCH 6/8] docs: kernel-doc: Move STATE_PROTO processing into its own function Jonathan Corbet
2018-02-09  9:33   ` Jani Nikula
2018-02-07 17:26 ` [PATCH 7/8] docs: kernel-doc: Finish moving STATE_* code out of process_file() Jonathan Corbet
2018-02-08  2:29   ` Tobin C. Harding [this message]
2018-02-08 19:58     ` Jonathan Corbet
2018-02-09  9:36       ` Jani Nikula
2018-02-07 17:26 ` [PATCH 8/8] docs: kernel-doc: Don't mangle literal code blocks in comments Jonathan Corbet
2018-02-08  2:30   ` Tobin C. Harding
2018-02-09  9:47   ` Jani Nikula
2018-02-14 16:53   ` Markus Heiser
2018-02-08  2:26 ` [PATCH 0/8] Clean up kernel-doc and fix literal-block handling Tobin C. Harding
  -- strict thread matches above, loose matches on Subject: below --
2018-02-14 18:40 [PATCH v2 0/8] docs: Cleanup kernel-doc and fix literal block handling Jonathan Corbet
2018-02-14 18:40 ` [PATCH 7/8] docs: kernel-doc: Finish moving STATE_* code out of process_file() Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180208022953.GB3304@eros \
    --to=me@tobin.cc \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox