Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75528 - in branches/quickbook-dev/tools/quickbook: src test/doc-info test/include
From: dnljms_at_[hidden]
Date: 2011-11-17 16:04:04


Author: danieljames
Date: 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
New Revision: 75528
URL: http://svn.boost.org/trac/boost/changeset/75528

Log:
Quickbook: Make source mode a document attribute and fix implementation.

In quickbook 1.6, nested documents default to C++, regardless of the
parent's source mode so that they are interpreted as if they are
standalone documents.
Added:
   branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_5.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_5.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_6.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_6.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/source_mode-inc1.qbk (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp | 5 +----
   branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp | 31 +++++++++++++++++++------------
   branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp | 3 +--
   branches/quickbook-dev/tools/quickbook/src/quickbook.cpp | 11 -----------
   branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-cpp-include.quickbook | 3 +--
   branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 | 2 ++
   6 files changed, 24 insertions(+), 31 deletions(-)

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-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -151,6 +151,7 @@
 
         value qbk_version = consume_list(values, doc_attributes::qbk_version, &duplicates);
         value compatibility_mode = consume_list(values, doc_attributes::compatibility_mode, &duplicates);
+ consume_multiple_lists(values, doc_attributes::source_mode);
 
         value id = consume_value_in_list(values, doc_info_attributes::id, &duplicates);
         value dirname = consume_value_in_list(values, doc_info_attributes::dirname, &duplicates);
@@ -164,10 +165,6 @@
         value license = consume_value_in_list(values, doc_info_attributes::license, &duplicates);
         std::vector<value> biblioids = consume_multiple_lists(values, doc_info_attributes::biblioid);
         value xmlbase = consume_value_in_list(values, doc_info_attributes::xmlbase, &duplicates);
-
- // Skip over source-mode tags (already dealt with)
-
- while (values.check(doc_info_attributes::source_mode)) values.consume();
 
         values.finish();
 

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -17,6 +17,7 @@
 #include <boost/spirit/include/classic_chset.hpp>
 #include <boost/spirit/include/classic_numerics.hpp>
 #include <boost/spirit/include/phoenix1_primitives.hpp>
+#include <boost/spirit/include/phoenix1_operators.hpp>
 #include "grammar_impl.hpp"
 #include "actions_class.hpp"
 #include "doc_info_tags.hpp"
@@ -82,11 +83,13 @@
         cl::rule<scanner> attribute_rule;
         assign_attribute_type assign_attribute;
         fallback_attribute_type fallback_attribute;
-
+
         doc_info_grammar_local()
             : assign_attribute(*this)
             , fallback_attribute(*this)
         {}
+
+ bool source_mode_unset;
     };
 
     void quickbook_grammar::impl::init_doc_info()
@@ -112,7 +115,7 @@
         }
         
         doc_info_details =
- space
+ space [ph::var(local.source_mode_unset) = true]
>> *( local.doc_attribute
>> space
                 )
@@ -128,6 +131,9 @@
>> actions.to_value(doc_info_tags::title)
                 [ *(~cl::eps_p(cl::ch_p('[') | ']' | cl::eol_p) >> local.char_) ]
>> space
+ >> !(qbk_since(106u) >> cl::eps_p(ph::var(local.source_mode_unset))
+ [cl::assign_a(actions.source_mode, "c++")]
+ )
>> (*( local.doc_info_attribute
>> space
                 )) [actions.values.sort()]
@@ -187,6 +193,17 @@
 
         local.attribute_rules[doc_attributes::compatibility_mode] = &local.doc_compatibility_mode;
 
+ local.doc_source_mode =
+ (
+ cl::str_p("c++")
+ | "python"
+ | "teletype"
+ ) [cl::assign_a(actions.source_mode)]
+ [ph::var(local.source_mode_unset) = false]
+ ;
+
+ local.attribute_rules[doc_attributes::source_mode] = &local.doc_source_mode;
+
         // Document Info Attributes
 
         // TODO: Restrictions on doc_id and doc_dirname?
