doc/texi2pod: rework man inclusion logic
Ignore @c man begin ... @c man end comments, rely on @chapter for marking the beginning of the various manual top level sections. This allows us to write markup which is not dependent on the specific texi2pod.pl implementation. This change causes a few rendering issues, which will be fixed in further patches.
This commit is contained in:
parent
1166fc07a2
commit
ca3d786227
@ -27,9 +27,9 @@ use warnings;
|
|||||||
|
|
||||||
$output = 0;
|
$output = 0;
|
||||||
$skipping = 0;
|
$skipping = 0;
|
||||||
%sects = ();
|
%chapters = ();
|
||||||
@sects_sequence = ();
|
@chapters_sequence = ();
|
||||||
$section = "";
|
$chapter = "";
|
||||||
@icstack = ();
|
@icstack = ();
|
||||||
@endwstack = ();
|
@endwstack = ();
|
||||||
@skstack = ();
|
@skstack = ();
|
||||||
@ -116,18 +116,24 @@ INF: while(<$inf>) {
|
|||||||
die "cannot open $1: $!\n";
|
die "cannot open $1: $!\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
# Look for blocks surrounded by @c man begin SECTION ... @c man end.
|
/^\@chapter\s+([A-Za-z ]+)/ and do {
|
||||||
# This really oughta be @ifman ... @end ifman and the like, but such
|
# close old chapter
|
||||||
# would require rev'ing all other Texinfo translators.
|
$chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name);
|
||||||
/^\@c\s+man\s+begin\s+([A-Za-z ]+)/ and $sect = $1, push (@sects_sequence, $sect), $output = 1, next;
|
|
||||||
/^\@c\s+man\s+end/ and do {
|
# start new chapter
|
||||||
$sects{$sect} = "" unless exists $sects{$sect};
|
$chapter_name = $1, push (@chapters_sequence, $chapter_name);
|
||||||
$sects{$sect} .= postprocess($section);
|
$chapters{$chapter_name} = "" unless exists $chapters{$chapter_name};
|
||||||
$section = "";
|
$chapter = "";
|
||||||
$output = 0;
|
$output = 1;
|
||||||
next;
|
next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/^\@bye/ and do {
|
||||||
|
# close old chapter
|
||||||
|
$chapters{$chapter_name} .= postprocess($chapter) if ($chapter_name);
|
||||||
|
last INF;
|
||||||
|
};
|
||||||
|
|
||||||
# handle variables
|
# handle variables
|
||||||
/^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do {
|
/^\@set\s+([a-zA-Z0-9_-]+)\s*(.*)$/ and do {
|
||||||
$defs{$1} = $2;
|
$defs{$1} = $2;
|
||||||
@ -293,7 +299,7 @@ INF: while(<$inf>) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$section .= $shift.$_."\n";
|
$chapter .= $shift.$_."\n";
|
||||||
}
|
}
|
||||||
# End of current file.
|
# End of current file.
|
||||||
close($inf);
|
close($inf);
|
||||||
@ -302,16 +308,15 @@ $inf = pop @instack;
|
|||||||
|
|
||||||
die "No filename or title\n" unless defined $fn && defined $tl;
|
die "No filename or title\n" unless defined $fn && defined $tl;
|
||||||
|
|
||||||
$sects{NAME} = "$fn \- $tl\n";
|
$chapters{NAME} = "$fn \- $tl\n";
|
||||||
$sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES};
|
$chapters{FOOTNOTES} .= "=back\n" if exists $chapters{FOOTNOTES};
|
||||||
|
|
||||||
unshift @sects_sequence, "NAME";
|
unshift @chapters_sequence, "NAME";
|
||||||
for $sect (@sects_sequence) {
|
for $chapter (@chapters_sequence) {
|
||||||
if(exists $sects{$sect}) {
|
if (exists $chapters{$chapter}) {
|
||||||
$head = $sect;
|
$head = uc($chapter);
|
||||||
$head =~ s/SEEALSO/SEE ALSO/;
|
|
||||||
print "=head1 $head\n\n";
|
print "=head1 $head\n\n";
|
||||||
print scalar unmunge ($sects{$sect});
|
print scalar unmunge ($chapters{$chapter});
|
||||||
print "\n";
|
print "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,13 +414,13 @@ sub unmunge
|
|||||||
|
|
||||||
sub add_footnote
|
sub add_footnote
|
||||||
{
|
{
|
||||||
unless (exists $sects{FOOTNOTES}) {
|
unless (exists $chapters{FOOTNOTES}) {
|
||||||
$sects{FOOTNOTES} = "\n=over 4\n\n";
|
$chapters{FOOTNOTES} = "\n=over 4\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$sects{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++;
|
$chapters{FOOTNOTES} .= "=item $fnno.\n\n"; $fnno++;
|
||||||
$sects{FOOTNOTES} .= $_[0];
|
$chapters{FOOTNOTES} .= $_[0];
|
||||||
$sects{FOOTNOTES} .= "\n\n";
|
$chapters{FOOTNOTES} .= "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
# stolen from Symbol.pm
|
# stolen from Symbol.pm
|
||||||
|
Loading…
x
Reference in New Issue
Block a user