Commits

Shlomi Fish  committed a4e3695

Rudimentary support for building DocBook 5.

Add the --basepath param and made the --output flag optional.

  • Participants
  • Parent commits f09ef72

Comments (0)

Files changed (4)

File modules/App-XML-DocBook-Docmake/Changes

+        - Add support for --basepath
+        - Made the -o flag optional, and excluding it from xsltproc if it's
+        not specified (there are other ways to specify the output with
+        xsltproc and XSLT).
+            - These two changes were intended for adapting docmake to
+            building DocBook 5.
+
 0.0300  Wed Apr 20 09:05:51 IDT 2011
         - Add support for the xhtml-1_1 mode.
         - Add the tag-release.pl script.

File modules/App-XML-DocBook-Docmake/lib/App/XML/DocBook/Docmake.pm

 $VERSION = '0.0300';
 
 __PACKAGE__->mk_accessors(qw(
+    _base_path
+    _has_output
     _input_path
     _make_like
     _mode
     my $verbose = 0;
     my $stylesheet;
     my @in_stringparams;
+    my $base_path;
     my $make_like = 0;
     my ($help, $man);
 
         "v|verbose" => \$verbose,
         "x|stylesheet=s" => \$stylesheet,
         "stringparam=s" => \@in_stringparams,
+        "basepath=s" => \$base_path,
         "make" => \$make_like,
         'help|h' => \$help,
-        'man' => \$man,        
+        'man' => \$man,
     );
 
     if (!$ret)
         }
     }
 
-    $self->_output_path($output_path);
+    $self->_has_output(
+        $self->_output_path($output_path) ? 1 : 0
+    );
+
+    
     $self->_verbose($verbose);
     $self->_stylesheet($stylesheet);
     $self->_xslt_stringparams(\@stringparams);
     $self->_make_like($make_like);
+    $self->_base_path($base_path);
 
     my $mode = shift(@$argv);
 
     {
         @stylesheet_params = ($self->_stylesheet());
     }
+
+    my @base_path_params = ();
+
+    if (defined($self->_base_path()))
+    {
+        @base_path_params =
+        (
+            "--path", 
+            ($self->_base_path() . '/' . $self->_xslt_mode()),
+        );
+    }
  
     return $self->_run_input_output_cmd(
         {
             input => $self->_input_path(),
-            output => $self->_calc_output_param_for_xslt($args),
-            make_output => $self->_calc_make_output_param_for_xslt($args),
+            ($self->_has_output()
+                ? (
+                    output => $self->_calc_output_param_for_xslt($args),
+                    make_output =>
+                        $self->_calc_make_output_param_for_xslt($args),
+                )
+                : ()
+            ),
             template =>
             [
                 "xsltproc",
-                "-o", $self->_output_cmd_comp(),
+                $self->_has_output() ? ("-o", $self->_output_cmd_comp()) : (),
                 (map { ("--stringparam", @$_ ) } @{$self->_xslt_stringparams()}),
+                @base_path_params,
                 @stylesheet_params,
                 $self->_input_cmd_comp(),
             ],

File modules/App-XML-DocBook-Docmake/script/docmake

 
 Use the XSLT stylesheet B<STYLESHEET> for performing XSLT transformations.
 
+=item * --basepath PATH
+
+This is the base path for the DocBook stylesheets. The appropriate XSLT mode
+will be appended to it.
+
 =item * --stringparam KEY=VALUE
 
 Specify the string parameter of B<KEY> as B<VALUE>. Note that as opposed to
-xsltproc B<KEY> and B<VALUE> cannot be as different command line arguments,
-but rather should be on the same one, delimited by an equal sign ("C<=>").
+xsltproc, B<KEY> and B<VALUE> cannot be specified as different command line
+arguments, but rather should be on the same one, delimited by an equal sign ("C<=>").
 
 =item * --make
 

File modules/App-XML-DocBook-Docmake/t/01-use.t

 use strict;
 use warnings;
 
-use Test::More tests => 16;
+use Test::More tests => 18;
 use Test::Trap qw( trap $trap :flow:stderr(systemsafe):stdout(systemsafe):warn );
 
 use App::XML::DocBook::Docmake;
         "Testing xhtml-1_1",
     );
 }
+
+{
+    my $docmake = MyTest::DocmakeAppDebug->new({argv => [
+            "-v",
+            "--stringparam", "root.filename=lib/docbook/5/essays/foss-and-other-beasts-v3/all-in-one.xhtml.temp.xml",
+            "--basepath", "/home/shlomif/Download/unpack/file/docbook/docbook-xsl-ns-snapshot",
+            "--stylesheet", "lib/sgml/shlomif-docbook/xsl-5-stylesheets/shlomif-essays-5-xhtml-onechunk.xsl",
+            "xhtml-1_1",
+            "lib/docbook/5/xml/foss-and-other-beasts-v3.xml",
+            ]});
+
+    # TEST
+    ok ($docmake, "DocBook 5 (with --basepath) was initialized.");
+
+    $docmake->run();
+
+    # TEST
+    is_deeply(MyTest::DocmakeAppDebug->debug_commands(),
+        [
+            [
+                "xsltproc",
+                "--stringparam",
+                    "root.filename",
+                    "lib/docbook/5/essays/foss-and-other-beasts-v3/all-in-one.xhtml.temp.xml",
+                "--path",
+                    "/home/shlomif/Download/unpack/file/docbook/docbook-xsl-ns-snapshot/xhtml-1_1",
+                "lib/sgml/shlomif-docbook/xsl-5-stylesheets/shlomif-essays-5-xhtml-onechunk.xsl", 
+                "lib/docbook/5/xml/foss-and-other-beasts-v3.xml",
+            ]
+        ],
+        "Testing DocBook 5 (with --basepath)",
+    );
+}