1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -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 {
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) ";
print protocols($standalone, $protocols);
}
if(!$arg && !$mutexed && !$magic) {
$o++;
print "[Boolean] ";
}
if($magic) {
$o++;
print "[cmdline control] ";
}
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";
}
#------------------------------------------------------------------------