Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85130 - in trunk/tools/quickbook: doc src test
From: dnljms_at_[hidden]
Date: 2013-07-23 04:23:29


Author: danieljames
Date: 2013-07-23 04:23:29 EDT (Tue, 23 Jul 2013)
New Revision: 85130
URL: http://svn.boost.org/trac/boost/changeset/85130

Log:
Expand all phrase templates inline, even if they contain blocks.

Hopefully more intuitive than turning what looks like a phrase into
a block.

Text files modified:
   trunk/tools/quickbook/doc/1_6.qbk | 25 +++++++++-------
   trunk/tools/quickbook/src/actions.cpp | 60 +++++++++++++++++++++------------------
   trunk/tools/quickbook/test/templates-1_7.gold | 23 ++++----------
   trunk/tools/quickbook/test/templates-1_7.quickbook | 10 +++---
   4 files changed, 58 insertions(+), 60 deletions(-)

Modified: trunk/tools/quickbook/doc/1_6.qbk
==============================================================================
--- trunk/tools/quickbook/doc/1_6.qbk Tue Jul 23 04:23:07 2013 (r85129)
+++ trunk/tools/quickbook/doc/1_6.qbk 2013-07-23 04:23:29 EDT (Tue, 23 Jul 2013) (r85130)
@@ -455,25 +455,28 @@
 
 [endsect]
 
-[section:phrase_block_templates Allow block markup in phrase templates]
+[section:phrase_block_templates Allow block lements in phrase templates]
 
-Basically, if you use block markup in a phrase template, it automatically
-becomes a block template. So this:
+Block elements can now be used in phrase templates, but paragraphs breaks aren't
+allowed, so this is an error:
 
- [template foo This table: [table]]
+ [template paras[] Something or other.
 
-Is rougly equivalent to:
+ Second paragraph.]
 
- [template foo
+If a phrase template only contains block elements, then it's practically
+indistinguishable from a block template. So you'll get the same output from:
 
- This table:
+ [template foo[] [blurb Blah, blah, blah]]
 
- [table]
+as:
+
+ [template foo[]
+ [blurb Blah, blah, blah]
     ]
 
-This might be a little surprising, since if used inline it will cause 'This
-table' to appear in its own paragraph. That might be something worth fixing
-before the final 1.7.
+If a phrase template has phrase content mixed with block elements, it'll generate
+output as if it was expanded inline.
 
 [endsect]
 

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp Tue Jul 23 04:23:07 2013 (r85129)
+++ trunk/tools/quickbook/src/actions.cpp 2013-07-23 04:23:29 EDT (Tue, 23 Jul 2013) (r85130)
@@ -1232,23 +1232,17 @@
             string_iterator first)
     {
         bool is_block = symbol->content.get_tag() != template_tags::phrase;
+ quickbook::paragraph_action paragraph_action(state);
+
+ // Finish off any existing paragraphs.
+ if (is_block) paragraph_action();
 
         // If this template contains already encoded text, then just
         // write it out, without going through any of the rigamarole.
 
         if (symbol->content.is_encoded())
         {
- if (is_block)
- {
- paragraph_action para(state);
- para();
- state.out << symbol->content.get_encoded();
- }
- else
- {
- state.phrase << symbol->content.get_encoded();
- }
-
+ (is_block ? state.out : state.phrase) << symbol->content.get_encoded();
             return;
         }
 
@@ -1259,11 +1253,11 @@
         // arguments are expanded.
         template_scope const& call_scope = state.templates.top_scope();
 
- std::string block;
- std::string phrase;
-
         {
- state_save save(state, state_save::scope_all);
+ state_save save(state, state_save::scope_callables);
+ std::string save_block;
+ std::string save_phrase;
+
             state.templates.start_template(symbol);
 
             qbk_version_n = symbol->content.get_file()->version();
@@ -1296,6 +1290,11 @@
             ///////////////////////////////////
             // parse the template body:
 
+ if (symbol->content.get_file()->version() < 107u) {
+ state.out.swap(save_block);
+ state.phrase.swap(save_phrase);
+ }
+
             if (!parse_template(symbol->content, state))
             {
                 detail::outerr(state.current_file, first)
@@ -1321,19 +1320,24 @@
                 return;
             }
 
- state.out.swap(block);
- state.phrase.swap(phrase);
- }
-
- if(is_block || !block.empty()) {
- paragraph_action para(state);
- para(); // For paragraphs before the template call.
- state.out << block;
- state.phrase << phrase;
- para();
- }
- else {
- state.phrase << phrase;
+ if (symbol->content.get_file()->version() < 107u) {
+ state.out.swap(save_block);
+ state.phrase.swap(save_phrase);
+
+ if(is_block || !save_block.empty()) {
+ paragraph_action();
+ state.out << save_block;
+ state.phrase << save_phrase;
+ paragraph_action();
+ }
+ else {
+ state.phrase << save_phrase;
+ }
+ }
+ else
+ {
+ if (is_block) paragraph_action();
+ }
         }
     }
 

