Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71013 - in branches/quickbook-dev/tools/quickbook: src test/doc-info test/include
From: dnljms_at_[hidden]
Date: 2011-04-05 16:03:20


Author: danieljames
Date: 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
New Revision: 71013
URL: http://svn.boost.org/trac/boost/changeset/71013

Log:
Quickbook: In 1.6, override document id with id from include element.
Added:
   branches/quickbook-dev/tools/quickbook/test/include/include-id-1.5.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include-id-1.5.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include-id-1.6.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include-id-1.6.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include-id-inc1.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include-id-inc2.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include-id-inc3.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 8 ++------
   branches/quickbook-dev/tools/quickbook/src/actions.hpp | 4 ++--
   branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp | 32 +++++++++++++++++++++-----------
   branches/quickbook-dev/tools/quickbook/src/quickbook.cpp | 5 +++--
   branches/quickbook-dev/tools/quickbook/src/quickbook.hpp | 6 ++++--
   branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-1.6.gold | 9 ++++++---
   branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 | 2 ++
   7 files changed, 40 insertions(+), 26 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -1806,17 +1806,13 @@
             // remain bug compatible with old versions of quickbook
             if(qbk_version_n < 106) actions.doc_id.clear();
 
- // if an id is specified in this include (as in [include:id foo.qbk])
- // then use it as the doc_id.
- if (!include_doc_id.empty())
- actions.doc_id = include_doc_id.get_quickbook();
-
             // update the __FILENAME__ macro
             *boost::spirit::classic::find(actions.macro, "__FILENAME__")
                 = detail::path_to_generic(actions.filename_relative);
         
             // parse the file
- quickbook::parse_file(actions.filename, actions, true);
+ quickbook::parse_file(actions.filename, actions,
+ include_doc_id, true);
 
             // Don't restore source_mode on older versions.
             if (keep_inner_source_mode) state.source_mode = actions.source_mode;

Modified: branches/quickbook-dev/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.hpp 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -345,8 +345,8 @@
         docinfo_nested = 2
     };
 
- void pre(collector& out, quickbook::actions& actions, docinfo_types = docinfo_main);
- void post(collector& out, quickbook::actions& actions, docinfo_types = docinfo_main);
+ void pre(collector& out, quickbook::actions& actions, value include_doc_id, docinfo_types);
+ void post(collector& out, quickbook::actions& actions, docinfo_types);
 
     struct phrase_to_docinfo_action_impl
     {

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -68,7 +68,8 @@
         return values;
     }
 
- void pre(collector& out, quickbook::actions& actions, docinfo_types docinfo_type)
+ void pre(collector& out, quickbook::actions& actions,
+ value include_doc_id, docinfo_types docinfo_type)
     {
         // The doc_info in the file has been parsed. Here's what we'll do
         // *before* anything else.
@@ -126,18 +127,27 @@
                 ;
         }
 
- if (!id.empty())
- actions.doc_id = id.get_quickbook();
-
- // This is only meant to kick in for the main document (since in
- // included documents, the id should already be set), but due to a
- // bug in old versions the document id is reset when including files.
-
- if (actions.doc_id.empty())
+ // Note: this is the version number of the parent document.
+ if (qbk_version_n >= 106)
         {
- assert(qbk_version_n < 106 || docinfo_type == docinfo_main);
- actions.doc_id = detail::make_identifier(actions.doc_title_qbk);
+ if (!include_doc_id.empty())
+ actions.doc_id = include_doc_id.get_quickbook();
+ else if (!id.empty())
+ actions.doc_id = id.get_quickbook();
+ else if (docinfo_type)
+ actions.doc_id = detail::make_identifier(actions.doc_title_qbk);
         }
+ else
+ {
+ if (!id.empty())
+ actions.doc_id = id.get_quickbook();
+ else if (!include_doc_id.empty())
+ actions.doc_id = include_doc_id.get_quickbook();
+ else
+ actions.doc_id = detail::make_identifier(actions.doc_title_qbk);
+ }
+
+ assert(!actions.doc_id.empty());
 
         // if we're ignoring the document info, we're done.
 

Modified: branches/quickbook-dev/tools/quickbook/src/quickbook.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/quickbook.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/quickbook.cpp 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -69,7 +69,8 @@
     // Parse a file
     //
     ///////////////////////////////////////////////////////////////////////////
