Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69181 - in branches/quickbook-filenames/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-02-22 15:47:27


Author: danieljames
Date: 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
New Revision: 69181
URL: http://svn.boost.org/trac/boost/changeset/69181

Log:
Another testing flag to allow testing xinclude.

Not ideal, since not testing normal use. But at least it would have
caught the error fixed in [68308].
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 4 ++--
   branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp | 8 ++++----
   branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp | 4 ++--
   branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp | 29 ++++++++++++++++++++++-------
   branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 | 2 +-
   branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam | 4 +++-
   branches/quickbook-filenames/tools/quickbook/test/xinclude.gold | 2 +-
   7 files changed, 35 insertions(+), 18 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
@@ -1515,8 +1515,8 @@
         {
             fs::path infile = fs::absolute(actions.filename).normalize();
             path = (infile.parent_path() / path).normalize();
- fs::path outdir = fs::absolute(actions.outdir).normalize();
- path = path_difference(outdir, path);
+ fs::path xinclude_base = fs::absolute(actions.xinclude_base).normalize();
+ path = path_difference(xinclude_base, path);
         }
         return path;
     }

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.cpp 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
@@ -20,7 +20,7 @@
 
 namespace quickbook
 {
- actions::actions(fs::path const& filein_, fs::path const& outdir_, string_stream& out_)
+ actions::actions(fs::path const& filein_, fs::path const& xinclude_base_, string_stream& out_)
         : grammar_()
 
     // header info
@@ -45,7 +45,7 @@
 
     // state
         , filename(fs::absolute(filein_))
- , outdir(outdir_)
+ , xinclude_base(xinclude_base_)
         , macro_change_depth(0)
         , macro()
         , section_level(0)
@@ -116,7 +116,7 @@
         state_stack.push(
             boost::make_tuple(
                 filename
- , outdir
+ , xinclude_base
               , macro_change_depth
               , section_level
               , min_section_level
@@ -156,7 +156,7 @@
     
         boost::tie(
             filename
- , outdir
+ , xinclude_base
           , macro_change_depth
           , section_level
           , min_section_level

Modified: branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions_class.hpp 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
@@ -23,7 +23,7 @@
 
     struct actions
     {
- actions(fs::path const& filein_, fs::path const& outdir, string_stream& out_);
+ actions(fs::path const& filein_, fs::path const& xinclude_base, string_stream& out_);
 
     private:
         boost::scoped_ptr<quickbook_grammar> grammar_;
@@ -63,7 +63,7 @@
 
     // state
         fs::path filename;
- fs::path outdir;
+ fs::path xinclude_base;
         std::size_t macro_change_depth;
         string_symbols macro;
         int section_level;

Modified: branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/quickbook.cpp 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
@@ -109,9 +109,10 @@
     }
 
     static int
- parse_document(fs::path const& filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false)
+ parse_document(fs::path const& filein_, fs::path const& xinclude_base,
+ string_stream& out, bool ignore_docinfo = false)
     {
- actions actor(filein_, outdir, out);
+ actions actor(filein_, xinclude_base, out);
 
         set_macros(actor);
         bool r = parse_file(filein_, actor);
@@ -133,16 +134,14 @@
     parse_document(
         fs::path const& filein_
       , fs::path const& fileout_
+ , fs::path const& xinclude_base_
       , int indent
       , int linewidth
       , bool pretty_print)
     {
         int result = 0;
- fs::path outdir = fileout_.parent_path();
- if (outdir.empty())
- outdir = ".";
         string_stream buffer;
- result = parse_document(filein_, outdir, buffer);
+ result = parse_document(filein_, xinclude_base_, buffer);
 
         if (result == 0)
         {
@@ -220,6 +219,9 @@
             ("expect-errors",
                 "Succeed if the input file contains a correctly handled "
                 "error, fail otherwise.")
+ ("xinclude-base", PO_VALUE<input_string>(),
+ "Generate xincludes as if generating for this target "
+ "directory.")
         ;
 
         all.add(desc).add(hidden);
@@ -347,12 +349,25 @@
                 fileout = filein;
                 fileout.replace_extension(".xml");
             }
+
+ fs::path xinclude_base;
+ if (vm.count("xinclude-base"))
+ {
+ xinclude_base = quickbook::detail::input_to_path(
+ vm["xinclude-base"].as<input_string>());
+ }
+ else
+ {
+ xinclude_base = fileout.parent_path();
+ if (xinclude_base.empty())
+ xinclude_base = ".";
+ }
 
             quickbook::detail::out() << "Generating Output File: "
                 << quickbook::detail::path_to_stream(fileout)
                 << std::endl;
 
- int r = quickbook::parse_document(filein, fileout, indent, linewidth, pretty_print);
+ int r = quickbook::parse_document(filein, fileout, xinclude_base, indent, linewidth, pretty_print);
 
             if (expect_errors)
             {

Modified: branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
@@ -36,7 +36,7 @@
     [ quickbook-test mismatched-brackets-1 ]
     [ quickbook-test mismatched-brackets-2 ]
     [ quickbook-error-test mismatched-brackets-3 ]
- #[ quickbook-test xinclude ]
+ [ quickbook-test xinclude : : : <quickbook-xinclude-base>../src ]
     [ quickbook-test import ]
     [ quickbook-test include_1_5 ]
     [ quickbook-test include_1_6 ]

Modified: branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam (original)
+++ branches/quickbook-filenames/tools/quickbook/test/quickbook-testing.jam 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
@@ -17,6 +17,7 @@
 
 feature.feature quickbook-testing.quickbook-command : : free dependency ;
 feature.feature <quickbook-test-define> : : free ;
+feature.feature <quickbook-xinclude-base> : : free ;
 
 type.register QUICKBOOK_INPUT : quickbook ;
 type.register QUICKBOOK_OUTPUT ;
@@ -124,6 +125,7 @@
 ################################################################################
 toolset.flags quickbook-testing.process-quickbook quickbook-command <quickbook-testing.quickbook-command> ;
 toolset.flags quickbook-testing.process-quickbook QB-DEFINES <quickbook-test-define> ;
+toolset.flags quickbook-testing.process-quickbook XINCLUDE <quickbook-xinclude-base> ;
 
 rule process-quickbook ( target : source : properties * )
 {
@@ -132,6 +134,6 @@
 
 actions process-quickbook bind quickbook-command
 {
- $(quickbook-command) $(>) --output-file=$(<) --debug -D"$(QB-DEFINES)" $(OPTIONS)
+ $(quickbook-command) $(>) --output-file=$(<) --debug -D"$(QB-DEFINES)" --xinclude-base=$(XINCLUDE)
 }
 

Modified: branches/quickbook-filenames/tools/quickbook/test/xinclude.gold
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/xinclude.gold (original)
+++ branches/quickbook-filenames/tools/quickbook/test/xinclude.gold 2011-02-22 15:47:15 EST (Tue, 22 Feb 2011)
@@ -2,5 +2,5 @@
 <!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
 <article id="include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
   <title>Include</title>
- <xi:include href="../../../../../../../../../tools/quickbook/test/stub.xml" />
+ <xi:include href="../test/stub.xml" />
 </article>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk