Debian Codegraph @

bin/pod2wiki

raw
1 #!/usr/bin/perl -w
2
3 #######################################################################
4 #
5 # pod2wiki - A utility to convert Pod documents to Wiki format.
6 #
7 # Copyright John McNamara, [email protected]
8 #
9 # Documentation after __END__
10 #
11
12 use strict;
13 use Pod::Simple::Wiki;
14 use Getopt::Long;
15 use Pod::Usage;
16
17 my $man = 0;
18 my $help = 0;
19 my $style = 'wiki';
20 my $whine = 1;
21 my $errata = 1;
22 my $complain = 0;
23 my $encoding = '';
24
25 GetOptions(
26 'help|?' => \$help,
27 'man' => \$man,
28 'style=s' => \$style,
29 'whine!' => \$whine,
30 'errata!' => \$errata,
31 'complain!' => \$complain,
32 'encoding=s' => \$encoding,
33 ) or pod2usage(2);
34
35 pod2usage(1) if $help;
36 pod2usage(-verbose => 2) if $man;
37
38
39 # From the Pod::Usage pod:
40 pod2usage() if @ARGV == 0 && -t STDIN;
41
42
43 my $parser = Pod::Simple::Wiki->new($style);
44 $parser->no_whining(not $whine);
45 $parser->no_errata_section(not $errata);
46 $parser->complain_stderr($complain);
47
48 if (defined $ARGV[0]) {
49 open IN, $ARGV[0] or die "Couldn't open $ARGV[0]: $!\n";
50 } else {
51 *IN = *STDIN;
52 }
53
54 if (defined $ARGV[1]) {
55 open OUT, ">$ARGV[1]" or die "Couldn't open $ARGV[1]: $!\n";
56 $parser->output_fh(*OUT);
57 }
58
59 # Encode the output filehandle if required.
60 if ($] >= 5.008 && $encoding) {
61 binmode $parser->{output_fh}, $encoding;
62 }
63
64 $parser->parse_file(*IN);
65
66
67 __END__
68
69 =head1 NAME
70
71 pod2wiki - A utility to convert Pod documents to Wiki format.
72
73 =head1 SYNOPSIS
74
75 pod2wiki [--style --noerrata --help --man] podfile [outfile]
76
77 Options:
78 --style wiki style (defaults to wiki. See --help)
79 --noerrata don't generate a "POD ERRORS" section
80 --help brief help message
81 --man full documentation
82
83
84 =head1 DESCRIPTION
85
86 This program is used for converting Pod text to Wiki text.
87
88 Pod is Perl's I<Plain Old Documentation> format. See C<man perlpod> or C<perldoc perlpod>.
89
90 A Wiki is a user extensible web site. It uses very simple mark-up that is converted to Html. For an introduction to Wikis see: L<http://en.wikipedia.org/wiki/Wiki>
91
92
93 =head1 OPTIONS
94
95 =over 4
96
97 =item B<podfile>
98
99 The input file that contains the Pod file to be converted. It can also be stdin.
100
101 =item B<outfile>
102
103 The converted output file in wiki format. Defaults to stdout if not specified.
104
105 =item B<--style or -s>
106
107 Sets the wiki style of the output. If no C<style> is specified the program defaults to C<wiki>. The available options are:
108
109 =over 4
110
111 =item wiki
112
113 This is the original Wiki format as used on Ward Cunningham's Portland repository of Patterns. See L<http://c2.com/cgi/wiki>.
114
115 =item kwiki
116
117 This is the format as used by Brian Ingerson's Kwiki: L<http://www.kwiki.org>.
118
119 =item usemod
120
121 This is the format used by the Usemod wikis. See: L<http://www.usemod.com/cgi-bin/wiki.pl>.
122
123 =item twiki
124
125 This is the format used by TWiki wikis. See: L<http://twiki.org/>.
126
127 =item tiddlywiki
128
129 This is the format used by the TiddlyWiki. See: L<http://www.tiddlywiki.com/>.
130
131 =item textile
132
133 The Textile markup format as used on GitHub. See: L<http://textile.thresholdstate.com/>.
134
135 =item wikipedia or mediawiki
136
137 This is the format used by Wikipedia and MediaWiki wikis. See: L<http://www.mediawiki.org/>.
138
139 =item markdown
140
141 This is the format used by GitHub and other sites. See: L<http://daringfireball.net/projects/markdown/syntax>.
142
143 =item moinmoin
144
145 This is the format used by MoinMoin wikis. See: L<http://moinmo.in/MoinMoinWiki>.
146
147 =item muse
148
149 Emacs Muse (also known as "Muse" or "Emacs-Muse") is an authoring and publishing environment for Emacs.
150
151 =item confluence
152
153 This is the format used by Confluence. See: L<http://www.atlassian.com/software/confluence/>.
154
155 =back
156
157
158 =item B<--encoding>
159
160 Specify the encoding for the output filehandle:
161
162 --encoding=":utf8"
163
164 Refer to C<binmode> in L<perlfunc> for more details. This option is only available in Perl 5.8 and later.
165
166 =item B<--noerrata or -noe>
167
168 Don't generate a "POD ERRORS" section at the end of the document. Equivalent to the C<Pod::Simple::no_errata_section()> method.
169
170
171 =item B<--help or -h>
172
173 Print a brief help message and exits.
174
175
176 =item B<--man or -m>
177
178 Prints the manual page and exits.
179
180 =back
181
182
183 =head1 DISCLAIMER OF WARRANTY
184
185 Please refer to the DISCLAIMER OF WARRANTY in L<Pod::Simple::Wiki>.
186
187
188 =head1 AUTHOR
189
190 John McNamara [email protected]
191
192
193 =head1 COPYRIGHT
194
195 (c) MMIII-MMX1V John McNamara.
196
197 All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
198
199 =cut