- int parse_file(fs::path const& filein_, actions& actor, bool nested_file)
+ void parse_file(fs::path const& filein_, actions& actor,
+ value include_doc_id, bool nested_file)
     {
         using std::vector;
         using std::string;
@@ -98,7 +99,7 @@
 
         if (info.hit || !docinfo_type)
         {
- pre(actor.out, actor, docinfo_type);
+ pre(actor.out, actor, include_doc_id, docinfo_type);
 
             info = cl::parse(info.hit ? info.stop : first, last, actor.grammar().block);
             if (info.full)

Modified: branches/quickbook-dev/tools/quickbook/src/quickbook.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/quickbook.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/quickbook.hpp 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -17,6 +17,7 @@
 #include <string>
 #include <boost/filesystem/v3/path.hpp>
 #include "fwd.hpp"
+#include "values.hpp"
 
 namespace quickbook
 {
@@ -28,8 +29,9 @@
     extern std::vector<fs::path> include_path;
     extern std::vector<std::string> preset_defines;
 
- int parse_file(fs::path const& filein_, actions& actor,
- bool nested_file = false);
+ void parse_file(fs::path const& filein_, actions& actor,
+ value include_doc_id = value(),
+ bool nested_file = false);
     
     // Some initialisation methods
     //

Modified: branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-1.6.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-1.6.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-1.6.gold 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -18,7 +18,8 @@
     
 <programlisting>This shouldn't be highlighted.</programlisting>
   </para>
- <article id="c___test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <article id="c___source_mode_include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
     <title>C++ source mode include</title>
     <para>
       
@@ -29,7 +30,8 @@
     
 <programlisting>This shouldn't be highlighted.</programlisting>
   </para>
- <article id="c___test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <article id="python_source_mode_include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
     <title>Python source mode include</title>
     <para>
       
@@ -40,7 +42,8 @@
     
 <programlisting>This shouldn't be highlighted.</programlisting>
   </para>
- <article id="c___test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <article id="teletype_source_mode_include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
     <title>Teletype source mode include</title>
     <para>
       

Modified: branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -26,6 +26,8 @@
     [ quickbook-test macros-1.6 ]
     [ quickbook-test code-import ]
     [ quickbook-test code-include ]
+ [ quickbook-test include-id-1.5 ]
+ [ quickbook-test include-id-1.6 ]
     [ quickbook-error-test section-fail1 ]
     [ quickbook-error-test section-fail2 ]
     ;

Added: branches/quickbook-dev/tools/quickbook/test/include/include-id-1.5.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include-id-1.5.gold 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="include_id_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include Id Test</title> <anchor id="a.simple_include"/>
+ <bridgehead renderas="sect2" id="a.simple_include-heading">
+ <link linkend="a.simple_include">Simple include</link>
+ </bridgehead>
+ <anchor id="b.simple_include"/>
+ <bridgehead renderas="sect2" id="b.simple_include-heading">
+ <link linkend="b.simple_include">Simple include</link>
+ </bridgehead>
+ <anchor id="c.title__no_id"/>
+ <bridgehead renderas="sect2" id="c.title__no_id-heading">
+ <link linkend="c.title__no_id">Title, no id</link>
+ </bridgehead>
+ <anchor id="d.title__no_id"/>
+ <bridgehead renderas="sect2" id="d.title__no_id-heading">
+ <link linkend="d.title__no_id">Title, no id</link>
+ </bridgehead>
+ <anchor id="with-id.title_with_id"/>
+ <bridgehead renderas="sect2" id="with-id.title_with_id-heading">
+ <link linkend="with-id.title_with_id">Title with id</link>
+ </bridgehead>
+ <anchor id="with-id.title_with_id"/>
+ <bridgehead renderas="sect2" id="with-id.title_with_id-heading">
+ <link linkend="with-id.title_with_id">Title with id</link>
+ </bridgehead>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/include/include-id-1.5.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include-id-1.5.quickbook 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -0,0 +1,10 @@
+[article Include Id Test
+[quickbook 1.5]
+]
+
+[include:a include-id-inc1.quickbook]
+[include:b include-id-inc1.quickbook]
+[include:c include-id-inc2.quickbook]
+[include:d include-id-inc2.quickbook]
+[include:e include-id-inc3.quickbook]
+[include:f include-id-inc3.quickbook]

Added: branches/quickbook-dev/tools/quickbook/test/include/include-id-1.6.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include-id-1.6.gold 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="include_id_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include Id Test</title> <anchor id="a.simple_include"/>
+ <bridgehead renderas="sect2" id="a.simple_include-heading">
+ <link linkend="a.simple_include">Simple include</link>
+ </bridgehead>
+ <anchor id="b.simple_include"/>
+ <bridgehead renderas="sect2" id="b.simple_include-heading">
+ <link linkend="b.simple_include">Simple include</link>
+ </bridgehead>
+ <article id="c" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include without id</title> <anchor id="c.title__no_id"/>
+ <bridgehead renderas="sect2" id="c.title__no_id-heading">
+ <link linkend="c.title__no_id">Title, no id</link>
+ </bridgehead>
+ </article>
+ <article id="d" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include without id</title> <anchor id="d.title__no_id"/>
+ <bridgehead renderas="sect2" id="d.title__no_id-heading">
+ <link linkend="d.title__no_id">Title, no id</link>
+ </bridgehead>
+ </article>
+ <article id="e" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include with id</title> <anchor id="e.title_with_id"/>
+ <bridgehead renderas="sect2" id="e.title_with_id-heading">
+ <link linkend="e.title_with_id">Title with id</link>
+ </bridgehead>
+ </article>
+ <article id="f" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include with id</title> <anchor id="f.title_with_id"/>
+ <bridgehead renderas="sect2" id="f.title_with_id-heading">
+ <link linkend="f.title_with_id">Title with id</link>
+ </bridgehead>
+ </article>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/include/include-id-1.6.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include-id-1.6.quickbook 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -0,0 +1,10 @@
+[article Include Id Test
+[quickbook 1.6]
+]
+
+[include:a include-id-inc1.quickbook]
+[include:b include-id-inc1.quickbook]
+[include:c include-id-inc2.quickbook]
+[include:d include-id-inc2.quickbook]
+[include:e include-id-inc3.quickbook]
+[include:f include-id-inc3.quickbook]

Added: branches/quickbook-dev/tools/quickbook/test/include/include-id-inc1.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include-id-inc1.quickbook 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -0,0 +1 @@
+[heading Simple include]

Added: branches/quickbook-dev/tools/quickbook/test/include/include-id-inc2.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include-id-inc2.quickbook 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -0,0 +1,5 @@
+[article Include without id
+[quickbook 1.5]
+]
+
+[heading Title, no id]

Added: branches/quickbook-dev/tools/quickbook/test/include/include-id-inc3.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include-id-inc3.quickbook 2011-04-05 16:03:18 EDT (Tue, 05 Apr 2011)
@@ -0,0 +1,6 @@
+[article Include with id
+[quickbook 1.5]
+[id with-id]
+]
+
+[heading Title with id]


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