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 grep( {-d} glob('/usr/local/share/perl/*')),
70 $include_system_perl_modules ? (
72 grep {-d} glob('/usr/share/perl/*'),
77 =head2 fs_pod2html_from_src output_dir
79 Generate Freeside-themed HTML documentation from a Freeside source tree
81 Will fail, unless run with CWD at the root of the Freesidse source tree
85 sub fs_pod2html_from_src {
88 fs_pod2html_from_dirs(
93 'fs_selfservice/FS-SelfService',
94 $include_system_perl_modules ? (
96 grep {-d} glob('/usr/share/perl/*'),
100 # FS-SelfService is loosely packaged:
101 # perl modules are not stored in lib/FS, scripts not stored in /bin, so
102 # batch_convert() places these .html in the wrong locations
104 # Copy to correct locations, and correct relative links
105 copy( "$html_dir/SelfService.html", "$html_dir/FS/SelfService.html" );
106 mkdir( "$html_dir/FS/SelfService" );
107 copy( "$html_dir/SelfService/XMLRPC.html", "$html_dir/FS/SelfService/XMLRPC.html" );
109 'sed -i "s/href=\"\.\//href=\"\.\.\//g" "'.$html_dir.'/FS/SelfService.html"',
110 'sed -i "s/href=\"\\..\//href=\"\.\.\/\.\.\//g" "'.$html_dir.'/FS/SelfService/XMLRPC.html"',
116 =head2 fs_pod2html output_dir @source_scan_dirs
118 Generate Freeside-themed HTML documentation, scanning the provided directories
122 sub fs_pod2html_from_dirs {
124 or croak 'Please specify an output directory';
126 croak "Directory $html_dir: No write access"
129 my @search_dirs = @_;
131 for my $dir ( @search_dirs ) {
133 croak "Cannot continue - source directory ($dir) not found! ";
137 my $parser = Pod::Simple::HTMLBatch->new;
145 $parser->search_class('Inline::Pod::Simple::Search');
146 $parser->html_render_class('Inline::Pod::Simple::HTML');
147 $parser->contents_page_start(
148 "$html_before_title Freeside Documentation Index $html_after_title"
150 $parser->contents_page_end( $html_footer );
152 $parser->batch_convert( \@search_dirs, $html_dir );
159 Inline::Pod::Simple::Search
163 Subclass of Pod::Simple::Search
165 Enable searching for POD in all files instead of just .pl and .pm
169 package Inline::Pod::Simple::Search;
170 use base 'Pod::Simple::Search';
174 my $self = Pod::Simple::Search->new( @_ );
185 Inline::Pod::Simple::HTML
189 Subclass of Pod::Simple::HTML
191 Customize parsed HTML output
195 # Subclass Pod::Simple::HTML to control HTML output
196 package Inline::Pod::Simple::HTML;
197 use base 'Pod::Simple::HTML';
199 sub html_header_before_title { $html_before_title }
200 sub html_header_after_title { $html_after_title }
201 sub html_footer { $html_footer }