~ubuntu-branches/ubuntu/warty/swish-e/warty

« back to all changes in this revision

Viewing changes to doc/bin/pod2hpp

  • Committer: Bazaar Package Importer
  • Author(s): Ludovic Drolez
  • Date: 2004-03-11 08:41:07 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040311084107-7vp0mu82blq1qjvo
Tags: 2.4.1-3
Oops ! A comment was not removed to disable interactive compilation.
Closes: Bug#237332

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -w
 
2
 
 
3
##########################################
 
4
#                                        #
 
5
##           for documentation          ##
 
6
###               execute:             ###
 
7
####          % perldoc pod2hpp       ####
 
8
###          to get the built-in       ###
 
9
##              docs rendered           ##
 
10
#                                        #
 
11
##########################################
 
12
 
 
13
use strict;
 
14
$|=1;
 
15
 
 
16
# I was told that it doesn't run under perl5.004 mainly because of
 
17
# s/XXX/YYY/ for @foo 5.005-isms. It's about a time you should upgrade
 
18
# to 5.005 :) 5.6 is out!!!
 
19
# require 5.005; 
 
20
 
 
21
# allow to execute this script from any path and not only from the current
 
22
# directory
 
23
#use FindBin qw($Bin);
 
24
#use lib $Bin;
 
25
#use Cwd ();
 
26
#my $orig_dir = Cwd::cwd;
 
27
#chdir $Bin;
 
28
 
 
29
use Carp;
 
30
 
 
31
BEGIN{
 
32
    my $config_file = pop @ARGV;
 
33
    croak ("!!! Target configuration file is missing\n!!! Must specify the configuration file as a last argument\n"), exit
 
34
        unless -e $config_file and -r _;
 
35
    use Pod::HtmlPsPdf::Config ();
 
36
    Pod::HtmlPsPdf::Config::set_config_file($config_file);
 
37
}
 
38
 
 
39
use Getopt::Std;
 
40
 
 
41
use Pod::HtmlPsPdf::RunTime ();
 
42
use Pod::HtmlPsPdf::Book ();
 
43
my $config = Pod::HtmlPsPdf::Config->new();
 
44
 
 
45
######################################
 
46
### Init Command Line Arguments
 
47
######################################
 
48
 
 
49
# set defaults if no options given
 
50
my $verbose        = 0;  # verbose?
 
51
my $podify_items   = 0;  # podify pseudo-pod (s/^* /=item */)
 
52
my $split_html     = 0;  # create the splitted html version
 
53
my $make_tgz       = 0;  # create the rel and bin+src archives?
 
54
my $generate_ps    = 0;  # generate PS file
 
55
my $generate_pdf   = 0;  # generate PDF file
 
56
my $rebuild_all    = 0;  # ignore the timestamp of ../src/.last_modified
 
57
my $print_anchors  = 0;  # print the available anchors
 
58
my $validate_links = 0;  # validate %links_to_check against %valid_anchors
 
59
my $makefile_mode  = 0;  # executed from Makefile (forces rebuild, no
 
60
                         # PS/PDF file, no tgz archive created!)
 
61
my $slides_mode    = 0;
 
62
 
 
63
######################################
 
64
### Process Command Line Arguments
 
65
######################################
 
66
 
 
67
my %opts;
 
68
getopts('hvtpdfalmise', \%opts);
 
69
 
 
70
usage() if $opts{h};
 
71
 
 
72
if (keys %opts) {   # options given
 
73
  $verbose        = $opts{v} || 0;
 
74
  $podify_items   = $opts{i} || 0;
 
75
  $split_html     = $opts{s} || 0;
 
76
  $make_tgz       = $opts{t} || 0;
 
77
  $generate_ps    = $opts{p} || 0;
 
78
  $generate_pdf   = $opts{d} || 0;
 
79
  $rebuild_all    = $opts{f} || 0; # force
 
80
  $print_anchors  = $opts{a} || 0;
 
81
  $validate_links = $opts{l} || 0;
 
82
  $slides_mode    = $opts{e} || 0;
 
83
  $makefile_mode  = $opts{m} || 0;
 
84
}
 
85
 
 
86
if ($makefile_mode) {
 
87
  $verbose        = 1;
 
88
  $make_tgz       = 0;
 
89
  $generate_ps    = 0;
 
90
  $generate_pdf   = 0;
 
91
  $rebuild_all    = 1;
 
92
  $print_anchors  = 0;
 
93
  $validate_links = 0;
 
94
}
 
95
 
 
96
# in the slides mode we turn preprocessing automatically to be on
 
97
if ($slides_mode) {
 
98
  $podify_items = 1;
 
99
}
 
100
 
 
101
  # we need a PS version in order to create a pdf
 
102
$generate_ps = 1 if $generate_pdf;
 
103
 
 
104
  # verify the ability to create PS version
 