Modified: trunk/tools/quickbook/test/templates-1_7.gold
==============================================================================
--- trunk/tools/quickbook/test/templates-1_7.gold Tue Jul 23 04:23:07 2013 (r85129)
+++ trunk/tools/quickbook/test/templates-1_7.gold 2013-07-23 04:23:29 EDT (Tue, 23 Jul 2013) (r85130)
@@ -103,10 +103,7 @@
       Post
     </para>
     <para>
- Pre
- </para>
- <para>
- Start phrase template.
+ Pre Start phrase template.
     </para>
     <para>
       Start block template.
@@ -118,10 +115,7 @@
       End block template.
     </para>
     <para>
- End phrase template.
- </para>
- <para>
- Post
+ End phrase template. Post
     </para>
     <para>
       Pre Start phrase template. Start phrase template. Hello! End phrase template.
@@ -247,10 +241,7 @@
       </tgroup>
     </informaltable>
     <para>
- Text2 afterwards
- </para>
- <para>
- Text3 before
+ Text2 afterwards. Text3 before.
     </para>
     <informaltable frame="all">
       <tgroup cols="0">
@@ -259,7 +250,7 @@
       </tgroup>
     </informaltable>
     <para>
- Text4 before
+ Text4 before.
     </para>
     <informaltable frame="all">
       <tgroup cols="0">
@@ -268,7 +259,7 @@
       </tgroup>
     </informaltable>
     <para>
- Text4 afterwards
+ Text4 afterwards.
     </para>
     <informaltable frame="all">
       <tgroup cols="0">
@@ -277,7 +268,7 @@
       </tgroup>
     </informaltable>
     <para>
- * Not a list
+ * Not a list.
     </para>
     <informaltable frame="all">
       <tgroup cols="0">
@@ -286,7 +277,7 @@
       </tgroup>
     </informaltable>
     <para>
- * Not a list
+ * Not a list.
     </para>
   </section>
 </article>

Modified: trunk/tools/quickbook/test/templates-1_7.quickbook
==============================================================================
--- trunk/tools/quickbook/test/templates-1_7.quickbook Tue Jul 23 04:23:07 2013 (r85129)
+++ trunk/tools/quickbook/test/templates-1_7.quickbook 2013-07-23 04:23:29 EDT (Tue, 23 Jul 2013) (r85130)
@@ -281,12 +281,12 @@
 [/ Blocks in phrase templates ]
 
 [template phrase_block1[] [table]]
-[template phrase_block2[] [table] Text2 afterwards]
-[template phrase_block3[] Text3 before [table]]
-[template phrase_block4[] Text4 before [table] Text4 afterwards]
-[template phrase_block5[] [table] * Not a list]
+[template phrase_block2[] [table] Text2 afterwards.]
+[template phrase_block3[] Text3 before. [table]]
+[template phrase_block4[] Text4 before. [table] Text4 afterwards.]
+[template phrase_block5[] [table] * Not a list.]
 [template phrase_block6[] [table]
-* Not a list]
+* Not a list.]
 
 [phrase_block1][phrase_block2][phrase_block3][phrase_block4]
 [phrase_block5][phrase_block6]


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