From: Jarkko Hietaniemi Date: Mon, 26 Nov 2001 11:28:18 +0000 (+0000) Subject: Upgrade to podlators 1.16. X-Git-Tag: accepted/trunk/20130322.191538~29211 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b4558dc4bd9c296354bf29971495ac6ba5e42420;p=platform%2Fupstream%2Fperl.git Upgrade to podlators 1.16. p4raw-id: //depot/perl@13282 --- diff --git a/MANIFEST b/MANIFEST index 8f920e2..57c9a2d 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1169,6 +1169,7 @@ lib/Pod/Parser.pm Pod-Parser - define base class for parsing POD lib/Pod/ParseUtils.pm Pod-Parser - pod utility functions lib/Pod/Plainer.pm Pod migration utility module lib/Pod/Select.pm Pod-Parser - select portions of POD docs +lib/Pod/t/basic.cap podlators test lib/Pod/t/basic.clr podlators test lib/Pod/t/basic.man podlators test lib/Pod/t/basic.ovr podlators test diff --git a/lib/Pod/Man.pm b/lib/Pod/Man.pm index 6ddbe13..6a33aa0 100644 --- a/lib/Pod/Man.pm +++ b/lib/Pod/Man.pm @@ -1,5 +1,5 @@ # Pod::Man -- Convert POD data to formatted *roff input. -# $Id: Man.pm,v 1.28 2001/11/23 08:13:16 eagle Exp $ +# $Id: Man.pm,v 1.29 2001/11/26 08:35:15 eagle Exp $ # # Copyright 1999, 2000, 2001 by Russ Allbery # @@ -38,7 +38,7 @@ use vars qw(@ISA %ESCAPES $PREAMBLE $VERSION); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 1.28; +$VERSION = 1.29; ############################################################################## @@ -1176,7 +1176,7 @@ also be used directly. As a derived class from Pod::Parser, Pod::Man supports the same methods and interfaces. See L for all the details; briefly, one creates a -new parser with Cnew()> and then calls either +new parser with C<< Pod::Man->new() >> and then calls either parse_from_filehandle() or parse_from_file(). new() can take options, in the form of key/value pairs that control the @@ -1201,10 +1201,10 @@ func(), func(3), and simple variable references like $foo or @bar so you don't have to use code escapes for them; complex expressions like C<$fred{'stuff'}> will still need to be escaped, though. It also translates dashes that aren't used as hyphens into en dashes, makes long dashes--like -this--into proper em dashes, fixes "paired quotes," makes C++ and PI look -right, puts a little space between double underbars, makes ALLCAPS a teeny -bit smaller in B, and escapes stuff that *roff treats as special so -that you don't have to. +this--into proper em dashes, fixes "paired quotes," makes C++ look right, +puts a little space between double underbars, makes ALLCAPS a teeny bit +smaller in B, and escapes stuff that *roff treats as special so that +you don't have to. The recognized options to new() are as follows. All options take a single argument. @@ -1345,22 +1345,24 @@ C<=over> command. =head1 BUGS -The lint-like features and strict POD format checking done by B are -not yet implemented and should be, along with the corresponding C -option. +Eight-bit input data isn't handled at all well at present. The correct +approach would be to map EEE escapes to the appropriate UTF-8 +characters and then do a translation pass on the output according to the +user-specified output character set. Unfortunately, we can't send eight-bit +data directly to the output unless the user says this is okay, since some +vendor *roff implementations can't handle eight-bit data. If the *roff +implementation can, however, that's far superior to the current hacked +characters that only work under troff. + +There is currently no way to turn off the guesswork that tries to format +unmarked text appropriately, and sometimes it isn't wanted (particularly +when using POD to document something other than Perl). The NAME section should be recognized specially and index entries emitted for everything in that section. This would have to be deferred until the next section, since extraneous things in NAME tends to confuse various man page processors. -The handling of hyphens and em dashes is somewhat fragile, and one may get -the wrong one under some circumstances. This should only matter for -B output. - -When and whether to use small caps is somewhat tricky, and Pod::Man doesn't -necessarily get it right. - Pod::Man doesn't handle font names longer than two characters. Neither do most B implementations, but GNU troff does as an extension. It would be nice to support as an option for those who want to use it. @@ -1372,6 +1374,15 @@ output if needed, perhaps on the fly as the characters are used. Pod::Man is excessively slow. +=head1 CAVEATS + +The handling of hyphens and em dashes is somewhat fragile, and one may get +the wrong one under some circumstances. This should only matter for +B output. + +When and whether to use small caps is somewhat tricky, and Pod::Man doesn't +necessarily get it right. + =head1 SEE ALSO L, L, L, L, L, diff --git a/lib/Pod/Text/Termcap.pm b/lib/Pod/Text/Termcap.pm index a3e8770..4733a81 100644 --- a/lib/Pod/Text/Termcap.pm +++ b/lib/Pod/Text/Termcap.pm @@ -1,5 +1,5 @@ # Pod::Text::Termcap -- Convert POD data to ASCII text with format escapes. -# $Id: Termcap.pm,v 1.3 2001/11/15 08:04:18 eagle Exp $ +# $Id: Termcap.pm,v 1.4 2001/11/26 07:54:54 eagle Exp $ # # Copyright 1999, 2001 by Russ Allbery # @@ -30,7 +30,7 @@ use vars qw(@ISA $VERSION); # Don't use the CVS revision as the version, since this module is also in Perl # core and too many things could munge CVS magic revision strings. This # number should ideally be the same as the CVS revision in podlators, however. -$VERSION = 1.03; +$VERSION = 1.04; ############################################################################## @@ -49,10 +49,11 @@ sub initialize { my $termios = POSIX::Termios->new; $termios->getattr; my $ospeed = $termios->getospeed; - my $term = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed }; - $$self{BOLD} = $$term{_md} or die 'BOLD'; - $$self{UNDL} = $$term{_us} or die 'UNDL'; - $$self{NORM} = $$term{_me} or die 'NORM'; + my $term; + eval { $term = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed } }; + $$self{BOLD} = $$term{_md} || "\e[1m"; + $$self{UNDL} = $$term{_us} || "\e[4m"; + $$self{NORM} = $$term{_me} || "\e[m"; unless (defined $$self{width}) { $$self{width} = $ENV{COLUMNS} || $$term{_co} || 78; @@ -139,9 +140,17 @@ text using the correct termcap escape sequences for the current terminal. Apart from the format codes, it in all ways functions like Pod::Text. See L for details and available options. +=head NOTES + +This module uses Term::Cap to retrieve the formatting escape sequences for +the current terminal, and falls back on the ECMA-48 (the same in this +regard as ANSI X3.64 and ISO 6429, the escape codes also used by DEC VT100 +terminals) if the bold, underline, and reset codes aren't set in the +termcap information. + =head1 SEE ALSO -L, L +L, L, L =head1 AUTHOR diff --git a/lib/Pod/t/basic.cap b/lib/Pod/t/basic.cap new file mode 100644 index 0000000..21f38ba --- /dev/null +++ b/lib/Pod/t/basic.cap @@ -0,0 +1,283 @@ +NAME + basic.pod - Test of various basic POD features in translators. + +HEADINGS + Try a few different levels of headings, with embedded formatting codes and + other interesting bits. + +This "is" a "level 1" heading + ``Level'' "2 heading + Level 3 heading with "weird stuff "" (double quote)" + Level "4 "heading" + Now try again with intermixed text. + +This "is" a "level 1" heading + Text. + + ``Level'' 2 heading + Text. + + Level 3 heading with "weird stuff" + Text. + + Level "4 "heading" + Text. + +LINKS + These are all taken from the Pod::Parser tests. + + Try out LOTS of different ways of specifying references: + + Reference the "section" in manpage + + Reference the "section" in manpage + + Reference the "section" in manpage + + Reference the "section" in manpage + + Reference the "manpage/section" + + Reference the "section" in "manpage" + + Reference the "section" in manpage + + Reference the "section" in manpage + + Reference the "section" in manpage + + Now try it using the new "|" stuff ... + + Reference the thistext| + + Reference the thistext | + + Reference the thistext| + + Reference the thistext | + + Reference the thistext| + + Reference the thistext | + + Reference the thistext| + + Reference the thistext| + + Reference the thistext | + + And then throw in a few new ones of my own. + + foo + + foo + + "bar" in foo + + "baz boo" in foo + + "bar" + + "baz boo" + + "baz boo" + + "baz boo" in foo bar + + "baz boo" in foo bar + + "boo" in foo bar baz + + "boo var baz" + + "bar baz" + + "boo bar baz / baz boo" + + "boo", "bar", and "baz" + + foobar + + Testing italics + + "Italic text" in foo + + "Section "with" other markup" in foo|bar + + Nested + +OVER AND ITEMS + Taken from Pod::Parser tests, this is a test to ensure that multiline + =item paragraphs get indented appropriately. + + This is a test. + + There should be whitespace now before this line. + + Taken from Pod::Parser tests, this is a test to ensure the nested =item + paragraphs get indented appropriately. + + 1 First section. + + a this is item a + + b this is item b + + 2 Second section. + + a this is item a + + b this is item b + + c + d This is item c & d. + + Now some additional weirdness of our own. Make sure that multiple tags for + one paragraph are properly compacted. + + "foo" + bar + "baz" + There shouldn't be any spaces between any of these item tags; this + idiom is used in perlfunc. + + Some longer item text + Just to make sure that we test paragraphs where the item text doesn't + fit in the margin of the paragraph (and make sure that this paragraph + fills a few lines). + + Let's also make it multiple paragraphs to be sure that works. + + Test use of =over without =item as a block "quote" or block paragraph. + + This should be indented four spaces but otherwise formatted the same + as any other regular text paragraph. Make sure it's long enough to see + the results of the formatting..... + + Now try the same thing nested, and make sure that the indentation is reset + back properly. + + This paragraph should be doubly indented. + + This paragraph should only be singly indented. + + * This is an item in the middle of a block-quote, which should be + allowed. + + * We're also testing tagless item commands. + + Should be back to the single level of indentation. + + Should be back to regular indentation. + + Now also check the transformation of * into real bullets for man pages. + + * An item. We're also testing using =over without a number, and making + sure that item text wraps properly. + + * Another item. + + and now test the numbering of item blocks. + + 1. First item. + + 2. Second item. + +FORMATTING CODES + Another test taken from Pod::Parser. + + This is a test to see if I can do not only $self and "method()", but also + "$self->method()" and "$self->{FIELDNAME}" and "$Foo <=> $Bar" without + resorting to escape sequences. If I want to refer to the right-shift + operator I can do something like "$x >> 3" or even "$y >> 5". + + Now for the grand finale of "$self->method()->{FIELDNAME} = {FOO=>BAR}". + And I also want to make sure that newlines work like this "$self->{FOOBAR} + >> 3 and [$b => $a]->[$a <=> $b]" + + Of course I should still be able to do all this with escape sequences too: + "$self->method()" and "$self->{FIELDNAME}" and "{FOO=>BAR}". + + Dont forget "$self->method()->{FIELDNAME} = {FOO=>BAR}". + + And make sure that 0 works too! + + Now, if I use << or >> as my delimiters, then I have to use whitespace. So + things like "<$self-"method()>> and "<$self-"{FIELDNAME}>> wont end up + doing what you might expect since the first > will still terminate the + first < seen. + + Lets make sure these work for empty ones too, like and ">>" (just to be + obnoxious) + + The statement: "This is dog kind's finest hour!" is a parody of a + quotation from Winston Churchill. + + The following tests are added to those: + + Make sure that a few other odd things still work. This should be a + vertical bar: |. Here's a test of a few more special escapes that have to + be supported: + + & An ampersand. + + ' An apostrophe. + + < A less-than sign. + + > A greater-than sign. + + " A double quotation mark. + + / A forward slash. + + Try to get this bit of text over towards the edge so + |that all of this text inside S<> won't| be wrapped. Also test the + |same thing with non-breaking spaces.| + + There is a soft hyphen in hyphen at hy-phen. + + This is a test of an index entry. + +VERBATIM + Throw in a few verbatim paragraphs. + + use Term::ANSIColor; + print color 'bold blue'; + print "This text is bold blue.\n"; + print color 'reset'; + print "This text is normal.\n"; + print colored ("Yellow on magenta.\n", 'yellow on_magenta'); + print "This text is normal.\n"; + print colored ['yellow on_magenta'], "Yellow on magenta.\n"; + + use Term::ANSIColor qw(uncolor); + print uncolor '01;31', "\n"; + + But this isn't verbatim (make sure it wraps properly), and the next + paragraph is again: + + use Term::ANSIColor qw(:constants); + print BOLD, BLUE, "This text is in bold blue.\n", RESET; + + use Term::ANSIColor qw(:constants); $Term::ANSIColor::AUTORESET = 1; print BOLD BLUE "This text is in bold blue.\n"; print "This text is normal.\n"; + + (Ugh, that's obnoxiously long.) Try different spacing: + + Starting with a tab. + Not + starting + with + a + tab. But this should still be verbatim. + As should this. + + This isn't. + + This is. And this: is an internal tab. It should be: + |--| <= lined up with that. + + (Tricky, but tabs should be expanded before the translator starts in on + the text since otherwise text with mixed tabs and spaces will get messed + up.) + diff --git a/lib/Pod/t/basic.t b/lib/Pod/t/basic.t index b58ea6f..a87cb8b 100644 --- a/lib/Pod/t/basic.t +++ b/lib/Pod/t/basic.t @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# $Id: basic.t,v 1.1 2001/11/23 10:09:06 eagle Exp $ +# $Id: basic.t,v 1.3 2001/11/26 09:24:37 eagle Exp $ # # basic.t -- Basic tests for podlators. # @@ -11,12 +11,13 @@ BEGIN { chdir 't' if -d 't'; if ($ENV{PERL_CORE}) { - @INC = '../lib'; + @INC = '../lib'; } else { - unshift (@INC, '../blib/lib'); + unshift (@INC, '../blib/lib'); } + unshift (@INC, '../blib/lib'); $| = 1; - print "1..9\n"; + print "1..11\n"; } END { @@ -29,11 +30,27 @@ use Pod::Text::Color; use Pod::Text::Overstrike; use Pod::Text::Termcap; +# Find the path to the test source files. This requires some fiddling when +# these tests are run as part of Perl core. +sub source_path { + my $file = shift; + if ($ENV{PERL_CORE}) { + require File::Spec; + my $updir = File::Spec->updir; + my $dir = File::Spec->catdir ($updir, 'lib', 'Pod', 't'); + return File::Spec->catfile ($dir, $file); + } else { + return $file; + } +} + $loaded = 1; print "ok 1\n"; # Hard-code a few values to try to get reproducible results. -@ENV{qw(TERMCAP COLUMNS)} = ('co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m', 80); +$ENV{COLUMNS} = 80; +$ENV{TERM} = 'xterm'; +$ENV{TERMCAP} = 'xterm:co=80:do=^J:md=\E[1m:us=\E[4m:me=\E[m'; # Map of translators to file extensions to find the formatted output to # compare against. @@ -41,23 +58,11 @@ my %translators = ('Pod::Man' => 'man', 'Pod::Text' => 'txt', 'Pod::Text::Color' => 'clr', 'Pod::Text::Overstrike' => 'ovr', - # 'Pod::Text::Termcap' => 'cap' # unportable - ); + 'Pod::Text::Termcap' => 'cap'); # Set default options to match those of pod2man and pod2text. %options = (sentence => 0); -sub basic { - my $basic = shift; - if ($ENV{PERL_CORE}) { - require File::Spec; - return File::Spec->catfile(File::Spec->catdir(File::Spec->updir, - "lib", "Pod", "t"), - $basic); - } - return $basic; -} - my $n = 2; for (sort keys %translators) { my $parser = $_->new (%options); @@ -68,7 +73,7 @@ for (sort keys %translators) { # line. That means that we don't check those things; oh well. The header # changes with each version change or touch of the input file. if ($_ eq 'Pod::Man') { - $parser->parse_from_file (basic("basic.pod"), 'out.tmp'); + $parser->parse_from_file (source_path ('basic.pod'), 'out.tmp'); open (TMP, 'out.tmp') or die "Cannot open out.tmp: $!\n"; open (OUTPUT, "> out.$translators{$_}") or die "Cannot create out.$translators{$_}: $!\n"; @@ -79,11 +84,12 @@ for (sort keys %translators) { close TMP; unlink 'out.tmp'; } else { - $parser->parse_from_file (basic("basic.pod"), "out.$translators{$_}"); + my $basic = source_path ('basic.pod'); + $parser->parse_from_file ($basic, "out.$translators{$_}"); } { local $/; - open (MASTER, basic("basic.$translators{$_}")) + open (MASTER, source_path ("basic.$translators{$_}")) or die "Cannot open basic.$translators{$_}: $!\n"; open (OUTPUT, "out.$translators{$_}") or die "Cannot open out.$translators{$_}: $!\n"; diff --git a/pod/pod2man.PL b/pod/pod2man.PL index 8642641..1c27bfe 100644 --- a/pod/pod2man.PL +++ b/pod/pod2man.PL @@ -36,7 +36,7 @@ $Config{startperl} print OUT <<'!NO!SUBS!'; # pod2man -- Convert POD data to formatted *roff input. -# $Id: pod2man.PL,v 1.8 2001/11/05 04:55:47 eagle Exp $ +# $Id: pod2man.PL,v 1.9 2001/11/26 08:44:58 eagle Exp $ # # Copyright 1999, 2000, 2001 by Russ Allbery # @@ -79,6 +79,10 @@ if ($options{official} && !defined $options{center}) { my $verbose = $options{verbose}; delete $options{verbose}; +# This isn't a valid Pod::Man option and is only accepted for backwards +# compatibility. +delete $options{lax}; + # Initialize and run the formatter, pulling a pair of input and output off at # a time. my $parser = Pod::Man->new (%options); @@ -183,8 +187,9 @@ Print out usage information. =item B<-l>, B<--lax> -Don't complain when required sections are missing. Not currently used, as -POD checking functionality is not yet implemented in Pod::Man. +No longer used. B used to check its input for validity as a manual +page, but this should now be done by L instead. Accepted for +backwards compatibility; this option no longer does anything. =item B<-n> I, B<--name>=I @@ -274,8 +279,6 @@ L for more details. Lots of this documentation is duplicated from L. -POD checking and the corresponding B<--lax> option don't work yet. - =head1 NOTES For those not sure of the proper layout of a man page, here are some notes @@ -512,16 +515,16 @@ to later edit the documentation. Note that many existing translators or URLs when wrapped in LEE, so don't do that. For additional information that may be more accurate for your specific -system, see either man(5) or man(7) depending on your system manual section -numbering conventions. +system, see either L or L depending on your system manual +section numbering conventions. =head1 SEE ALSO -L, L, man(1), nroff(1), -troff(1), man(7) +L, L, L, L, L, +L, L -The man page documenting the an macro set may be man(5) instead of man(7) on -your system. +The man page documenting the an macro set may be L instead of +L on your system. =head1 AUTHOR