[freeside-commits] branch master updated. f48a1666f8b7b967e202c6e36480209a9656710e

Mitch Jackson mitch at freeside.biz
Tue Feb 19 17:24:27 PST 2019


The branch, master has been updated
       via  f48a1666f8b7b967e202c6e36480209a9656710e (commit)
       via  48e65eb4bd1773dfb7076047df4f366538b81459 (commit)
      from  d5b8de340fed6080ca521844131f78336b491cd9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit f48a1666f8b7b967e202c6e36480209a9656710e
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Tue Feb 19 20:20:43 2019 -0500

    RT# 81961 Pod2Html make docs during build, instead of install

diff --git a/Makefile b/Makefile
index f3bbdc4b9..d815c44ed 100644
--- a/Makefile
+++ b/Makefile
@@ -333,7 +333,7 @@ install-chown:
 install-pod2html:
 	echo "${POD2HTML_DIR}"
 	mkdir -p "${POD2HTML_DIR}"
-	perl -MFS::Misc::Pod2Html -e "FS::Misc::Pod2Html::fs_pod2html('${POD2HTML_DIR}');"
+	perl -IFS -MFS::Misc::Pod2Html -e "FS::Misc::Pod2Html::fs_pod2html_from_src('${POD2HTML_DIR}');"
 	chown freeside:freeside -R "${POD2HTML_DIR}"
 
 install: install-perl-modules install-docs install-init install-apache install-rt install-torrus install-texmf install-chown install-pod2html
diff --git a/debian/freeside-lib.postinst b/debian/freeside-lib.postinst
index 0692f8910..dbc3a7590 100644
--- a/debian/freeside-lib.postinst
+++ b/debian/freeside-lib.postinst
@@ -3,19 +3,4 @@
 # Rebuild ls-R filename databases used by TeX
 texhash /usr/local/share/texmf
 
-# Generate HTML documentation from perl POD
-if [ -z "$APACHE_VERSION" ]; then
-  export APACHE_VERSION=`/usr/sbin/apache2 -v | grep -q '\/2\.4\.' && echo '2.4' || echo '2'`
-fi
-
-if [ -z "$APACHE_DOCUMENT_ROOT" ]; then
-  export APACHE_DOCUMENT_ROOT=`[ ${APACHE_VERSION} = '2.4' ] && echo '/var/www/html' || echo '/var/www'`
-fi
-
-export POD2HTML_DOCUMENT_ROOT="${APACHE_DOCUMENT_ROOT}/freeside/docs/library"
-
-mkdir -p "$POD2HTML_DOCUMENT_ROOT"
-perl -MFS::Misc::Pod2Html -e "FS::Misc::Pod2Html::fs_pod2html('$POD2HTML_DOCUMENT_ROOT');"
-chown -R freeside "$POD2HTML_DOCUMENT_ROOT"
-
 exit 0
diff --git a/debian/rules b/debian/rules
index 041c895a4..153f17751 100755
--- a/debian/rules
+++ b/debian/rules
@@ -49,6 +49,7 @@ export MASON_HANDLER=$(TMP)-webui/usr/local/etc/freeside/handler.pl
 export APACHE_VERSION        := $(shell /usr/sbin/apache2 -v | grep -q '\/2\.4\.' && echo '2.4' || echo '2')
 export APACHE_DOCUMENT_ROOT  := $(shell [ ${APACHE_VERSION} = '2.4' ] && echo '/var/www/html' || echo '/var/www')
 export FREESIDE_DOCUMENT_ROOT = $(TMP)-webui$(APACHE_DOCUMENT_ROOT)/freeside
+export POD2HTML_DOCUMENT_ROOT = $(FREESIDE_DOCUMENT_ROOT)/docs/library
 export INIT_FILE              = $(TMP).init
 export INIT_INSTALL           = /bin/true
 export HTTPD_RESTART          = /bin/true
@@ -287,6 +288,10 @@ install-stamp: build-stamp
 		s'%%%FREESIDE_URL%%%'${FREESIDE_URL}'g;\
 		" ${RT_PATH}/etc/RT_SiteConfig.pm
 
+	# Build pod2html documentation
+	install -d ${POD2HTML_DOCUMENT_ROOT}
+	perl -IFS -MFS::Misc::Pod2Html -e "FS::Misc::Pod2Html::fs_pod2html_from_src('${POD2HTML_DOCUMENT_ROOT}');"
+
 	dh_install
 
 	#touch $@

commit 48e65eb4bd1773dfb7076047df4f366538b81459
Author: Mitch Jackson <mitch at freeside.biz>
Date:   Tue Feb 19 20:17:29 2019 -0500

    RT# 81961 Pod2Html can use installed libs, or Freeside source

diff --git a/FS/FS/Misc/Pod2Html.pm b/FS/FS/Misc/Pod2Html.pm
index 08358aa77..1dfca048c 100644
--- a/FS/FS/Misc/Pod2Html.pm
+++ b/FS/FS/Misc/Pod2Html.pm
@@ -2,6 +2,7 @@ package FS::Misc::Pod2Html;
 use strict;
 use warnings;
 use Carp qw( croak );
