Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75236 - in branches/quickbook-dev/tools/quickbook: src test/include
From: dnljms_at_[hidden]
Date: 2011-11-01 15:21:38


Author: danieljames
Date: 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
New Revision: 75236
URL: http://svn.boost.org/trac/boost/changeset/75236

Log:
Quickbook: Fix including from inside a section.

It's a bit of a crazy edge case which creates invalid docbook in 1.6.
Added:
   branches/quickbook-dev/tools/quickbook/test/include/in_section-1_5.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/in_section-1_5.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/in_section-1_6.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/in_section-1_6.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/in_section-include1.qbk (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/in_section-include2.qbk (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions_class.cpp | 4 ++--
   branches/quickbook-dev/tools/quickbook/src/actions_class.hpp | 2 +-
   branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp | 9 +++++++--
   branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 | 2 ++
   4 files changed, 12 insertions(+), 5 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.cpp 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -106,6 +106,7 @@
         , filename_relative(a.filename_relative)
         , source_mode(a.source_mode)
         , macro()
+ , min_section_level(a.min_section_level)
     {
         if (scope & scope_macros) macro = a.macro;
         if (scope & scope_templates) a.templates.push();
@@ -132,13 +133,13 @@
         }
         if (scope & scope_templates) a.templates.pop();
         if (scope & scope_macros) a.macro = macro;
+ boost::swap(a.min_section_level, min_section_level);
     }
     
     template_state::template_state(actions& a)
         : file_state(a, file_state::scope_all)
         , template_depth(a.template_depth)
         , section_level(a.section_level)
- , min_section_level(a.min_section_level)
         , section_id(a.section_id)
         , qualified_section_id(a.qualified_section_id)
     {
@@ -148,7 +149,6 @@
     {
         boost::swap(a.template_depth, template_depth);
         boost::swap(a.section_level, section_level);
- boost::swap(a.min_section_level, min_section_level);
         boost::swap(a.section_id, section_id);
         boost::swap(a.qualified_section_id, qualified_section_id);
     }

Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.hpp 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -136,6 +136,7 @@
         fs::path filename_relative;
         std::string source_mode;
         string_symbols macro;
+ int min_section_level;
     private:
         file_state(file_state const&);
         file_state& operator=(file_state const&);
@@ -148,7 +149,6 @@
 
         int template_depth;
         int section_level;
- int min_section_level;
         std::string section_id;
         std::string qualified_section_id;
     };

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-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -167,6 +167,11 @@
         
         assert(doc_title.check() && !actions.doc_type.empty());
 
+ // Save the section level so it can be checked at the end of the
+ // document.
+
+ actions.min_section_level = actions.section_level;
+
         // Quickbook version
 
         int qbk_major_version, qbk_minor_version;
@@ -460,12 +465,12 @@
         assert(!actions.doc_type.empty());
 
         // Close any open sections.
- if (actions.section_level != 0) {
+ if (actions.section_level > actions.min_section_level) {
             detail::outwarn(actions.filename)
                 << "Missing [endsect] detected at end of file."
                 << std::endl;
 
- while(actions.section_level > 0) {
+ while(actions.section_level > actions.min_section_level) {
                 out << "</section>";
                 --actions.section_level;
             }

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-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -31,4 +31,6 @@
     [ quickbook-test include-id-1.6 ]
     [ quickbook-error-test section-fail1 ]
     [ quickbook-error-test section-fail2 ]
+ [ quickbook-test in_section-1_5 ]
+ [ quickbook-test in_section-1_6 ]
     ;

Added: branches/quickbook-dev/tools/quickbook/test/include/in_section-1_5.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/in_section-1_5.gold 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -0,0 +1,66 @@
+<?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_in_section_1_5" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section 1.5</title>
+ <section id="include_in_section_1_5.container">
+ <title><link linkend="include_in_section_1_5.container">Container</link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container.h0">
+ <phrase id="include_in_section_include_1.container.test1"/><link linkend="include_in_section_include_1.container.test1">Test1</link>
+ </bridgehead>
+ <section id="include_in_section_include_1.container.inner">
+ <title><link linkend="include_in_section_include_1.container.inner"></link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container.inner.h0">
+ <phrase id="include_in_section_include_1.container.inner.test2"/><link linkend="include_in_section_include_1.container.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ <bridgehead renderas="sect1" id="section_include.container.h0">
+ <phrase id="section_include.container.test1"/><link linkend="section_include.container.test1">Test1</link>
+ </bridgehead>
+ <section id="section_include.container.inner">
+ <title><link linkend="section_include.container.inner"></link></title>
+ <bridgehead renderas="sect1" id="section_include.container.inner.h0">
+ <phrase id="section_include.container.inner.test2"/><link linkend="section_include.container.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </section>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.h0">
+ <phrase id="include_in_section_include_1.test1"/><link linkend="include_in_section_include_1.test1">Test1</link>
+ </bridgehead>
+ <section id="include_in_section_include_1.inner">
+ <title><link linkend="include_in_section_include_1.inner"></link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.inner.h0">
+ <phrase id="include_in_section_include_1.inner.test2"/><link linkend="include_in_section_include_1.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ <bridgehead renderas="sect1" id="section_include.h0">
+ <phrase id="section_include.test1"/><link linkend="section_include.test1">Test1</link>
+ </bridgehead>
+ <section id="section_include.inner">
+ <title><link linkend="section_include.inner"></link></title>
+ <bridgehead renderas="sect1" id="section_include.inner.h0">
+ <phrase id="section_include.inner.test2"/><link linkend="section_include.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ <section id="include_in_section_1_5.container2">
+ <title><link linkend="include_in_section_1_5.container2">Container2</link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container2.h0">
+ <phrase id="include_in_section_include_1.container2.test1"/><link linkend="include_in_section_include_1.container2.test1">Test1</link>
+ </bridgehead>
+ <section id="include_in_section_include_1.container2.inner">
+ <title><link linkend="include_in_section_include_1.container2.inner"></link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container2.inner.h0">
+ <phrase id="include_in_section_include_1.container2.inner.test2"/><link linkend="include_in_section_include_1.container2.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ <bridgehead renderas="sect1" id="section_include.container2.h0">
+ <phrase id="section_include.container2.test1"/><link linkend="section_include.container2.test1">Test1</link>
+ </bridgehead>
+ <section id="section_include.container2.inner">
+ <title><link linkend="section_include.container2.inner"></link></title>
+ <bridgehead renderas="sect1" id="section_include.container2.inner.h0">
+ <phrase id="section_include.container2.inner.test2"/><link linkend="section_include.container2.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </section>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/include/in_section-1_5.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/in_section-1_5.quickbook 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -0,0 +1,16 @@
+[article Include in section 1.5
+[quickbook 1.5]
+]
+
+[section:container Container]
+[include in_section-include1.qbk]
+[include in_section-include2.qbk]
+[endsect]
+
+[include in_section-include1.qbk]
+[include in_section-include2.qbk]
+
+[section:container2 Container2]
+[include in_section-include1.qbk]
+[include in_section-include2.qbk]
+[endsect]

Added: branches/quickbook-dev/tools/quickbook/test/include/in_section-1_6.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/in_section-1_6.gold 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -0,0 +1,92 @@
+<?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_in_section_1_6" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section 1.6</title>
+ <section id="include_in_section_1_6.container">
+ <title><link linkend="include_in_section_1_6.container">Container</link></title>
+ <article id="include_in_section_include_1" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section include 1</title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container.h0">
+ <phrase id="include_in_section_include_1.container.test1"/><link linkend="include_in_section_include_1.container.test1">Test1</link>
+ </bridgehead>
+ <section id="include_in_section_include_1.container.inner">
+ <title><link linkend="include_in_section_include_1.container.inner"></link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container.inner.h0">
+ <phrase id="include_in_section_include_1.container.inner.test2"/><link
+ linkend="include_in_section_include_1.container.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </article>
+ <article id="section_include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section include 2</title>
+ <bridgehead renderas="sect1" id="section_include.container.h0">
+ <phrase id="section_include.container.test1"/><link linkend="section_include.container.test1">Test1</link>
+ </bridgehead>
+ <section id="section_include.container.inner">
+ <title><link linkend="section_include.container.inner"></link></title>
+ <bridgehead renderas="sect1" id="section_include.container.inner.h0">
+ <phrase id="section_include.container.inner.test2"/><link linkend="section_include.container.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </article>
+ </section>
+ <article id="include_in_section_include_1_0" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section include 1</title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.h0">
+ <phrase id="include_in_section_include_1.test1"/><link linkend="include_in_section_include_1.test1">Test1</link>
+ </bridgehead>
+ <section id="include_in_section_include_1.inner">
+ <title><link linkend="include_in_section_include_1.inner"></link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.inner.h0">
+ <phrase id="include_in_section_include_1.inner.test2"/><link linkend="include_in_section_include_1.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </article>
+ <article id="section_include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section include 2</title>
+ <bridgehead renderas="sect1" id="section_include.h0">
+ <phrase id="section_include.test1"/><link linkend="section_include.test1">Test1</link>
+ </bridgehead>
+ <section id="section_include.inner">
+ <title><link linkend="section_include.inner"></link></title>
+ <bridgehead renderas="sect1" id="section_include.inner.h0">
+ <phrase id="section_include.inner.test2"/><link linkend="section_include.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </article>
+ <section id="include_in_section_1_6.container2">
+ <title><link linkend="include_in_section_1_6.container2">Container2</link></title>
+ <article id="include_in_section_include_1_1" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section include 1</title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container2.h0">
+ <phrase id="include_in_section_include_1.container2.test1"/><link linkend="include_in_section_include_1.container2.test1">Test1</link>
+ </bridgehead>
+ <section id="include_in_section_include_1.container2.inner">
+ <title><link linkend="include_in_section_include_1.container2.inner"></link></title>
+ <bridgehead renderas="sect1" id="include_in_section_include_1.container2.inner.h0">
+ <phrase id="include_in_section_include_1.container2.inner.test2"/><link
+ linkend="include_in_section_include_1.container2.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </article>
+ <article id="section_include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include in section include 2</title>
+ <bridgehead renderas="sect1" id="section_include.container2.h0">
+ <phrase id="section_include.container2.test1"/><link linkend="section_include.container2.test1">Test1</link>
+ </bridgehead>
+ <section id="section_include.container2.inner">
+ <title><link linkend="section_include.container2.inner"></link></title>
+ <bridgehead renderas="sect1" id="section_include.container2.inner.h0">
+ <phrase id="section_include.container2.inner.test2"/><link linkend="section_include.container2.inner.test2">Test2</link>
+ </bridgehead>
+ </section>
+ </article>
+ </section>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/include/in_section-1_6.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/in_section-1_6.quickbook 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -0,0 +1,16 @@
+[article Include in section 1.6
+[quickbook 1.6]
+]
+
+[section:container Container]
+[include in_section-include1.qbk]
+[include in_section-include2.qbk]
+[endsect]
+
+[include in_section-include1.qbk]
+[include in_section-include2.qbk]
+
+[section:container2 Container2]
+[include in_section-include1.qbk]
+[include in_section-include2.qbk]
+[endsect]

Added: branches/quickbook-dev/tools/quickbook/test/include/in_section-include1.qbk
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/in_section-include1.qbk 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -0,0 +1,11 @@
+[article Include in section include 1
+[quickbook 1.6]
+]
+
+[h1 Test1]
+
+[section:inner]
+
+[h1 Test2]
+
+[endsect]
\ No newline at end of file

Added: branches/quickbook-dev/tools/quickbook/test/include/in_section-include2.qbk
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/in_section-include2.qbk 2011-11-01 15:21:36 EDT (Tue, 01 Nov 2011)
@@ -0,0 +1,12 @@
+[article Include in section include 2
+[quickbook 1.6]
+[id section_include]
+]
+
+[h1 Test1]
+
+[section:inner]
+
+[h1 Test2]
+
+[endsect]
\ No newline at end of file


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