linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Markus Heiser <markus.heiser@darmarit.de>
Cc: Jani Nikula <jani.nikula@intel.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Jonathan Corbet <corbet@lwn.net>,
	Grant Likely <grant.likely@secretlab.ca>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	Dan Allen <dan@opendevise.io>,
	Russel Winder <russel@winder.org.uk>,
	Keith Packard <keithp@keithp.com>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-doc@vger.kernel.org, Hans Verkuil <hverkuil@xs4all.nl>
Subject: [PATCH 02/10] kernel-doc: support printing exported and non-exported symbols
Date: Fri, 20 May 2016 16:39:33 +0300	[thread overview]
Message-ID: <fc758c93601f3a0967e2d343b7b4a8fea7d9f64d.1463748027.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1463748027.git.jani.nikula@intel.com>
In-Reply-To: <cover.1463748027.git.jani.nikula@intel.com>

Currently we use docproc to figure out which symbols are exported, and
then docproc calls kernel-doc on specific functions, to get
documentation on exported functions. According to git blame and docproc
comments, this is due to historical reasons, as functions and their
corresponding EXPORT_SYMBOL* may have been in different files. However
for more than ten years the recommendation in CodingStyle has been to
place the EXPORT_SYMBOL* immediately after the closing function brace
line.

Additionally, the kernel-doc comments for functions are generally placed
above the function definition in the .c files (i.e. where the
EXPORT_SYMBOL* is) rather than above the declaration in the .h
files. There are some exceptions to this, but AFAICT none of these are
included in DocBook documentation using the "!E" docproc directive.

Therefore, assuming the EXPORT_SYMBOL* and kernel-doc are with the
function definition, kernel-doc can extract the exported vs. not
information by making two passes on the input file. Add support for that
via the new -export and -internal parameters.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 scripts/kernel-doc | 29 +++++++++++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index babb374c043d..0e4109bcaa41 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -59,6 +59,12 @@ Output format selection (mutually exclusive):
   -text			Output plain text format.
 
 Output selection (mutually exclusive):
+  -export		Only output documentation for symbols that have been
+			exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL()
+			in the same FILE.
+  -internal		Only output documentation for symbols that have NOT been
+			exported using EXPORT_SYMBOL() or EXPORT_SYMBOL_GPL()
+			in the same FILE.
   -function NAME	Only output documentation for the given function(s)
 			or DOC: section title(s). All other functions and DOC:
 			sections are ignored. May be specified multiple times.
@@ -380,6 +386,7 @@ my $doc_block = $doc_com . 'DOC:\s*(.*)?';
 my $doc_split_start = '^\s*/\*\*\s*$';
 my $doc_split_sect = '\s*\*\s*(@[\w\s]+):(.*)';
 my $doc_split_end = '^\s*\*/\s*$';
+my $export_symbol = '^\s*EXPORT_SYMBOL(_GPL)?\s*\(\s*(\w+)\s*\)\s*;';
 
 my %constants;
 my %parameterdescs;