+use File::Copy;
 use Pod::Simple::HTML;
 use Pod::Simple::HTMLBatch;
 use Pod::Simple::Search;
@@ -9,12 +10,15 @@ use Pod::Simple::Search;
 use base 'Exporter';
 our @EXPORT_OK = qw(
   fs_pod2html
+  fs_pod2html_from_src
+  fs_pod2html_from_dirs
   $include_system_perl_modules
   $quiet_mode
 );
 
 our $include_system_perl_modules = 1;
 our $quiet_mode = 0;
+our $DEBUG = 0;
 
 =head1 NAME
 
@@ -31,9 +35,9 @@ Usage:
   use FS::Misc::Pod2Html 'fs_pod2html';
   fs_pod2html( '/output/directory' );
 
-=head2 fs_pod2html /output/directory/
+Also:
 
-Generates Freeside-themed HTML docuemtnation from installed perl modules
+  perl -MFS::Misc::Pod2Html -e "FS::Misc::Pod2Html::fs_pod2html('/tmp/pod2html');"
 
 =cut
 
@@ -52,14 +56,15 @@ our $html_after_title = q{</h1>};
 
 our $html_footer = q{</div><% include ('/elements/footer.html' ) %>};
 
-sub fs_pod2html {
-  my $html_dir = shift
-    or croak 'Please specify an output directory';
+=head2 fs_pod2html output_dir
 
-  croak "Directory $html_dir: No write access"
-    unless -w $html_dir;
+Generates Freeside-themed HTML docuemtnation from installed perl modules
 
-  my @search_dirs = (
+=cut
+
+sub fs_pod2html {
+  fs_pod2html_from_dirs(
+    shift,
     '/usr/local/share/perl/5.24.1',
     '/usr/local/bin',
     $include_system_perl_modules ? (
@@ -68,12 +73,79 @@ sub fs_pod2html {
       '/usr/share/perl/5.24.1',
     ) : (),
   );
+}
+
+=head2 fs_pod2html_from_src output_dir
+
+Generate Freeside-themed HTML documentation from a Freeside source tree
+
+Will fail, unless run with CWD at the root of the Freesidse source tree
+
+=cut
+
+sub fs_pod2html_from_src {
+  my $html_dir = shift;
+
+  fs_pod2html_from_dirs(
+    $html_dir,
+    'FS/bin',
+    'bin',
+    'FS',
+    'fs_selfservice/FS-SelfService',
+    # '/usr/local/share/perl/5.24.1',
+    # '/usr/local/bin',
+    $include_system_perl_modules ? (
+      '/usr/share/perl5',
+      '/usr/share/perl/5.24',
+      '/usr/share/perl/5.24.1',
+    ) : (),
+  );
+
+  # FS-SelfService is loosely packaged:
+  #   perl modules are not stored in lib/FS, scripts not stored in /bin, so
+  # batch_convert() places these .html in the wrong locations
+  #
+  # Copy to correct locations, and correct relative links
+  copy( "$html_dir/SelfService.html", "$html_dir/FS/SelfService.html" );
+  mkdir( "$html_dir/FS/SelfService" );
+  copy( "$html_dir/SelfService/XMLRPC.html", "$html_dir/FS/SelfService/XMLRPC.html" );
+    for my $sed_cmd (
+    'sed -i "s/href=\"\.\//href=\"\.\.\//g" "'.$html_dir.'/FS/SelfService.html"',
+    'sed -i "s/href=\"\\..\//href=\"\.\.\/\.\.\//g" "'.$html_dir.'/FS/SelfService/XMLRPC.html"',
+  ) {
+    `$sed_cmd`
+  }
+}
+
+=head2 fs_pod2html output_dir @source_scan_dirs
+
+Generate Freeside-themed HTML documentation, scanning the provided directories
+
+=cut
+
+sub fs_pod2html_from_dirs {
+  my $html_dir = shift
+    or croak 'Please specify an output directory';
+
+  croak "Directory $html_dir: No write access"
+    unless -w $html_dir;
+
+  my @search_dirs = @_;
+
+  for my $dir ( @search_dirs ) {
+    unless ( -d $dir ) {
+      croak "Cannot continue - source directory ($dir) not found! ";
+    }
+  }
 
   my $parser = Pod::Simple::HTMLBatch->new;
 
   $parser->verbose(0)
     if $quiet_mode;
 
+  $parser->verbose(2)
+    if $DEBUG;
+
   $parser->search_class('Inline::Pod::Simple::Search');
   $parser->html_render_class('Inline::Pod::Simple::HTML');
   $parser->contents_page_start(
@@ -105,8 +177,11 @@ sub new {
   my $class = shift;
   my $self = Pod::Simple::Search->new( @_ );
   $self->laborious(1);
+  $self->verbose(2)
+    if $DEBUG;
   $self;
 }
+
 1;
 
 =head1 NAME

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Misc/Pod2Html.pm       | 91 ++++++++++++++++++++++++++++++++++++++++----
 Makefile                     |  2 +-
 debian/freeside-lib.postinst | 15 --------
 debian/rules                 |  5 +++
 4 files changed, 89 insertions(+), 24 deletions(-)




More information about the freeside-commits mailing list