summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wilcox <mawilcox@microsoft.com>2018-02-13 16:15:35 -0500
committerJonathan Corbet <corbet@lwn.net>2018-02-13 16:21:52 -0500
commit5b229fbec89b90f73d1829e022163d9b896dc94c (patch)
tree07f60b861b370a38879cd3ba0681c0d775d99fd6
parentdcb50d979ecc80e1f2d90acb7734d7bcd0e44672 (diff)
Add scripts/split-man.pl
Instead of asking the user to copy and paste a small perl script from the documentation, just distribute the perl script in the scripts directory. Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
-rw-r--r--Documentation/doc-guide/kernel-doc.rst30
-rwxr-xr-xscripts/split-man.pl28
2 files changed, 30 insertions, 28 deletions
diff --git a/Documentation/doc-guide/kernel-doc.rst b/Documentation/doc-guide/kernel-doc.rst
index 64ca081d075e..466347067f79 100644
--- a/Documentation/doc-guide/kernel-doc.rst
+++ b/Documentation/doc-guide/kernel-doc.rst
@@ -528,32 +528,6 @@ How to use kernel-doc to generate man pages
528------------------------------------------- 528-------------------------------------------
529 529
530If you just want to use kernel-doc to generate man pages you can do this 530If you just want to use kernel-doc to generate man pages you can do this
531from the Kernel git tree:: 531from the kernel git tree::
532 532
533 $ scripts/kernel-doc -man $(git grep -l '/\*\*' |grep -v Documentation/) | ./split-man.pl /tmp/man 533 $ scripts/kernel-doc -man $(git grep -l '/\*\*' -- :^Documentation :^tools) | scripts/split-man.pl /tmp/man
534
535Using the small ``split-man.pl`` script below::
536
537
538 #!/usr/bin/perl
539
540 if ($#ARGV < 0) {
541 die "where do I put the results?\n";
542 }
543
544 mkdir $ARGV[0],0777;
545 $state = 0;
546 while (<STDIN>) {
547 if (/^\.TH \"[^\"]*\" 9 \"([^\"]*)\"/) {
548 if ($state == 1) { close OUT }
549 $state = 1;
550 $fn = "$ARGV[0]/$1.9";
551 print STDERR "Creating $fn\n";
552 open OUT, ">$fn" or die "can't open $fn: $!\n";
553 print OUT $_;
554 } elsif ($state != 0) {
555 print OUT $_;
556 }
557 }
558
559 close OUT;
diff --git a/scripts/split-man.pl b/scripts/split-man.pl
new file mode 100755
index 000000000000..bfe16cbe42df
--- /dev/null
+++ b/scripts/split-man.pl
@@ -0,0 +1,28 @@
1#!/usr/bin/perl
2# SPDX-License-Identifier: GPL-2.0
3#
4# Author: Mauro Carvalho Chehab <mchehab@s-opensource.com>
5#
6# Produce manpages from kernel-doc.
7# See Documentation/doc-guide/kernel-doc.rst for instructions
8
9if ($#ARGV < 0) {
10 die "where do I put the results?\n";
11}
12
13mkdir $ARGV[0],0777;
14$state = 0;
15while (<STDIN>) {
16 if (/^\.TH \"[^\"]*\" 9 \"([^\"]*)\"/) {
17 if ($state == 1) { close OUT }
18 $state = 1;
19 $fn = "$ARGV[0]/$1.9";
20 print STDERR "Creating $fn\n";
21 open OUT, ">$fn" or die "can't open $fn: $!\n";
22 print OUT $_;
23 } elsif ($state != 0) {
24 print OUT $_;
25 }
26}
27
28close OUT;