1 package FS::Misc::Pod2Html;
7 use Pod::Simple::HTMLBatch;
8 use Pod::Simple::Search;
15 $include_system_perl_modules
19 our $include_system_perl_modules = 1;
29 Generate HTML from POD Documentation
35 use FS::Misc::Pod2Html 'fs_pod2html';
36 fs_pod2html( '/output/directory' );
40 perl -MFS::Misc::Pod2Html -e "FS::Misc::Pod2Html::fs_pod2html('/tmp/pod2html');"
44 our $html_before_title = q{
45 <% include( '/elements/header.html', 'Developer Documentation' ) %>
46 <& /elements/menubar.html,
47 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html',
48 'Complete Index' => $fsurl.'docs/library/index.html',
51 <div style="width: 90%; margin: 1em auto; font-size: .9em; border: solid 1px #666; background-color: #eee; padding: 1em;">
52 <h1 style="margin: .5em; border-bottom: solid 1px #999;">
55 our $html_after_title = q{</h1>};
57 our $html_footer = q{</div><% include ('/elements/footer.html' ) %>};
59 =head2 fs_pod2html output_dir
61 Generates Freeside-themed HTML docuemtnation from installed perl modules
66 fs_pod2html_from_dirs(
68 '/usr/local/share/perl/5.24.1',
70 $include_system_perl_modules ? (
72 '/usr/share/perl/5.24',
73 '/usr/share/perl/5.24.1',
78 =head2 fs_pod2html_from_src output_dir
80 Generate Freeside-themed HTML documentation from a Freeside source tree
82 Will fail, unless run with CWD at the root of the Freesidse source tree
86 sub fs_pod2html_from_src {
89 fs_pod2html_from_dirs(
94 'fs_selfservice/FS-SelfService',
95 # '/usr/local/share/perl/5.24.1',
97 $include_system_perl_modules ? (
99 '/usr/share/perl/5.24',
100 '/usr/share/perl/5.24.1',
104 # FS-SelfService is loosely packaged:
105 # perl modules are not stored in lib/FS, scripts not stored in /bin, so
106 # batch_convert() places these .html in the wrong locations
108 # Copy to correct locations, and correct relative links
109 copy( "$html_dir/SelfService.html", "$html_dir/FS/SelfService.html" );
110 mkdir( "$html_dir/FS/SelfService" );
111 copy( "$html_dir/SelfService/XMLRPC.html", "$html_dir/FS/SelfService/XMLRPC.html" );
113 'sed -i "s/href=\"\.\//href=\"\.\.\//g" "'.$html_dir.'/FS/SelfService.html"',
114 'sed -i "s/href=\"\\..\//href=\"\.\.\/\.\.\//g" "'.$html_dir.'/FS/SelfService/XMLRPC.html"',
120 =head2 fs_pod2html output_dir @source_scan_dirs
122 Generate Freeside-themed HTML documentation, scanning the provided directories
126 sub fs_pod2html_from_dirs {
128 or croak 'Please specify an output directory';
130 croak "Directory $html_dir: No write access"
133 my @search_dirs = @_;
135 for my $dir ( @search_dirs ) {
137 croak "Cannot continue - source directory ($dir) not found! ";
141 my $parser = Pod::Simple::HTMLBatch->new;
149 $parser->search_class('Inline::Pod::Simple::Search');
150 $parser->html_render_class('Inline::Pod::Simple::HTML');
151 $parser->contents_page_start(
152 "$html_before_title Freeside Documentation Index $html_after_title"
154 $parser->contents_page_end( $html_footer );
156 $parser->batch_convert( \@search_dirs, $html_dir );
163 Inline::Pod::Simple::Search
167 Subclass of Pod::Simple::Search
169 Enable searching for POD in all files instead of just .pl and .pm
173 package Inline::Pod::Simple::Search;
174 use base 'Pod::Simple::Search';
178 my $self = Pod::Simple::Search->new( @_ );
189 Inline::Pod::Simple::HTML
193 Subclass of Pod::Simple::HTML
195 Customize parsed HTML output
199 # Subclass Pod::Simple::HTML to control HTML output
200 package Inline::Pod::Simple::HTML;
201 use base 'Pod::Simple::HTML';
203 sub html_header_before_title { $html_before_title }
204 sub html_header_after_title { $html_after_title }
205 sub html_footer { $html_footer }