]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
docs/make: generate curl.1 from listed files only
authorDaniel Stenberg <daniel@haxx.se>
Wed, 25 Mar 2020 22:16:28 +0000 (23:16 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 26 Mar 2020 12:25:59 +0000 (13:25 +0100)
Previously it rendered the page from files matching "*.d" in the correct
directory, which worked fine in git builds when the files were added but
made it easy to forget adding the files to the dist.

Now, only man page sections listed in DPAGES in Makefile.inc will be
used, thus "forcing" us to update this to get the man page right and get
it included in the dist at the same time.

Ref: #5146
Closes #5149

docs/cmdline-opts/Makefile.am
docs/cmdline-opts/gen.pl
src/tool_help.c

index e6ecf7a6b0c73d55279451ddf87ecdc13d8f5471..0c81b623b2cc0166f078e897081f2f3eac9d4932 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -31,4 +31,5 @@ EXTRA_DIST = $(DPAGES) MANPAGE.md gen.pl $(OTHERPAGES) CMakeLists.txt
 all: $(MANPAGE)
 
 $(MANPAGE): $(DPAGES) $(OTHERPAGES) Makefile.inc
-       @PERL@ $(srcdir)/gen.pl mainpage $(srcdir) > $(MANPAGE)
+       @echo "generate $(MANPAGE)"
+       @(cd $(srcdir) && @PERL@ ./gen.pl mainpage $(DPAGES)) > $(MANPAGE)
index 63e3504d3e3d0b173576a11682ab753f8c508c04..b7a924e8afa788ece5c21812beec0f799213a9a4 100755 (executable)
@@ -25,7 +25,7 @@
 
 This script generates the manpage.
 
-Example: gen.pl mainpage > curl.1
+Example: gen.pl <command> [files] > curl.1
 
 Dev notes:
 
@@ -37,12 +37,6 @@ Unfortunately it seems some perls like msysgit can't handle a global input-only
 =end comment
 =cut
 
-my $some_dir=$ARGV[1] || ".";
-
-opendir(my $dh, $some_dir) || die "Can't opendir $some_dir: $!";
-my @s = grep { /\.d$/ && -f "$some_dir/$_" } readdir($dh);
-closedir $dh;
-
 my %optshort;
 my %optlong;
 my %helplong;
@@ -122,7 +116,7 @@ sub added {
 
 sub single {
     my ($f, $standalone)=@_;
-    open(F, "<:crlf", "$some_dir/$f") ||
+    open(F, "<:crlf", "$f") ||
         return 1;
     my $short;
     my $long;
@@ -262,7 +256,7 @@ sub single {
 
 sub getshortlong {
     my ($f)=@_;
-    open(F, "<:crlf", "$some_dir/$f");
+    open(F, "<:crlf", "$f");
     my $short;
     my $long;
     my $help;
@@ -301,14 +295,15 @@ sub getshortlong {
 }
 
 sub indexoptions {
-  foreach my $f (@s) {
-    getshortlong($f);
-  }
+    my (@files) = @_;
+    foreach my $f (@files) {
+        getshortlong($f);
+    }
 }
 
 sub header {
     my ($f)=@_;
-    open(F, "<:crlf", "$some_dir/$f");
+    open(F, "<:crlf", "$f");
     my @d;
     while(<F>) {
         push @d, $_;
@@ -347,12 +342,15 @@ sub listhelp {
 }
 
 sub mainpage {
+    my (@files) = @_;
     # show the page header
     header("page-header");
 
     # output docs for all options
-    foreach my $f (sort @s) {
-        single($f, 0);
+    foreach my $f (sort @files) {
+        if(single($f, 0)) {
+            print STDERR "Can't read $f?\n";
+        }
     }
 
     header("page-footer");
@@ -379,33 +377,33 @@ sub showprotocols {
 }
 
 sub getargs {
-    my $f;
-    do {
-        $f = shift @ARGV;
-        if($f eq "mainpage") {
-            mainpage();
-            return;
-        }
-        elsif($f eq "listhelp") {
-            listhelp();
-            return;
-        }
-        elsif($f eq "single") {
-            showonly(shift @ARGV);
-            return;
-        }
-        elsif($f eq "protos") {
-            showprotocols();
-            return;
-        }
-    } while($f);
+    my ($f, @s) = @_;
+    if($f eq "mainpage") {
+        mainpage(@s);
+        return;
+    }
+    elsif($f eq "listhelp") {
+        listhelp();
+        return;
+    }
+    elsif($f eq "single") {
+        showonly($s[0]);
+        return;
+    }
+    elsif($f eq "protos") {
+        showprotocols();
+        return;
+    }
 
-    print "Usage: gen.pl <mainpage/listhelp/single FILE/protos> [srcdir]\n";
+    print "Usage: gen.pl <mainpage/listhelp/single FILE/protos> [files]\n";
 }
 
 #------------------------------------------------------------------------
 
+my $cmd = shift @ARGV;
+my @files = @ARGV; # the rest are the files
+
 # learn all existing options
-indexoptions();
+indexoptions(@files);
 
-getargs();
+getargs($cmd, @files);
index 4fe9e4ce0aeadbcf49ed6f460c0552766544c7e3..822f396a3d80f6f0e270a3ea403510ad2d8c0119 100644 (file)
@@ -40,7 +40,7 @@
  ---------------------------------------------------------
 
   cd $srcroot/docs/cmdline-opts
-  ./gen.pl listhelp
+  ./gen.pl listhelp *.d
  */
 
 struct helptxt {