@@ -253,16 +270,6 @@
 
         local.attribute_rules[doc_info_attributes::authors] = &local.doc_authors;
 
- local.doc_source_mode =
- (
- cl::str_p("c++")
- | "python"
- | "teletype"
- ) [cl::assign_a(actions.source_mode)]
- ;
-
- local.attribute_rules[doc_info_attributes::source_mode] = &local.doc_source_mode;
-
         local.doc_biblioid =
                 (+cl::alnum_p) [actions.values.entry(ph::arg1, ph::arg2, doc_info_tags::biblioid_class)]
>> hard_space

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -26,6 +26,7 @@
     QUICKBOOK_VALUE_NAMED_TAGS(doc_attributes, 0x440,
         ((qbk_version)("quickbook"))
         ((compatibility_mode)("compatibility-mode"))
+ ((source_mode)("source-mode"))
     )
 
     QUICKBOOK_VALUE_NAMED_TAGS(doc_info_attributes, 0x450,
@@ -41,8 +42,6 @@
         ((license)("license"))
         ((biblioid)("biblioid"))
         ((xmlbase)("xmlbase"))
- // Source mode must come last.
- ((source_mode)("source-mode"))
     )
 }
 

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-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -77,18 +77,7 @@
         parse_iterator first(actor.current_file->source.begin());
         parse_iterator last(actor.current_file->source.end());
 
- // This is awkward. When not ignoring docinfo, the source_mode should be
- // reset, but the code doesn't find out if the docinfo is ignored until
- // too late. So reset it now, but save it in order to undo the reset if
- // appopriate.
- std::string saved_source_mode = actor.source_mode;
- if (qbk_version_n >= 106) actor.source_mode = "c++";
-
         cl::parse_info<parse_iterator> info = cl::parse(first, last, actor.grammar().doc_info);
-
- // TODO: Fix this:
- if (!info.hit) actor.source_mode = saved_source_mode;
-
         if (!actor.error_count)
         {
             std::string doc_type = pre(actor.out, actor, include_doc_id, nested_file);

Modified: branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-cpp-include.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-cpp-include.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/source-mode-cpp-include.quickbook 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -1,5 +1,4 @@
-[article C++ source mode include
 [source-mode c++]
-]
+[article C++ source mode include]
 
 ```int main() {}```
\ No newline at end of file

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-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -35,4 +35,6 @@
     [ quickbook-test in_section-1_6 ]
     [ quickbook-test compatibility-1_1 ]
     [ quickbook-test compatibility-1_5 ]
+ [ quickbook-test source_mode-1_5 ]
+ [ quickbook-test source_mode-1_6 ]
     ;

Added: branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_5.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_5.gold 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,7 @@
+<?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="souce_mode_include_" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Souce Mode Include </title>
+<programlisting>void main() {}</programlisting>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_5.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_5.quickbook 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,3 @@
+[article Souce Mode Include [source-mode teletype][quickbook 1.5]]
+
+[include source_mode-inc1.qbk]
\ No newline at end of file

Added: branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_6.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_6.gold 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,11 @@
+<?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="souce_mode_include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Souce Mode Include</title>
+ <article id="source_include_with_no_source_mode" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Source include with no source-mode</title>
+<programlisting><phrase role="keyword">void</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase></programlisting>
+ </article>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_6.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/source_mode-1_6.quickbook 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,4 @@
+[source-mode teletype][quickbook 1.6]
+[article Souce Mode Include]
+
+[include source_mode-inc1.qbk]
\ No newline at end of file

Added: branches/quickbook-dev/tools/quickbook/test/include/source_mode-inc1.qbk
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/source_mode-inc1.qbk 2011-11-17 16:04:02 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,3 @@
+[article Source include with no source-mode]
+
+ void main() {}
\ 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