105
$generate_ps  = Pod::HtmlPsPdf::RunTime::can_create_ps if $generate_ps;
 
106
 
 
107
  # verify the ability to create PDF version
 
108
$generate_pdf = Pod::HtmlPsPdf::RunTime::can_create_pdf if $generate_pdf;
 
109
 
 
110
  # we cannot create PDF if we cannot generate PS
 
111
$generate_pdf = 0 unless $generate_ps;
 
112
 
 
113
  # if there is no toc_file we cannot produce correct internal links,
 
114
  # therefore we force this option.
 
115
my $toc_file = $config->get_param('toc_file');
 
116
$rebuild_all = 1,
 
117
  print "!!! No $toc_file was found, forcing complete rebuild\n"
 
118
    unless -e $toc_file or $rebuild_all;
 
119
 
 
120
my %options =
 
121
  (
 
122
   verbose        => $verbose,
 
123
   podify_items   => $podify_items,
 
124
   split_html     => $split_html,
 
125
   make_tgz       => $make_tgz,
 
126
   generate_ps    => $generate_ps,
 
127
   generate_pdf   => $generate_pdf,
 
128
   rebuild_all    => $rebuild_all,
 
129
   print_anchors  => $print_anchors,
 
130
   validate_links => $validate_links,
 
131
   makefile_mode  => $makefile_mode,
 
132
   slides_mode    => $slides_mode,
 
133
  );
 
134
 
 
135
# make the runtime options available to other packages
 
136
Pod::HtmlPsPdf::RunTime::set_runtime_options(\%options);
 
137
 
 
138
######################################
 
139
### Create the Book
 
140
######################################
 
141
 
 
142
  # create the book object
 
143
my $book = Pod::HtmlPsPdf::Book->new();
 
144
 
 
145
  # process the source files and convert them into html files write
 
146
  # two copies of the files -- one as normal html using the html
 
147
  # teplates, and the other again in html but using the PS templates,
 
148
  # since generally these don't need TOC and all the other stuff,
 
149
  # html2ps generates this for us automatically.
 
150
$book->create_html_version();
 
151
 
 
152
  # Validate pod's L<> links
 
153
$book->validate_links if $validate_links;
 
154
 
 
155
  # when there are broken links reported by validate_links() we need
 
156
  # to know the correct links as rendered by pod2html converter. This
 
157
  # will print all the available achors.
 
158
$book->print_anchors if $print_anchors;
 
159
 
 
160
  # generate the PS version of the book
 
161
$book->create_ps_version if $generate_ps;
 
162
 
 
163
  # generate the PDF version of the book
 
164
$book->create_pdf_version if $generate_pdf;
 
165
 
 
166
  # generate the Split HTML version of the book
 
167
$book->create_split_html_version if $split_html;
 
168
 
 
169
  # build the dist
 
170
$book->make_tar_gz() if $make_tgz;
 
171
 
 
172
  # do the cleanup chores
 
173
$book->cleanup();
 
174
 
 
175
  # go back to where you have from
 
176
#chdir $orig_dir;
 
177
 
 
178
######################################
 
179
### Subs
 
180
######################################
 
181
 
 
182
##########
 
183
sub usage{
 
184
 
 
185
  print <<USAGE;
 
186
    pod2hpp [options] config_file_location
 
187
 
 
188
Options:
 
189
 
 
190
  -h    this help
 
191
  -v    verbose
 
192
  -i    podify pseudo-pod items (s/^* /=item */)
 
193
  -s    create the splitted html version
 
194
  -t    create tar.gz
 
195
  -p    generate PS file
 
196
  -d    generate PDF file
 
197
  -f    force a complete rebuild
 
198
  -a    print available hypertext anchors
 
199
  -l    do hypertext links validation
 
200
  -e    slides mode (for presentations)
 
201
  -m    executed from Makefile (forces rebuild,
 
202
                                no PS/PDF file,
 
203
                                no tgz archive!)
 
204
 
 
205
USAGE
 
206
 
 
207
  exit;
 
208
 
 
209
} # end of sub usage
 
210
 
 
211
 
 
212
 
 
213
__END__
 
214
 
 
215
=head1 NAME
 
216
 
 
217
pod2hpp - a script that does documentation projects building in HTML, PS and PDF formats
 
218
 
 
219
=head1 SYNOPSIS
 
220
 
 
221
  pod2hpp [options] configuration_file_location
 
222
 
 
223
=head1 DESCRIPTION
 
224
 
 
225
See C<Pod::HtmlPsPdf>
 
226
 
 
227
=head1 AUTHOR
 
228
 
 
229
Stas Bekman <stas@stason.org>
 
230
 
 
231
=head1 COPYRIGHT
 
232
 
 
233
This program is distributed under the Artistic License, like the Perl
 
234
itself.
 
235
 
 
236
=cut
 
237
 
 
238
 
 
239
=cut