@@ -444,6 +451,12 @@ while ($ARGV[0] =~ m/^-(.*)/) {
 	$function_only = 2;
 	$function = shift @ARGV;
 	$function_table{$function} = 1;
+    } elsif ($cmd eq "-export") { # only exported symbols
+	$function_only = 3;
+	%function_table = ()
+    } elsif ($cmd eq "-internal") { # only non-exported symbols
+	$function_only = 4;
+	%function_table = ()
     } elsif ($cmd eq "-v") {
 	$verbose = 1;
     } elsif (($cmd eq "-h") || ($cmd eq "--help")) {
@@ -1971,8 +1984,10 @@ sub output_declaration {
     my $functype = shift;
     my $func = "output_${functype}_$output_mode";
     if (($function_only==0) ||
-	( $function_only == 1 && defined($function_table{$name})) ||
-	( $function_only == 2 && !($functype eq "function" && defined($function_table{$name}))))
+	( ($function_only == 1 || $function_only == 3) &&
+	  defined($function_table{$name})) ||
+	( ($function_only == 2 || $function_only == 4) &&
+	  !($functype eq "function" && defined($function_table{$name}))))
     {
 	&$func(@_);
 	$section_counter++;
@@ -2677,6 +2692,16 @@ sub process_file($) {
 
     $. = 1;
 
+    # two passes for -export and -internal
+    if ($function_only == 3 || $function_only == 4) {
+	while (<IN>) {
+	    if (/$export_symbol/o) {
+		$function_table{$2} = 1;
+	    }
+	}
+	seek(IN, 0, 0);
+    }
+
     $section_counter = 0;
     while (<IN>) {
 	while (s/\\\s*$//) {
-- 
2.1.4

  parent reply	other threads:[~2016-05-20 13:40 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 13:39 [PATCH 00/10] Documentation/Sphinx Jani Nikula
2016-05-20 13:39 ` [PATCH 01/10] kernel-doc: fix use of uninitialized value Jani Nikula
2016-05-20 13:39 ` Jani Nikula [this message]
2016-05-20 13:39 ` [PATCH 03/10] Documentation/sphinx: add basic working Sphinx configuration and build Jani Nikula
2016-05-20 13:39 ` [PATCH 04/10] Documentation: add .gitignore Jani Nikula
2016-05-20 13:39 ` [PATCH 05/10] Documentation/sphinx: add Sphinx kernel-doc directive extension Jani Nikula
2016-06-03 20:35   ` Jonathan Corbet
2016-06-04  6:57     ` Markus Heiser
2016-05-20 13:39 ` [PATCH 06/10] Documentation/sphinx: configure the kernel-doc extension Jani Nikula
2016-05-20 13:39 ` [PATCH 07/10] sphinx: cheesy script to convert .tmpl files Jani Nikula
2016-05-20 13:39 ` [PATCH 08/10] Documentation: add kernel hacking rst Jani Nikula
2016-05-20 13:39 ` [PATCH 09/10] Documentation: add kernel api rst Jani Nikula
2016-05-20 13:39 ` [PATCH 10/10] Documentation: moar files Jani Nikula
2016-05-29 20:33 ` [PATCH 00/10] Documentation/Sphinx Jani Nikula
2016-05-30  9:10   ` Daniel Vetter
2016-05-30 10:47     ` Markus Heiser
2016-05-30 14:46       ` Jani Nikula
2016-05-30 15:29         ` Daniel Vetter
2016-05-30 16:39         ` Markus Heiser
2016-05-30 20:05           ` Jani Nikula
2016-05-30 21:23             ` Mauro Carvalho Chehab
2016-05-31 10:16               ` Markus Heiser
2016-06-24 10:40                 ` Mauro Carvalho Chehab
2016-06-27  6:15                   ` Markus Heiser
2016-06-27 17:08                     ` Mauro Carvalho Chehab
2016-06-29 12:41                       ` Markus Heiser
2016-05-31  7:27             ` Markus Heiser
2016-05-31  8:07               ` Daniel Vetter
2016-05-31  9:39                 ` Markus Heiser
2016-05-31 10:30                   ` Jani Nikula
2016-05-31 11:12                     ` Markus Heiser
2016-06-03 20:47             ` rst2pdf (was [PATCH 00/10] Documentation/Sphinx) Jonathan Corbet
2016-06-07  6:02               ` Markus Heiser
2016-06-07  6:44                 ` Jani Nikula
2016-06-10 17:08                   ` Markus Heiser
2016-06-03 21:04             ` [PATCH 00/10] Documentation/Sphinx Jonathan Corbet
2016-06-03 22:54               ` Daniel Vetter
2016-06-04 11:45               ` Jani Nikula
2016-06-01  1:07     ` Jonathan Corbet
2016-06-01  6:42       ` Daniel Vetter
2016-06-03 20:16 ` Jonathan Corbet
2016-06-03 20:24   ` Daniel Vetter
2016-06-03 20:27     ` Jonathan Corbet
2016-06-04 13:01       ` Jani Nikula
2016-06-04 12:54   ` Jani Nikula

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=fc758c93601f3a0967e2d343b7b4a8fea7d9f64d.1463748027.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=corbet@lwn.net \
    --cc=dan@opendevise.io \
    --cc=daniel.vetter@ffwll.ch \
    --cc=grant.likely@secretlab.ca \
    --cc=hverkuil@xs4all.nl \
    --cc=keithp@keithp.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=markus.heiser@darmarit.de \
    --cc=mchehab@osg.samsung.com \
    --cc=russel@winder.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).