xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/pod/pod2man.PL (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/local/bin/perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateuse Config;
4*0Sstevel@tonic-gateuse File::Basename qw(&basename &dirname);
5*0Sstevel@tonic-gateuse Cwd;
6*0Sstevel@tonic-gate
7*0Sstevel@tonic-gate# List explicitly here the variables you want Configure to
8*0Sstevel@tonic-gate# generate.  Metaconfig only looks for shell variables, so you
9*0Sstevel@tonic-gate# have to mention them as if they were shell variables, not
10*0Sstevel@tonic-gate# %Config entries.  Thus you write
11*0Sstevel@tonic-gate#  $startperl
12*0Sstevel@tonic-gate# to ensure Configure will look for $Config{startperl}.
13*0Sstevel@tonic-gate
14*0Sstevel@tonic-gate# This forces PL files to create target in same directory as PL file.
15*0Sstevel@tonic-gate# This is so that make depend always knows where to find PL derivatives.
16*0Sstevel@tonic-gate$origdir = cwd;
17*0Sstevel@tonic-gatechdir dirname($0);
18*0Sstevel@tonic-gate$file = basename($0, '.PL');
19*0Sstevel@tonic-gate$file .= '.com' if $^O eq 'VMS';
20*0Sstevel@tonic-gate
21*0Sstevel@tonic-gateopen OUT,">$file" or die "Can't create $file: $!";
22*0Sstevel@tonic-gate
23*0Sstevel@tonic-gateprint "Extracting $file (with variable substitutions)\n";
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate# In this section, perl variables will be expanded during extraction.
26*0Sstevel@tonic-gate# You can use $Config{...} to use Configure variables.
27*0Sstevel@tonic-gate
28*0Sstevel@tonic-gateprint OUT <<"!GROK!THIS!";
29*0Sstevel@tonic-gate$Config{startperl}
30*0Sstevel@tonic-gate    eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
31*0Sstevel@tonic-gate        if \$running_under_some_shell;
32*0Sstevel@tonic-gate!GROK!THIS!
33*0Sstevel@tonic-gate
34*0Sstevel@tonic-gate# In the following, perl variables are not expanded during extraction.
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gateprint OUT <<'!NO!SUBS!';
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gate# pod2man -- Convert POD data to formatted *roff input.
39*0Sstevel@tonic-gate# $Id: pod2man.PL,v 1.10 2002/07/15 05:45:56 eagle Exp $
40*0Sstevel@tonic-gate#
41*0Sstevel@tonic-gate# Copyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>
42*0Sstevel@tonic-gate#
43*0Sstevel@tonic-gate# This program is free software; you may redistribute it and/or modify it
44*0Sstevel@tonic-gate# under the same terms as Perl itself.
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gaterequire 5.004;
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gateuse Getopt::Long qw(GetOptions);
49*0Sstevel@tonic-gateuse Pod::Man ();
50*0Sstevel@tonic-gateuse Pod::Usage qw(pod2usage);
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gateuse strict;
53*0Sstevel@tonic-gate
54*0Sstevel@tonic-gate# Silence -w warnings.
55*0Sstevel@tonic-gateuse vars qw($running_under_some_shell);
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate# Insert -- into @ARGV before any single dash argument to hide it from
58*0Sstevel@tonic-gate# Getopt::Long; we want to interpret it as meaning stdin (which Pod::Parser
59*0Sstevel@tonic-gate# does correctly).
60*0Sstevel@tonic-gatemy $stdin;
61*0Sstevel@tonic-gate@ARGV = map { $_ eq '-' && !$stdin++ ? ('--', $_) : $_ } @ARGV;
62*0Sstevel@tonic-gate
63*0Sstevel@tonic-gate# Parse our options, trying to retain backwards compatibility with pod2man but
64*0Sstevel@tonic-gate# allowing short forms as well.  --lax is currently ignored.
65*0Sstevel@tonic-gatemy %options;
66*0Sstevel@tonic-gateGetopt::Long::config ('bundling_override');
67*0Sstevel@tonic-gateGetOptions (\%options, 'section|s=s', 'release|r=s', 'center|c=s',
68*0Sstevel@tonic-gate            'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s',
69*0Sstevel@tonic-gate            'fixedbolditalic=s', 'name|n=s', 'official|o', 'quotes|q=s',
70*0Sstevel@tonic-gate            'lax|l', 'help|h', 'verbose|v') or exit 1;
71*0Sstevel@tonic-gatepod2usage (0) if $options{help};
72*0Sstevel@tonic-gate
73*0Sstevel@tonic-gate# Official sets --center, but don't override things explicitly set.
74*0Sstevel@tonic-gateif ($options{official} && !defined $options{center}) {
75*0Sstevel@tonic-gate    $options{center} = 'Perl Programmers Reference Guide';
76*0Sstevel@tonic-gate}
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gate# Verbose is only our flag, not a Pod::Man flag.
79*0Sstevel@tonic-gatemy $verbose = $options{verbose};
80*0Sstevel@tonic-gatedelete $options{verbose};
81*0Sstevel@tonic-gate
82*0Sstevel@tonic-gate# This isn't a valid Pod::Man option and is only accepted for backwards
83*0Sstevel@tonic-gate# compatibility.
84*0Sstevel@tonic-gatedelete $options{lax};
85*0Sstevel@tonic-gate
86*0Sstevel@tonic-gate# Initialize and run the formatter, pulling a pair of input and output off at
87*0Sstevel@tonic-gate# a time.
88*0Sstevel@tonic-gatemy $parser = Pod::Man->new (%options);
89*0Sstevel@tonic-gatemy @files;
90*0Sstevel@tonic-gatedo {
91*0Sstevel@tonic-gate    @files = splice (@ARGV, 0, 2);
92*0Sstevel@tonic-gate    print "  $files[1]\n" if $verbose;
93*0Sstevel@tonic-gate    $parser->parse_from_file (@files);
94*0Sstevel@tonic-gate} while (@ARGV);
95*0Sstevel@tonic-gate
96*0Sstevel@tonic-gate__END__
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gate=head1 NAME
99*0Sstevel@tonic-gate
100*0Sstevel@tonic-gatepod2man - Convert POD data to formatted *roff input
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gate=head1 SYNOPSIS
103*0Sstevel@tonic-gate
104*0Sstevel@tonic-gatepod2man [B<--section>=I<manext>] [B<--release>=I<version>]
105*0Sstevel@tonic-gate[B<--center>=I<string>] [B<--date>=I<string>] [B<--fixed>=I<font>]
106*0Sstevel@tonic-gate[B<--fixedbold>=I<font>] [B<--fixeditalic>=I<font>]
107*0Sstevel@tonic-gate[B<--fixedbolditalic>=I<font>] [B<--name>=I<name>] [B<--official>]
108*0Sstevel@tonic-gate[B<--lax>] [B<--quotes>=I<quotes>] [B<--verbose>]
109*0Sstevel@tonic-gate[I<input> [I<output>] ...]
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gatepod2man B<--help>
112*0Sstevel@tonic-gate
113*0Sstevel@tonic-gate=head1 DESCRIPTION
114*0Sstevel@tonic-gate
115*0Sstevel@tonic-gateB<pod2man> is a front-end for Pod::Man, using it to generate *roff input
116*0Sstevel@tonic-gatefrom POD source.  The resulting *roff code is suitable for display on a
117*0Sstevel@tonic-gateterminal using nroff(1), normally via man(1), or printing using troff(1).
118*0Sstevel@tonic-gate
119*0Sstevel@tonic-gateI<input> is the file to read for POD source (the POD can be embedded in
120*0Sstevel@tonic-gatecode).  If I<input> isn't given, it defaults to STDIN.  I<output>, if given,
121*0Sstevel@tonic-gateis the file to which to write the formatted output.  If I<output> isn't
122*0Sstevel@tonic-gategiven, the formatted output is written to STDOUT.  Several POD files can be
123*0Sstevel@tonic-gateprocessed in the same B<pod2man> invocation (saving module load and compile
124*0Sstevel@tonic-gatetimes) by providing multiple pairs of I<input> and I<output> files on the
125*0Sstevel@tonic-gatecommand line.
126*0Sstevel@tonic-gate
127*0Sstevel@tonic-gateB<--section>, B<--release>, B<--center>, B<--date>, and B<--official> can be
128*0Sstevel@tonic-gateused to set the headers and footers to use; if not given, Pod::Man will
129*0Sstevel@tonic-gateassume various defaults.  See below or L<Pod::Man> for details.
130*0Sstevel@tonic-gate
131*0Sstevel@tonic-gateB<pod2man> assumes that your *roff formatters have a fixed-width font named
132*0Sstevel@tonic-gateCW.  If yours is called something else (like CR), use B<--fixed> to specify
133*0Sstevel@tonic-gateit.  This generally only matters for troff output for printing.  Similarly,
134*0Sstevel@tonic-gateyou can set the fonts used for bold, italic, and bold italic fixed-width
135*0Sstevel@tonic-gateoutput.
136*0Sstevel@tonic-gate
137*0Sstevel@tonic-gateBesides the obvious pod conversions, Pod::Man, and therefore pod2man also
138*0Sstevel@tonic-gatetakes care of formatting func(), func(n), and simple variable references
139*0Sstevel@tonic-gatelike $foo or @bar so you don't have to use code escapes for them; complex
140*0Sstevel@tonic-gateexpressions like C<$fred{'stuff'}> will still need to be escaped, though.
141*0Sstevel@tonic-gateIt also translates dashes that aren't used as hyphens into en dashes, makes
142*0Sstevel@tonic-gatelong dashes--like this--into proper em dashes, fixes "paired quotes," and
143*0Sstevel@tonic-gatetakes care of several other troff-specific tweaks.  See L<Pod::Man> for
144*0Sstevel@tonic-gatecomplete information.
145*0Sstevel@tonic-gate
146*0Sstevel@tonic-gate=head1 OPTIONS
147*0Sstevel@tonic-gate
148*0Sstevel@tonic-gate=over 4
149*0Sstevel@tonic-gate
150*0Sstevel@tonic-gate=item B<-c> I<string>, B<--center>=I<string>
151*0Sstevel@tonic-gate
152*0Sstevel@tonic-gateSets the centered page header to I<string>.  The default is "User
153*0Sstevel@tonic-gateContributed Perl Documentation", but also see B<--official> below.
154*0Sstevel@tonic-gate
155*0Sstevel@tonic-gate=item B<-d> I<string>, B<--date>=I<string>
156*0Sstevel@tonic-gate
157*0Sstevel@tonic-gateSet the left-hand footer string to this value.  By default, the modification
158*0Sstevel@tonic-gatedate of the input file will be used, or the current date if input comes from
159*0Sstevel@tonic-gateSTDIN.
160*0Sstevel@tonic-gate
161*0Sstevel@tonic-gate=item B<--fixed>=I<font>
162*0Sstevel@tonic-gate
163*0Sstevel@tonic-gateThe fixed-width font to use for vertabim text and code.  Defaults to CW.
164*0Sstevel@tonic-gateSome systems may want CR instead.  Only matters for troff(1) output.
165*0Sstevel@tonic-gate
166*0Sstevel@tonic-gate=item B<--fixedbold>=I<font>
167*0Sstevel@tonic-gate
168*0Sstevel@tonic-gateBold version of the fixed-width font.  Defaults to CB.  Only matters for
169*0Sstevel@tonic-gatetroff(1) output.
170*0Sstevel@tonic-gate
171*0Sstevel@tonic-gate=item B<--fixeditalic>=I<font>
172*0Sstevel@tonic-gate
173*0Sstevel@tonic-gateItalic version of the fixed-width font (actually, something of a misnomer,
174*0Sstevel@tonic-gatesince most fixed-width fonts only have an oblique version, not an italic
175*0Sstevel@tonic-gateversion).  Defaults to CI.  Only matters for troff(1) output.
176*0Sstevel@tonic-gate
177*0Sstevel@tonic-gate=item B<--fixedbolditalic>=I<font>
178*0Sstevel@tonic-gate
179*0Sstevel@tonic-gateBold italic (probably actually oblique) version of the fixed-width font.
180*0Sstevel@tonic-gatePod::Man doesn't assume you have this, and defaults to CB.  Some systems
181*0Sstevel@tonic-gate(such as Solaris) have this font available as CX.  Only matters for troff(1)
182*0Sstevel@tonic-gateoutput.
183*0Sstevel@tonic-gate
184*0Sstevel@tonic-gate=item B<-h>, B<--help>
185*0Sstevel@tonic-gate
186*0Sstevel@tonic-gatePrint out usage information.
187*0Sstevel@tonic-gate
188*0Sstevel@tonic-gate=item B<-l>, B<--lax>
189*0Sstevel@tonic-gate
190*0Sstevel@tonic-gateNo longer used.  B<pod2man> used to check its input for validity as a manual
191*0Sstevel@tonic-gatepage, but this should now be done by L<podchecker(1)> instead.  Accepted for
192*0Sstevel@tonic-gatebackwards compatibility; this option no longer does anything.
193*0Sstevel@tonic-gate
194*0Sstevel@tonic-gate=item B<-n> I<name>, B<--name>=I<name>
195*0Sstevel@tonic-gate
196*0Sstevel@tonic-gateSet the name of the manual page to I<name>.  Without this option, the manual
197*0Sstevel@tonic-gatename is set to the uppercased base name of the file being converted unless
198*0Sstevel@tonic-gatethe manual section is 3, in which case the path is parsed to see if it is a
199*0Sstevel@tonic-gatePerl module path.  If it is, a path like C<.../lib/Pod/Man.pm> is converted
200*0Sstevel@tonic-gateinto a name like C<Pod::Man>.  This option, if given, overrides any
201*0Sstevel@tonic-gateautomatic determination of the name.
202*0Sstevel@tonic-gate
203*0Sstevel@tonic-gateNote that this option is probably not useful when converting multiple POD
204*0Sstevel@tonic-gatefiles at once.  The convention for Unix man pages for commands is for the
205*0Sstevel@tonic-gateman page title to be in all-uppercase even if the command isn't.
206*0Sstevel@tonic-gate
207*0Sstevel@tonic-gate=item B<-o>, B<--official>
208*0Sstevel@tonic-gate
209*0Sstevel@tonic-gateSet the default header to indicate that this page is part of the standard
210*0Sstevel@tonic-gatePerl release, if B<--center> is not also given.
211*0Sstevel@tonic-gate
212*0Sstevel@tonic-gate=item B<-q> I<quotes>, B<--quotes>=I<quotes>
213*0Sstevel@tonic-gate
214*0Sstevel@tonic-gateSets the quote marks used to surround CE<lt>> text to I<quotes>.  If
215*0Sstevel@tonic-gateI<quotes> is a single character, it is used as both the left and right
216*0Sstevel@tonic-gatequote; if I<quotes> is two characters, the first character is used as the
217*0Sstevel@tonic-gateleft quote and the second as the right quoted; and if I<quotes> is four
218*0Sstevel@tonic-gatecharacters, the first two are used as the left quote and the second two as
219*0Sstevel@tonic-gatethe right quote.
220*0Sstevel@tonic-gate
221*0Sstevel@tonic-gateI<quotes> may also be set to the special value C<none>, in which case no
222*0Sstevel@tonic-gatequote marks are added around CE<lt>> text (but the font is still changed for
223*0Sstevel@tonic-gatetroff output).
224*0Sstevel@tonic-gate
225*0Sstevel@tonic-gate=item B<-r>, B<--release>
226*0Sstevel@tonic-gate
227*0Sstevel@tonic-gateSet the centered footer.  By default, this is the version of Perl you run
228*0Sstevel@tonic-gateB<pod2man> under.  Note that some system an macro sets assume that the
229*0Sstevel@tonic-gatecentered footer will be a modification date and will prepend something like
230*0Sstevel@tonic-gate"Last modified: "; if this is the case, you may want to set B<--release> to
231*0Sstevel@tonic-gatethe last modified date and B<--date> to the version number.
232*0Sstevel@tonic-gate
233*0Sstevel@tonic-gate=item B<-s>, B<--section>
234*0Sstevel@tonic-gate
235*0Sstevel@tonic-gateSet the section for the C<.TH> macro.  The standard section numbering
236*0Sstevel@tonic-gateconvention is to use 1 for user commands, 2 for system calls, 3 for
237*0Sstevel@tonic-gatefunctions, 4 for devices, 5 for file formats, 6 for games, 7 for
238*0Sstevel@tonic-gatemiscellaneous information, and 8 for administrator commands.  There is a lot
239*0Sstevel@tonic-gateof variation here, however; some systems (like Solaris) use 4 for file
240*0Sstevel@tonic-gateformats, 5 for miscellaneous information, and 7 for devices.  Still others
241*0Sstevel@tonic-gateuse 1m instead of 8, or some mix of both.  About the only section numbers
242*0Sstevel@tonic-gatethat are reliably consistent are 1, 2, and 3.
243*0Sstevel@tonic-gate
244*0Sstevel@tonic-gateBy default, section 1 will be used unless the file ends in .pm in which case
245*0Sstevel@tonic-gatesection 3 will be selected.
246*0Sstevel@tonic-gate
247*0Sstevel@tonic-gate=item B<-v>, B<--verbose>
248*0Sstevel@tonic-gate
249*0Sstevel@tonic-gatePrint out the name of each output file as it is being generated.
250*0Sstevel@tonic-gate
251*0Sstevel@tonic-gate=back
252*0Sstevel@tonic-gate
253*0Sstevel@tonic-gate=head1 DIAGNOSTICS
254*0Sstevel@tonic-gate
255*0Sstevel@tonic-gateIf B<pod2man> fails with errors, see L<Pod::Man> and L<Pod::Parser> for
256*0Sstevel@tonic-gateinformation about what those errors might mean.
257*0Sstevel@tonic-gate
258*0Sstevel@tonic-gate=head1 EXAMPLES
259*0Sstevel@tonic-gate
260*0Sstevel@tonic-gate    pod2man program > program.1
261*0Sstevel@tonic-gate    pod2man SomeModule.pm /usr/perl/man/man3/SomeModule.3
262*0Sstevel@tonic-gate    pod2man --section=7 note.pod > note.7
263*0Sstevel@tonic-gate
264*0Sstevel@tonic-gateIf you would like to print out a lot of man page continuously, you probably
265*0Sstevel@tonic-gatewant to set the C and D registers to set contiguous page numbering and
266*0Sstevel@tonic-gateeven/odd paging, at least on some versions of man(7).
267*0Sstevel@tonic-gate
268*0Sstevel@tonic-gate    troff -man -rC1 -rD1 perl.1 perldata.1 perlsyn.1 ...
269*0Sstevel@tonic-gate
270*0Sstevel@tonic-gateTo get index entries on stderr, turn on the F register, as in:
271*0Sstevel@tonic-gate
272*0Sstevel@tonic-gate    troff -man -rF1 perl.1
273*0Sstevel@tonic-gate
274*0Sstevel@tonic-gateThe indexing merely outputs messages via C<.tm> for each major page,
275*0Sstevel@tonic-gatesection, subsection, item, and any C<XE<lt>E<gt>> directives.  See
276*0Sstevel@tonic-gateL<Pod::Man> for more details.
277*0Sstevel@tonic-gate
278*0Sstevel@tonic-gate=head1 BUGS
279*0Sstevel@tonic-gate
280*0Sstevel@tonic-gateLots of this documentation is duplicated from L<Pod::Man>.
281*0Sstevel@tonic-gate
282*0Sstevel@tonic-gate=head1 NOTES
283*0Sstevel@tonic-gate
284*0Sstevel@tonic-gateFor those not sure of the proper layout of a man page, here are some notes
285*0Sstevel@tonic-gateon writing a proper man page.
286*0Sstevel@tonic-gate
287*0Sstevel@tonic-gateThe name of the program being documented is conventionally written in bold
288*0Sstevel@tonic-gate(using BE<lt>E<gt>) wherever it occurs, as are all program options.
289*0Sstevel@tonic-gateArguments should be written in italics (IE<lt>E<gt>).  Functions are
290*0Sstevel@tonic-gatetraditionally written in italics; if you write a function as function(),
291*0Sstevel@tonic-gatePod::Man will take care of this for you.  Literal code or commands should
292*0Sstevel@tonic-gatebe in CE<lt>E<gt>.  References to other man pages should be in the form
293*0Sstevel@tonic-gateC<manpage(section)>, and Pod::Man will automatically format those
294*0Sstevel@tonic-gateappropriately.  As an exception, it's traditional not to use this form when
295*0Sstevel@tonic-gatereferring to module documentation; use C<LE<lt>Module::NameE<gt>> instead.
296*0Sstevel@tonic-gate
297*0Sstevel@tonic-gateReferences to other programs or functions are normally in the form of man
298*0Sstevel@tonic-gatepage references so that cross-referencing tools can provide the user with
299*0Sstevel@tonic-gatelinks and the like.  It's possible to overdo this, though, so be careful not
300*0Sstevel@tonic-gateto clutter your documentation with too much markup.
301*0Sstevel@tonic-gate
302*0Sstevel@tonic-gateThe major headers should be set out using a C<=head1> directive, and are
303*0Sstevel@tonic-gatehistorically written in the rather startling ALL UPPER CASE format, although
304*0Sstevel@tonic-gatethis is not mandatory.  Minor headers may be included using C<=head2>, and
305*0Sstevel@tonic-gateare typically in mixed case.
306*0Sstevel@tonic-gate
307*0Sstevel@tonic-gateThe standard sections of a manual page are:
308*0Sstevel@tonic-gate
309*0Sstevel@tonic-gate=over 4
310*0Sstevel@tonic-gate
311*0Sstevel@tonic-gate=item NAME
312*0Sstevel@tonic-gate
313*0Sstevel@tonic-gateMandatory section; should be a comma-separated list of programs or functions
314*0Sstevel@tonic-gatedocumented by this podpage, such as:
315*0Sstevel@tonic-gate
316*0Sstevel@tonic-gate    foo, bar - programs to do something
317*0Sstevel@tonic-gate
318*0Sstevel@tonic-gateManual page indexers are often extremely picky about the format of this
319*0Sstevel@tonic-gatesection, so don't put anything in it except this line.  A single dash, and
320*0Sstevel@tonic-gateonly a single dash, should separate the list of programs or functions from
321*0Sstevel@tonic-gatethe description.  Functions should not be qualified with C<()> or the like.
322*0Sstevel@tonic-gateThe description should ideally fit on a single line, even if a man program
323*0Sstevel@tonic-gatereplaces the dash with a few tabs.
324*0Sstevel@tonic-gate
325*0Sstevel@tonic-gate=item SYNOPSIS
326*0Sstevel@tonic-gate
327*0Sstevel@tonic-gateA short usage summary for programs and functions.  This section is mandatory
328*0Sstevel@tonic-gatefor section 3 pages.
329*0Sstevel@tonic-gate
330*0Sstevel@tonic-gate=item DESCRIPTION
331*0Sstevel@tonic-gate
332*0Sstevel@tonic-gateExtended description and discussion of the program or functions, or the body
333*0Sstevel@tonic-gateof the documentation for man pages that document something else.  If
334*0Sstevel@tonic-gateparticularly long, it's a good idea to break this up into subsections
335*0Sstevel@tonic-gateC<=head2> directives like:
336*0Sstevel@tonic-gate
337*0Sstevel@tonic-gate    =head2 Normal Usage
338*0Sstevel@tonic-gate
339*0Sstevel@tonic-gate    =head2 Advanced Features
340*0Sstevel@tonic-gate
341*0Sstevel@tonic-gate    =head2 Writing Configuration Files
342*0Sstevel@tonic-gate
343*0Sstevel@tonic-gateor whatever is appropriate for your documentation.
344*0Sstevel@tonic-gate
345*0Sstevel@tonic-gate=item OPTIONS
346*0Sstevel@tonic-gate
347*0Sstevel@tonic-gateDetailed description of each of the command-line options taken by the
348*0Sstevel@tonic-gateprogram.  This should be separate from the description for the use of things
349*0Sstevel@tonic-gatelike L<Pod::Usage|Pod::Usage>.  This is normally presented as a list, with
350*0Sstevel@tonic-gateeach option as a separate C<=item>.  The specific option string should be
351*0Sstevel@tonic-gateenclosed in BE<lt>E<gt>.  Any values that the option takes should be
352*0Sstevel@tonic-gateenclosed in IE<lt>E<gt>.  For example, the section for the option
353*0Sstevel@tonic-gateB<--section>=I<manext> would be introduced with:
354*0Sstevel@tonic-gate
355*0Sstevel@tonic-gate    =item B<--section>=I<manext>
356*0Sstevel@tonic-gate
357*0Sstevel@tonic-gateSynonymous options (like both the short and long forms) are separated by a
358*0Sstevel@tonic-gatecomma and a space on the same C<=item> line, or optionally listed as their
359*0Sstevel@tonic-gateown item with a reference to the canonical name.  For example, since
360*0Sstevel@tonic-gateB<--section> can also be written as B<-s>, the above would be:
361*0Sstevel@tonic-gate
362*0Sstevel@tonic-gate    =item B<-s> I<manext>, B<--section>=I<manext>
363*0Sstevel@tonic-gate
364*0Sstevel@tonic-gate(Writing the short option first is arguably easier to read, since the long
365*0Sstevel@tonic-gateoption is long enough to draw the eye to it anyway and the short option can
366*0Sstevel@tonic-gateotherwise get lost in visual noise.)
367*0Sstevel@tonic-gate
368*0Sstevel@tonic-gate=item RETURN VALUE
369*0Sstevel@tonic-gate
370*0Sstevel@tonic-gateWhat the program or function returns, if successful.  This section can be
371*0Sstevel@tonic-gateomitted for programs whose precise exit codes aren't important, provided
372*0Sstevel@tonic-gatethey return 0 on success as is standard.  It should always be present for
373*0Sstevel@tonic-gatefunctions.
374*0Sstevel@tonic-gate
375*0Sstevel@tonic-gate=item ERRORS
376*0Sstevel@tonic-gate
377*0Sstevel@tonic-gateExceptions, error return codes, exit statuses, and errno settings.
378*0Sstevel@tonic-gateTypically used for function documentation; program documentation uses
379*0Sstevel@tonic-gateDIAGNOSTICS instead.  The general rule of thumb is that errors printed to
380*0Sstevel@tonic-gateSTDOUT or STDERR and intended for the end user are documented in DIAGNOSTICS
381*0Sstevel@tonic-gatewhile errors passed internal to the calling program and intended for other
382*0Sstevel@tonic-gateprogrammers are documented in ERRORS.  When documenting a function that sets
383*0Sstevel@tonic-gateerrno, a full list of the possible errno values should be given here.
384*0Sstevel@tonic-gate
385*0Sstevel@tonic-gate=item DIAGNOSTICS
386*0Sstevel@tonic-gate
387*0Sstevel@tonic-gateAll possible messages the program can print out--and what they mean.  You
388*0Sstevel@tonic-gatemay wish to follow the same documentation style as the Perl documentation;
389*0Sstevel@tonic-gatesee perldiag(1) for more details (and look at the POD source as well).
390*0Sstevel@tonic-gate
391*0Sstevel@tonic-gateIf applicable, please include details on what the user should do to correct
392*0Sstevel@tonic-gatethe error; documenting an error as indicating "the input buffer is too
393*0Sstevel@tonic-gatesmall" without telling the user how to increase the size of the input buffer
394*0Sstevel@tonic-gate(or at least telling them that it isn't possible) aren't very useful.
395*0Sstevel@tonic-gate
396*0Sstevel@tonic-gate=item EXAMPLES
397*0Sstevel@tonic-gate
398*0Sstevel@tonic-gateGive some example uses of the program or function.  Don't skimp; users often
399*0Sstevel@tonic-gatefind this the most useful part of the documentation.  The examples are
400*0Sstevel@tonic-gategenerally given as verbatim paragraphs.
401*0Sstevel@tonic-gate
402*0Sstevel@tonic-gateDon't just present an example without explaining what it does.  Adding a
403*0Sstevel@tonic-gateshort paragraph saying what the example will do can increase the value of
404*0Sstevel@tonic-gatethe example immensely.
405*0Sstevel@tonic-gate
406*0Sstevel@tonic-gate=item ENVIRONMENT
407*0Sstevel@tonic-gate
408*0Sstevel@tonic-gateEnvironment variables that the program cares about, normally presented as a
409*0Sstevel@tonic-gatelist using C<=over>, C<=item>, and C<=back>.  For example:
410*0Sstevel@tonic-gate
411*0Sstevel@tonic-gate    =over 6
412*0Sstevel@tonic-gate
413*0Sstevel@tonic-gate    =item HOME
414*0Sstevel@tonic-gate
415*0Sstevel@tonic-gate    Used to determine the user's home directory.  F<.foorc> in this
416*0Sstevel@tonic-gate    directory is read for configuration details, if it exists.
417*0Sstevel@tonic-gate
418*0Sstevel@tonic-gate    =back
419*0Sstevel@tonic-gate
420*0Sstevel@tonic-gateSince environment variables are normally in all uppercase, no additional
421*0Sstevel@tonic-gatespecial formatting is generally needed; they're glaring enough as it is.
422*0Sstevel@tonic-gate
423*0Sstevel@tonic-gate=item FILES
424*0Sstevel@tonic-gate
425*0Sstevel@tonic-gateAll files used by the program or function, normally presented as a list, and
426*0Sstevel@tonic-gatewhat it uses them for.  File names should be enclosed in FE<lt>E<gt>.  It's
427*0Sstevel@tonic-gateparticularly important to document files that will be potentially modified.
428*0Sstevel@tonic-gate
429*0Sstevel@tonic-gate=item CAVEATS
430*0Sstevel@tonic-gate
431*0Sstevel@tonic-gateThings to take special care with, sometimes called WARNINGS.
432*0Sstevel@tonic-gate
433*0Sstevel@tonic-gate=item BUGS
434*0Sstevel@tonic-gate
435*0Sstevel@tonic-gateThings that are broken or just don't work quite right.
436*0Sstevel@tonic-gate
437*0Sstevel@tonic-gate=item RESTRICTIONS
438*0Sstevel@tonic-gate
439*0Sstevel@tonic-gateBugs you don't plan to fix.  :-)
440*0Sstevel@tonic-gate
441*0Sstevel@tonic-gate=item NOTES
442*0Sstevel@tonic-gate
443*0Sstevel@tonic-gateMiscellaneous commentary.
444*0Sstevel@tonic-gate
445*0Sstevel@tonic-gate=item SEE ALSO
446*0Sstevel@tonic-gate
447*0Sstevel@tonic-gateOther man pages to check out, like man(1), man(7), makewhatis(8), or
448*0Sstevel@tonic-gatecatman(8).  Normally a simple list of man pages separated by commas, or a
449*0Sstevel@tonic-gateparagraph giving the name of a reference work.  Man page references, if they
450*0Sstevel@tonic-gateuse the standard C<name(section)> form, don't have to be enclosed in
451*0Sstevel@tonic-gateLE<lt>E<gt> (although it's recommended), but other things in this section
452*0Sstevel@tonic-gateprobably should be when appropriate.
453*0Sstevel@tonic-gate
454*0Sstevel@tonic-gateIf the package has a mailing list, include a URL or subscription
455*0Sstevel@tonic-gateinstructions here.
456*0Sstevel@tonic-gate
457*0Sstevel@tonic-gateIf the package has a web site, include a URL here.
458*0Sstevel@tonic-gate
459*0Sstevel@tonic-gate=item AUTHOR
460*0Sstevel@tonic-gate
461*0Sstevel@tonic-gateWho wrote it (use AUTHORS for multiple people).  Including your current
462*0Sstevel@tonic-gatee-mail address (or some e-mail address to which bug reports should be sent)
463*0Sstevel@tonic-gateso that users have a way of contacting you is a good idea.  Remember that
464*0Sstevel@tonic-gateprogram documentation tends to roam the wild for far longer than you expect
465*0Sstevel@tonic-gateand pick an e-mail address that's likely to last if possible.
466*0Sstevel@tonic-gate
467*0Sstevel@tonic-gate=item COPYRIGHT AND LICENSE
468*0Sstevel@tonic-gate
469*0Sstevel@tonic-gateFor copyright
470*0Sstevel@tonic-gate
471*0Sstevel@tonic-gate    Copyright YEAR(s) by YOUR NAME(s)
472*0Sstevel@tonic-gate
473*0Sstevel@tonic-gate(No, (C) is not needed.  No, "all rights reserved" is not needed.)
474*0Sstevel@tonic-gate
475*0Sstevel@tonic-gateFor licensing the easiest way is to use the same licensing as Perl itself:
476*0Sstevel@tonic-gate
477*0Sstevel@tonic-gate    This library is free software; you may redistribute it and/or modify
478*0Sstevel@tonic-gate    it under the same terms as Perl itself.
479*0Sstevel@tonic-gate
480*0Sstevel@tonic-gateThis makes it easy for people to use your module with Perl.  Note that
481*0Sstevel@tonic-gatethis licensing is neither an endorsement or a requirement, you are of
482*0Sstevel@tonic-gatecourse free to choose any licensing.
483*0Sstevel@tonic-gate
484*0Sstevel@tonic-gate=item HISTORY
485*0Sstevel@tonic-gate
486*0Sstevel@tonic-gatePrograms derived from other sources sometimes have this, or you might keep
487*0Sstevel@tonic-gatea modification log here.  If the log gets overly long or detailed,
488*0Sstevel@tonic-gateconsider maintaining it in a separate file, though.
489*0Sstevel@tonic-gate
490*0Sstevel@tonic-gate=back
491*0Sstevel@tonic-gate
492*0Sstevel@tonic-gateIn addition, some systems use CONFORMING TO to note conformance to relevant
493*0Sstevel@tonic-gatestandards and MT-LEVEL to note safeness for use in threaded programs or
494*0Sstevel@tonic-gatesignal handlers.  These headings are primarily useful when documenting parts
495*0Sstevel@tonic-gateof a C library.  Documentation of object-oriented libraries or modules may
496*0Sstevel@tonic-gateuse CONSTRUCTORS and METHODS sections for detailed documentation of the
497*0Sstevel@tonic-gateparts of the library and save the DESCRIPTION section for an overview; other
498*0Sstevel@tonic-gatelarge modules may use FUNCTIONS for similar reasons.  Some people use
499*0Sstevel@tonic-gateOVERVIEW to summarize the description if it's quite long.
500*0Sstevel@tonic-gate
501*0Sstevel@tonic-gateSection ordering varies, although NAME should I<always> be the first section
502*0Sstevel@tonic-gate(you'll break some man page systems otherwise), and NAME, SYNOPSIS,
503*0Sstevel@tonic-gateDESCRIPTION, and OPTIONS generally always occur first and in that order if
504*0Sstevel@tonic-gatepresent.  In general, SEE ALSO, AUTHOR, and similar material should be left
505*0Sstevel@tonic-gatefor last.  Some systems also move WARNINGS and NOTES to last.  The order
506*0Sstevel@tonic-gategiven above should be reasonable for most purposes.
507*0Sstevel@tonic-gate
508*0Sstevel@tonic-gateFinally, as a general note, try not to use an excessive amount of markup.
509*0Sstevel@tonic-gateAs documented here and in L<Pod::Man>, you can safely leave Perl variables,
510*0Sstevel@tonic-gatefunction names, man page references, and the like unadorned by markup and
511*0Sstevel@tonic-gatethe POD translators will figure it out for you.  This makes it much easier
512*0Sstevel@tonic-gateto later edit the documentation.  Note that many existing translators
513*0Sstevel@tonic-gate(including this one currently) will do the wrong thing with e-mail addresses
514*0Sstevel@tonic-gateor URLs when wrapped in LE<lt>E<gt>, so don't do that.
515*0Sstevel@tonic-gate
516*0Sstevel@tonic-gateFor additional information that may be more accurate for your specific
517*0Sstevel@tonic-gatesystem, see either L<man(5)> or L<man(7)> depending on your system manual
518*0Sstevel@tonic-gatesection numbering conventions.
519*0Sstevel@tonic-gate
520*0Sstevel@tonic-gate=head1 SEE ALSO
521*0Sstevel@tonic-gate
522*0Sstevel@tonic-gateL<Pod::Man>, L<Pod::Parser>, L<man(1)>, L<nroff(1)>, L<podchecker(1)>,
523*0Sstevel@tonic-gateL<troff(1)>, L<man(7)>
524*0Sstevel@tonic-gate
525*0Sstevel@tonic-gateThe man page documenting the an macro set may be L<man(5)> instead of
526*0Sstevel@tonic-gateL<man(7)> on your system.
527*0Sstevel@tonic-gate
528*0Sstevel@tonic-gateThe current version of this script is always available from its web site at
529*0Sstevel@tonic-gateL<http://www.eyrie.org/~eagle/software/podlators/>.  It is also part of the
530*0Sstevel@tonic-gatePerl core distribution as of 5.6.0.
531*0Sstevel@tonic-gate
532*0Sstevel@tonic-gate=head1 AUTHOR
533*0Sstevel@tonic-gate
534*0Sstevel@tonic-gateRuss Allbery <rra@stanford.edu>, based I<very> heavily on the original
535*0Sstevel@tonic-gateB<pod2man> by Larry Wall and Tom Christiansen.  Large portions of this
536*0Sstevel@tonic-gatedocumentation, particularly the sections on the anatomy of a proper man
537*0Sstevel@tonic-gatepage, are taken from the B<pod2man> documentation by Tom.
538*0Sstevel@tonic-gate
539*0Sstevel@tonic-gate=head1 COPYRIGHT AND LICENSE
540*0Sstevel@tonic-gate
541*0Sstevel@tonic-gateCopyright 1999, 2000, 2001 by Russ Allbery <rra@stanford.edu>.
542*0Sstevel@tonic-gate
543*0Sstevel@tonic-gateThis program is free software; you may redistribute it and/or modify it
544*0Sstevel@tonic-gateunder the same terms as Perl itself.
545*0Sstevel@tonic-gate
546*0Sstevel@tonic-gate=cut
547*0Sstevel@tonic-gate!NO!SUBS!
548*0Sstevel@tonic-gate#'# (cperl-mode)
549*0Sstevel@tonic-gate
550*0Sstevel@tonic-gateclose OUT or die "Can't close $file: $!";
551*0Sstevel@tonic-gatechmod 0755, $file or die "Can't reset permissions for $file: $!\n";
552*0Sstevel@tonic-gateexec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
553*0Sstevel@tonic-gatechdir $origdir;
554