1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 16:18:48 -05:00

gen: support 'single' to make an individual page man page

This commit is contained in:
Daniel Stenberg 2016-11-16 11:41:02 +01:00
parent 41b1f649bf
commit 5781e3653e

View File

@ -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 { sub single {
my ($f)=@_; my ($f, $standalone)=@_;
open(F, "<$f"); open(F, "<$f") ||
return 1;
my $short; my $short;
my $long; my $long;
my $tags; my $tags;
@ -113,26 +155,26 @@ sub single {
$opt .= " $arg"; $opt .= " $arg";
} }
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"; print ".IP \"$opt\"\n";
}
if($redirect) { if($redirect) {
my $l = manpageify($redirect); my $l = manpageify($redirect);
print "Use $l instead!\n"; print "Use $l instead!\n";
} }
else { else {
my $o;
if($protocols) { if($protocols) {
$o++; print protocols($standalone, $protocols);
print "($protocols) ";
} }
if(!$arg && !$mutexed && !$magic) {
$o++;
print "[Boolean] ";
} }
if($magic) {
$o++; if($standalone) {
print "[cmdline control] "; print ".SH DESCRIPTION\n";
}
print "\n" if($o);
} }
printdesc(@desc); printdesc(@desc);
@ -146,7 +188,7 @@ sub single {
my $l = manpageify($k); my $l = manpageify($k);
$mstr .= sprintf "%s$l", $mstr?" and ":""; $mstr .= sprintf "%s$l", $mstr?" and ":"";
} }
push @foot, "See also $mstr. "; push @foot, seealso($standalone, $mstr);
} }
if($requires) { if($requires) {
my $l = manpageify($long); my $l = manpageify($long);
@ -160,16 +202,17 @@ sub single {
my $l = manpageify($k); my $l = manpageify($k);
$mstr .= sprintf "%s$l", $mstr?" and ":""; $mstr .= sprintf "%s$l", $mstr?" and ":"";
} }
push @foot, "This option overrides $mstr. "; push @foot, overrides($standalone, "This option overrides $mstr. ");
} }
if($added) { if($added) {
push @foot, "Added in $added. "; push @foot, added($standalone, $added);
} }
if($foot[0]) { if($foot[0]) {
print "\n"; print "\n";
print @foot; print @foot;
print "\n"; print "\n";
} }
return 0;
} }
sub getshortlong { sub getshortlong {
@ -214,7 +257,8 @@ sub indexoptions {
} }
sub header { sub header {
open(F, "<page-header"); my ($f)=@_;
open(F, "<$f");
my @d; my @d;
while(<F>) { while(<F>) {
push @d, $_; push @d, $_;
@ -252,11 +296,18 @@ sub listhelp {
sub mainpage { sub mainpage {
# show the page header # show the page header
header(); header("page-header");
# output docs for all options # output docs for all options
foreach my $f (sort @s) { 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(); listhelp();
return; return;
} }
elsif($f eq "single") {
showonly(shift @ARGV);
return;
}
} while($f); } while($f);
print "Usage: gen.pl <mainpage/listhelp>\n"; print "Usage: gen.pl <mainpage/listhelp/single FILE>\n";
} }
#------------------------------------------------------------------------ #------------------------------------------------------------------------