diff options
Diffstat (limited to 'docs/cmdline-opts')
-rwxr-xr-x | docs/cmdline-opts/gen.pl | 99 |
1 files changed, 77 insertions, 22 deletions
diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl index ba405a4a6..e39f380a3 100755 --- a/docs/cmdline-opts/gen.pl +++ b/docs/cmdline-opts/gen.pl @@ -41,9 +41,51 @@ sub printdesc { } } +sub seealso { + my($standalone, $data)=@_; + if($standalone) { + return sprintf + ".SH \"SEE ALSO\"\n$data\n"; + } + else { + return "See also $data. "; + } +} + +sub overrides { + my ($standalone, $data)=@_; + if($standalone) { + return ".SH \"OVERRIDES\"\n$data\n"; + } + else { + return $data; + } +} + +sub protocols { + my ($standalone, $data)=@_; + if($standalone) { + return ".SH \"PROTOCOLS\"\n$data\n"; + } + else { + return "($data) "; + } +} + +sub added { + my ($standalone, $data)=@_; + if($standalone) { + return ".SH \"ADDED\"\nAdded in curl version $data\n"; + } + else { + return "Added in $added. "; + } +} + sub single { - my ($f)=@_; - open(F, "<$f"); + my ($f, $standalone)=@_; + open(F, "<$f") || + return 1; my $short; my $long; my $tags; @@ -113,26 +155,26 @@ sub single { $opt .= " $arg"; } - print ".IP \"$opt\"\n"; + if($standalone) { + print ".TH curl 1 \"30 Nov 2016\" \"curl 7.52.0\" \"curl manual\"\n"; + print ".SH OPTION\n"; + print "curl $opt\n"; + } + else { + print ".IP \"$opt\"\n"; + } if($redirect) { my $l = manpageify($redirect); print "Use $l instead!\n"; } else { - my $o; if($protocols) { - $o++; - print "($protocols) "; - } - if(!$arg && !$mutexed && !$magic) { - $o++; - print "[Boolean] "; - } - if($magic) { - $o++; - print "[cmdline control] "; + print protocols($standalone, $protocols); } - print "\n" if($o); + } + + if($standalone) { + print ".SH DESCRIPTION\n"; } printdesc(@desc); @@ -146,7 +188,7 @@ sub single { my $l = manpageify($k); $mstr .= sprintf "%s$l", $mstr?" and ":""; } - push @foot, "See also $mstr. "; + push @foot, seealso($standalone, $mstr); } if($requires) { my $l = manpageify($long); @@ -160,16 +202,17 @@ sub single { my $l = manpageify($k); $mstr .= sprintf "%s$l", $mstr?" and ":""; } - push @foot, "This option overrides $mstr. "; + push @foot, overrides($standalone, "This option overrides $mstr. "); } if($added) { - push @foot, "Added in $added. "; + push @foot, added($standalone, $added); } if($foot[0]) { print "\n"; print @foot; print "\n"; } + return 0; } sub getshortlong { @@ -214,7 +257,8 @@ sub indexoptions { } sub header { - open(F, "<page-header"); + my ($f)=@_; + open(F, "<$f"); my @d; while(<F>) { push @d, $_; @@ -252,11 +296,18 @@ sub listhelp { sub mainpage { # show the page header - header(); + header("page-header"); # output docs for all options foreach my $f (sort @s) { - single($f); + single($f, 0); + } +} + +sub showonly { + my ($f) = @_; + if(single($f, 1)) { + print STDERR "$f: failed\n"; } } @@ -272,9 +323,13 @@ sub getargs { listhelp(); return; } + elsif($f eq "single") { + showonly(shift @ARGV); + return; + } } while($f); - print "Usage: gen.pl <mainpage/listhelp>\n"; + print "Usage: gen.pl <mainpage/listhelp/single FILE>\n"; } #------------------------------------------------------------------------ |