Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71060 - in branches/quickbook-dev/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-04-06 19:58:46


Author: danieljames
Date: 2011-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
New Revision: 71060
URL: http://svn.boost.org/trac/boost/changeset/71060

Log:
Quickbook: Write out blocks smuggled into phrases.

Pretty clumsy, but it's a dodgy thing to do. Maybe the values could
include whether they're blocks or phrases and actions could react
accordingly.
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 17 ++++++++++++--
   branches/quickbook-dev/tools/quickbook/src/actions.hpp | 7 ++---
   branches/quickbook-dev/tools/quickbook/src/actions_class.cpp | 3 -
   branches/quickbook-dev/tools/quickbook/src/actions_class.hpp | 3 -
   branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp | 2
   branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 4 +-
   branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp | 2
   branches/quickbook-dev/tools/quickbook/test/templates.gold | 45 ++++++++++++++++++++++++++++++++++++++++
   branches/quickbook-dev/tools/quickbook/test/templates.quickbook | 13 ++++++++++
   9 files changed, 80 insertions(+), 16 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-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -1927,13 +1927,24 @@
         return (*this)(first, last, value::default_tag);
     }
     
- void collector_to_value_action::operator()(iterator, iterator) const
+ void to_value_action::operator()(iterator, iterator) const
     {
         if (!(actions.process_state & actions.process_output)) return;
- write_anchors(actions, output);
 
         std::string value;
- output.swap(value);
+
+ if (!actions.out.str().empty())
+ {
+ actions.paragraph();
+ write_anchors(actions, actions.out);
+ actions.out.swap(value);
+ }
+ else
+ {
+ write_anchors(actions, actions.phrase);
+ actions.phrase.swap(value);
+ }
+
         actions.values.builder.insert(bbk_value(value, value::default_tag));
     }
     

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-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -364,15 +364,14 @@
     
     typedef phoenix::function<phrase_to_docinfo_action_impl> phrase_to_docinfo_action;
 
- struct collector_to_value_action
+ struct to_value_action
     {
- collector_to_value_action(quickbook::actions& actions, collector& output)
- : actions(actions), output(output) {}
+ to_value_action(quickbook::actions& actions)
+ : actions(actions) {}
 
         void operator()(iterator first, iterator last) const;
 
         quickbook::actions& actions;
- collector& output;
     };
 
     struct scoped_output_push : scoped_action_base

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-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -51,8 +51,7 @@
         , values()
 
     // actions
- , phrase_value(*this, phrase)
- , out_value(*this, out)
+ , to_value(*this)
         , docinfo_value(*this)
 
         , scoped_cond_phrase(*this)

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-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -84,8 +84,7 @@
     // actions
     ///////////////////////////////////////////////////////////////////////////
 
- collector_to_value_action phrase_value;
- collector_to_value_action out_value;
+ to_value_action to_value;
         phrase_to_docinfo_action docinfo_value;
         
         scoped_parser<cond_phrase_push>

Modified: branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp 2011-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -282,7 +282,7 @@
         local.inner_block =
             actions.scoped_output()
             [
- inside_paragraph [actions.out_value]
+ inside_paragraph [actions.to_value]
             ]
             ;
 

Modified: branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp 2011-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -222,7 +222,7 @@
>> (cl::ch_p('*') | '#')
                                             [actions.values.entry(ph::arg1, ph::arg2, general_tags::list_mark)]
>> *cl::blank_p
- >> local.list_item [actions.phrase_value]
+ >> local.list_item [actions.to_value]
                     ]
                 ]
                 ] [actions.element]
@@ -509,7 +509,7 @@
>> local.command_line_phrase
>> *cl::space_p
                 | cl::eps_p
- ) [actions.phrase_value]
+ ) [actions.to_value]
             ] [actions.element]
             ;
 

Modified: branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp 2011-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -127,7 +127,7 @@
         local.inner_phrase =
                 blank
>> actions.scoped_output()
- [ phrase [actions.phrase_value]
+ [ phrase [actions.to_value]
                 ]
             ;
     }

Modified: branches/quickbook-dev/tools/quickbook/test/templates.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/templates.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/templates.gold 2011-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -145,5 +145,50 @@
     <para/>
     
 <programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase></programlisting>
+ <para>
+ Paragraphs 1
+ </para>
+ <para>
+ Paragraphs 2
+ </para>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ a
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ b
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ <para/>
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase></programlisting>
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ <para>
+ Paragraphs 1
+ </para>
+ <para>
+ Paragraphs 2
+ </para>
+ </simpara>
+ </listitem>
+ </itemizedlist>
   </section>
 </article>

Modified: branches/quickbook-dev/tools/quickbook/test/templates.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/templates.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/templates.quickbook 2011-04-06 19:58:44 EDT (Wed, 06 Apr 2011)
@@ -184,6 +184,17 @@
 [template codeblock
     int main() {}]
 
-[list][horizontal][codeblock]
+[template paragraphs
+Paragraphs 1
+
+Paragraphs 2
+]
+
+[list][horizontal][codeblock][paragraphs]
+
+* [list]
+* [horizontal]
+* [codeblock]
+* [paragraphs]
 
 [endsect]


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