Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r71056 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-04-06 19:42:33


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

Log:
Quickbook: Write out blocks smuggled into phrases.

Pretty clumsy, but it's a dodgy thing for the user to do. Maybe the
values could include whether they're blocks or phrases and actions could
react accordingly.
Text files modified:
   trunk/tools/quickbook/src/actions.cpp | 17 ++++++++-
   trunk/tools/quickbook/src/actions.hpp | 7 +--
   trunk/tools/quickbook/src/actions_class.cpp | 3 -
   trunk/tools/quickbook/src/actions_class.hpp | 3 -
   trunk/tools/quickbook/src/block_element_grammar.cpp | 2
   trunk/tools/quickbook/src/main_grammar.cpp | 4 +-
   trunk/tools/quickbook/src/phrase_element_grammar.cpp | 2
   trunk/tools/quickbook/test/templates.gold | 65 ++++++++++++++++++++++++++++++++++++++++
   trunk/tools/quickbook/test/templates.quickbook | 29 +++++++++++++++++
   9 files changed, 117 insertions(+), 15 deletions(-)

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -1885,13 +1885,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.suppress) 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: trunk/tools/quickbook/src/actions.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions.hpp (original)
+++ trunk/tools/quickbook/src/actions.hpp 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -357,15 +357,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: trunk/tools/quickbook/src/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.cpp (original)
+++ trunk/tools/quickbook/src/actions_class.cpp 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -35,8 +35,7 @@
 
     // value actions
         , values()
- , phrase_value(*this, phrase)
- , out_value(*this, out)
+ , to_value(*this)
         , docinfo_value(*this)
         , scoped_cond_phrase(*this)
         , scoped_output(*this)

Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp (original)
+++ trunk/tools/quickbook/src/actions_class.hpp 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -51,8 +51,7 @@
 
     // value actions
         value_parser values;
- 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: trunk/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_element_grammar.cpp (original)
+++ trunk/tools/quickbook/src/block_element_grammar.cpp 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -281,7 +281,7 @@
         local.inner_block =
             actions.scoped_output()
             [
- inside_paragraph [actions.out_value]
+ inside_paragraph [actions.to_value]
             ]
             ;
 

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp (original)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -221,7 +221,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]
@@ -508,7 +508,7 @@
>> local.command_line_phrase
>> *cl::space_p
                 | cl::eps_p
- ) [actions.phrase_value]
+ ) [actions.to_value]
             ] [actions.element]
             ;
 

Modified: trunk/tools/quickbook/src/phrase_element_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/phrase_element_grammar.cpp (original)
+++ trunk/tools/quickbook/src/phrase_element_grammar.cpp 2011-04-06 19:42:31 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: trunk/tools/quickbook/test/templates.gold
==============================================================================
--- trunk/tools/quickbook/test/templates.gold (original)
+++ trunk/tools/quickbook/test/templates.gold 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -128,4 +128,69 @@
       End phrase template. Post
     </para>
   </section>
+ <section id="templates.block_markup">
+ <title><link linkend="templates.block_markup">Block Markup</link></title>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ a
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ b
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <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: trunk/tools/quickbook/test/templates.quickbook
==============================================================================
--- trunk/tools/quickbook/test/templates.quickbook (original)
+++ trunk/tools/quickbook/test/templates.quickbook 2011-04-06 19:42:31 EDT (Wed, 06 Apr 2011)
@@ -169,3 +169,32 @@
 Pre [phrase [phrase Hello!]] Post
 
 [endsect]
+
+[/----------------------------------- Block Markup ]
+
+[section Block Markup]
+
+[template list
+* a
+* b]
+
+[template horizontal
+----]
+
+[template codeblock
+ int main() {}]
+
+[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