diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-11-16 11:41:02 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-11-16 11:41:02 +0100 |
commit | 5781e3653ed73e7d50febed40ff01db70e7dd780 (patch) | |
tree | e63098dab11b417cb02bf05cd80823f8ebb2eca4 /docs | |
parent | 41b1f649bf63e3663fcf3d4a678fef37688e32b7 (diff) | |
download | curl-5781e3653ed73e7d50febed40ff01db70e7dd780.tar.gz |
gen: support 'single' to make an individual page man page
Diffstat (limited to 'docs')
-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"; } #------------------------------------------------------------------------ |