Received: by 10.223.176.5 with SMTP id f5csp911138wra; Wed, 7 Feb 2018 09:28:08 -0800 (PST) X-Google-Smtp-Source: AH8x2266bKEaC04q7e2XQTbQfBNFtXZbX3lkRP0nE83gHwIp+pOhlRsz1R/rLzzAeLxZMk4TuWXh X-Received: by 10.98.209.93 with SMTP id t29mr6621598pfl.233.1518024488158; Wed, 07 Feb 2018 09:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518024488; cv=none; d=google.com; s=arc-20160816; b=SYzvDLziZ2f+n/Em0QwwCOrgyZhhCpwBjxbTb/KbHMuNhjE39IW26tXMqaV0h5XwUO fbeETbFmfM3zlSAjp70Eelh5vYIHkzqJlg5+/zAJG9PUK+fA01S6KZjPqFvngSmDmMYL 3RWpjmvNJmcLPyScDrq2zbhhAjc7YRzJiHfVHV4Q2FVk0PNhKbu0h7JC210t8IXyGnGB dEir3sAvnPhGNC3Y2SW2BkUiowAAtGTS7Y3c/wBfeAFZqooHh5jkrKddOjtUVwN2q2ms QM4WkkrsNzT1Qs5xmQPz3RBDZuL5mqXJ9Zp7D4c2YVJ3uKpBDYiPEc7gO654HbP+dvao e+LA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=VGHvoRSIdnvQVhBcO3JFklAZMduAYa5CxHUaKC5epXU=; b=fpYLrrpmWJr8vcAaOhcUb7nw+BWF94bPqvNbdVCxVb0YbCU9CAnwFmMAvGMITbBV6A 3FreGf3C3bKqmPaJXboiajMbawJpI2Q418Dnm+jpxE1TkNik87lz8UQMqPaaSSLITbiX HUzJYHKyxDLDeKaRjgdzjqIPOMBz2wXqJ2bV15B9ylSTXHulivqUSXyFY8IlwR0gsgWd eytVRltIp/DPhB2q6kA3bhsSpAHIFjfBUBZHse0MbSqAdhUUqAJtooUQuzhlK518Z8ss s3B2NlROhVRhCB3MKyn+RUhD1uhISkVfdV4it3nbR6BcCK458+qslmIXXgtwZ26qKSDb Tuqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p1-v6si1357099pld.492.2018.02.07.09.27.54; Wed, 07 Feb 2018 09:28:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754877AbeBGR1I (ORCPT + 99 others); Wed, 7 Feb 2018 12:27:08 -0500 Received: from ms.lwn.net ([45.79.88.28]:41660 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754860AbeBGR1G (ORCPT ); Wed, 7 Feb 2018 12:27:06 -0500 Received: from tpad.lan (localhost [127.0.0.1]) by ms.lwn.net (Postfix) with ESMTPA id 7465F1329; Wed, 7 Feb 2018 17:27:05 +0000 (UTC) From: Jonathan Corbet To: linux-doc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, mchehab@kernel.org, me@tobin.cc, Jonathan Corbet Subject: [PATCH 7/8] docs: kernel-doc: Finish moving STATE_* code out of process_file() Date: Wed, 7 Feb 2018 10:26:23 -0700 Message-Id: <20180207172624.24555-8-corbet@lwn.net> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180207172624.24555-1-corbet@lwn.net> References: <20180207172624.24555-1-corbet@lwn.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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"; + } + } +} + +# +# 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