|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63162 - in branches/quickbook-1.5-spirit2: . test
From: daniel_james_at_[hidden]
Date: 2010-06-20 16:30:34
Author: danieljames
Date: 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
New Revision: 63162
URL: http://svn.boost.org/trac/boost/changeset/63162
Log:
Smarter use of paragraphs with templates.
Use the new paragraph output system to avoid expanding block templates
inside paragraphs. Refs #4302
Text files modified:
branches/quickbook-1.5-spirit2/phrase_actions.hpp | 2
branches/quickbook-1.5-spirit2/phrase_grammar.cpp | 2
branches/quickbook-1.5-spirit2/template.cpp | 27 +++++--
branches/quickbook-1.5-spirit2/test/callouts.gold | 68 ++++++++----------
branches/quickbook-1.5-spirit2/test/import.gold | 140 +++++++++++++++++++--------------------
branches/quickbook-1.5-spirit2/test/quickbook-manual.gold | 126 ++++++++++++++++-------------------
branches/quickbook-1.5-spirit2/test/template-section.gold | 30 ++++----
branches/quickbook-1.5-spirit2/test/template-section.quickbook | 2
branches/quickbook-1.5-spirit2/test/templates.gold | 20 +----
9 files changed, 196 insertions(+), 221 deletions(-)
Modified: branches/quickbook-1.5-spirit2/phrase_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_actions.hpp 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -25,7 +25,7 @@
break_ process(quickbook::state&, break_ const&);
boost::variant<formatted, block_formatted> process(quickbook::state&, code const&);
image2 process(quickbook::state&, image const&);
- std::string process(quickbook::state&, call_template const&);
+ nothing process(quickbook::state&, call_template const&);
}
#endif
Modified: branches/quickbook-1.5-spirit2/phrase_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_grammar.cpp 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -110,7 +110,7 @@
]
;
- simple_format_multiple_char
+ simple_format_chars
= *( qi::char_ -
( (qi::graph >> qi::lit(qi::_r1))
| simple_phrase_end // Make sure that we don't go
Modified: branches/quickbook-1.5-spirit2/template.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template.cpp (original)
+++ branches/quickbook-1.5-spirit2/template.cpp 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -354,6 +354,7 @@
++first; // skip initial newlines
r = boost::spirit::qi::parse(first, last, g.block) && first == last;
+ state.paragraph_output();
state.block.swap(result);
}
@@ -361,7 +362,7 @@
}
}
- std::string process(quickbook::state& state, call_template const& x)
+ nothing process(quickbook::state& state, call_template const& x)
{
++state.template_depth;
if (state.template_depth > state.max_template_depth)
@@ -370,7 +371,7 @@
<< "Infinite loop detected" << std::endl;
--state.template_depth;
++state.error_count;
- return "";
+ return nothing();
}
// The template arguments should have the scope that the template was
@@ -403,7 +404,7 @@
state.pop(); // restore the state
--state.template_depth;
++state.error_count;
- return "";
+ return nothing();
}
///////////////////////////////////
@@ -418,7 +419,7 @@
{
state.pop(); // restore the state
--state.template_depth;
- return "";
+ return nothing();
}
///////////////////////////////////
@@ -436,7 +437,7 @@
state.pop(); // restore the state
--state.template_depth;
++state.error_count;
- return "";
+ return nothing();
}
if (state.section_level != state.min_section_level)
@@ -446,7 +447,7 @@
state.pop(); // restore the actions' states
--state.template_depth;
++state.error_count;
- return "";
+ return nothing();
}
}
@@ -470,7 +471,7 @@
<< "Error expanding callout."
<< std::endl;
++state.error_count;
- return "";
+ return nothing();
}
list.push_back(item);
@@ -484,8 +485,16 @@
result += state.block.str();
state.pop();
}
-
- return result;
+
+ if(x.symbol->is_block) {
+ state.paragraph_output();
+ state.block << result;
+ }
+ else {
+ state.phrase << result;
+ }
+
+ return nothing();
}
}
Modified: branches/quickbook-1.5-spirit2/test/callouts.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/callouts.gold (original)
+++ branches/quickbook-1.5-spirit2/test/callouts.gold 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -9,67 +9,61 @@
Example 1:
</para>
<para>
- <para>
- Now we can define a function that simulates an ordinary six-sided die.
- </para>
- <para>
-
+ Now we can define a function that simulates an ordinary six-sided die.
+ </para>
+ <para>
+
<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
<phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests0co" linkends="callout_tests0" />
<phrase role="special">}</phrase>
</programlisting>
- </para>
- <calloutlist>
- <callout arearefs="callout_tests0co" id="callout_tests0">
- <para>
- create a uniform_int distribution
- </para>
- </callout>
- </calloutlist>
</para>
+ <calloutlist>
+ <callout arearefs="callout_tests0co" id="callout_tests0">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
<para>
Example 2:
</para>
<para>
- <para>
-
+
<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
<co id="callout_tests1co" linkends="callout_tests1" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
<phrase role="special">}</phrase>
</programlisting>
- </para>
- <calloutlist>
- <callout arearefs="callout_tests1co" id="callout_tests1">
- <important>
- <para>
- test
- </para>
- </important>
- </callout>
- </calloutlist>
</para>
+ <calloutlist>
+ <callout arearefs="callout_tests1co" id="callout_tests1">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
<para>
Example 3:
</para>
<para>
- <para>
-
+
<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
<co id="callout_tests2co" linkends="callout_tests2" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special"><</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special"><></phrase> <phrase role="special">></phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
<phrase role="special">}</phrase>
</programlisting>
- </para>
- <calloutlist>
- <callout arearefs="callout_tests2co" id="callout_tests2">
- <important>
- <para>
- test
- </para>
- </important>
- </callout>
- </calloutlist>
</para>
+ <calloutlist>
+ <callout arearefs="callout_tests2co" id="callout_tests2">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
</article>
Modified: branches/quickbook-1.5-spirit2/test/import.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/import.gold (original)
+++ branches/quickbook-1.5-spirit2/test/import.gold 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -5,99 +5,93 @@
<articleinfo>
</articleinfo>
<para>
- <para>
- This is the <emphasis role="bold"><emphasis>foo</emphasis></emphasis> function.
- </para>
- <para>
- This description can have paragraphs...
- </para>
- <itemizedlist>
- <listitem>
- <simpara>
- lists
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- etc.
- </simpara>
- </listitem>
- </itemizedlist>
- <para>
- And any quickbook block markup.
- </para>
- <para>
-
+ This is the <emphasis role="bold"><emphasis>foo</emphasis></emphasis> function.
+ </para>
+ <para>
+ This description can have paragraphs...
+ </para>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ lists
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ etc.
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <para>
+ And any quickbook block markup.
+ </para>
+ <para>
+
<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">foo</phrase><phrase role="special">()</phrase>
<phrase role="special">{</phrase>
<phrase role="comment">// return 'em, foo man!
</phrase> <phrase role="keyword">return</phrase> <phrase role="string">"foo"</phrase><phrase role="special">;</phrase>
<phrase role="special">}</phrase>
</programlisting>
- </para>
</para>
<para>
- <para>
- This is the Python <emphasis role="bold"><emphasis>foo</emphasis></emphasis>
- function.
- </para>
- <para>
- This description can have paragraphs...
- </para>
- <itemizedlist>
- <listitem>
- <simpara>
- lists
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- etc.
- </simpara>
- </listitem>
- </itemizedlist>
- <para>
- And any quickbook block markup.
- </para>
- <para>
-
+ This is the Python <emphasis role="bold"><emphasis>foo</emphasis></emphasis>
+ function.
+ </para>
+ <para>
+ This description can have paragraphs...
+ </para>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ lists
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ etc.
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <para>
+ And any quickbook block markup.
+ </para>
+ <para>
+
<programlisting><phrase role="keyword">def</phrase> <phrase role="identifier">foo</phrase><phrase role="special">():</phrase>
<phrase role="comment"># return 'em, foo man!
</phrase> <phrase role="keyword">return</phrase> <phrase role="string">"foo"</phrase>
</programlisting>
- </para>
</para>
<para>
- <para>
- This is the C <emphasis role="bold"><emphasis>foo</emphasis></emphasis> function.
- </para>
- <para>
- This description can have paragraphs...
- </para>
- <itemizedlist>
- <listitem>
- <simpara>
- lists
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- etc.
- </simpara>
- </listitem>
- </itemizedlist>
- <para>
- And any quickbook block markup.
- </para>
- <para>
-
+ This is the C <emphasis role="bold"><emphasis>foo</emphasis></emphasis> function.
+ </para>
+ <para>
+ This description can have paragraphs...
+ </para>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ lists
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ etc.
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <para>
+ And any quickbook block markup.
+ </para>
+ <para>
+
<programlisting><phrase role="keyword">char</phrase><phrase role="special">*</phrase> <phrase role="identifier">foo</phrase><phrase role="special">()</phrase>
<phrase role="special">{</phrase>
<phrase role="comment">// return 'em, foo man!
</phrase> <phrase role="keyword">return</phrase> <phrase role="string">"foo"</phrase><phrase role="special">;</phrase>
<phrase role="special">}</phrase>
</programlisting>
- </para>
</para>
</article>
Modified: branches/quickbook-1.5-spirit2/test/quickbook-manual.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/quickbook-manual.gold (original)
+++ branches/quickbook-1.5-spirit2/test/quickbook-manual.gold 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -2060,12 +2060,12 @@
Which will expand to:
</para>
<para>
- <para>
- Hi, my name is James Bond. I am 39 years old. I am a Spy.
- </para>
- <para>
- Hi, my name is Santa Clause. I am 87 years old. I am a Big Red Fatso.
- </para>
+ Hi, my name is James Bond. I am 39 years old. I am a Spy.
+ </para>
+ <para>
+ </para>
+ <para>
+ Hi, my name is Santa Clause. I am 87 years old. I am a Big Red Fatso.
</para>
<caution>
<para>
@@ -2689,52 +2689,50 @@
And the result is:
</para>
<para>
- <para>
- This is the <emphasis role="bold"><emphasis>foo</emphasis></emphasis>
- function.
- </para>
- <para>
- This description can have paragraphs...
- </para>
- <itemizedlist>
- <listitem>
- <simpara>
- lists
- </simpara>
- </listitem>
- <listitem>
- <simpara>
- etc.
- </simpara>
- </listitem>
- </itemizedlist>
- <para>
- And any quickbook block markup.
- </para>
- <para>
-
+ This is the <emphasis role="bold"><emphasis>foo</emphasis></emphasis> function.
+ </para>
+ <para>
+ This description can have paragraphs...
+ </para>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ lists
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ etc.
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <para>
+ And any quickbook block markup.
+ </para>
+ <para>
+
<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">foo</phrase><phrase role="special">()</phrase>
<phrase role="special">{</phrase>
<phrase role="comment">// return 'em, foo man!
</phrase> <phrase role="keyword">return</phrase> <phrase role="string">"foo"</phrase><phrase role="special">;</phrase>
<phrase role="special">}</phrase>
</programlisting>
- </para>
- <para>
- This is the <emphasis role="bold"><emphasis>bar</emphasis></emphasis>
- function
- </para>
- <para>
-
+ </para>
+ <para>
+ </para>
+ <para>
+ This is the <emphasis role="bold"><emphasis>bar</emphasis></emphasis> function
+ </para>
+ <para>
+
<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">bar</phrase><phrase role="special">()</phrase>
<phrase role="special">{</phrase>
<phrase role="comment">// return 'em, bar man!
</phrase> <phrase role="keyword">return</phrase> <phrase role="string">"bar"</phrase><phrase role="special">;</phrase>
<phrase role="special">}</phrase></programlisting>
- </para>
- <para>
- Some trailing text here
- </para>
+ </para>
+ <para>
+ Some trailing text here
</para>
<anchor id="quickbook.syntax.block.import.code_snippet_markup"/>
<bridgehead renderas="sect5">
@@ -2798,28 +2796,26 @@
for details. Example:
</para>
<para>
- <para>
-
+
<programlisting><phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">string</phrase> <phrase role="identifier">foo_bar</phrase><phrase role="special">()</phrase> <co id="quickbook0co" linkends="quickbook0" />
<phrase role="special">{</phrase>
<phrase role="keyword">return</phrase> <phrase role="string">"foo-bar"</phrase><phrase role="special">;</phrase> <co id="quickbook1co" linkends="quickbook1" />
<phrase role="special">}</phrase>
</programlisting>
- </para>
- <calloutlist>
- <callout arearefs="quickbook0co" id="quickbook0">
- <para>
- The <emphasis>Mythical</emphasis> FooBar. See <ulink url="http://en.wikipedia.org/wiki/Foobar">Foobar
- for details</ulink>
- </para>
- </callout>
- <callout arearefs="quickbook1co" id="quickbook1">
- <para>
- return 'em, foo-bar man!
- </para>
- </callout>
- </calloutlist>
</para>
+ <calloutlist>
+ <callout arearefs="quickbook0co" id="quickbook0">
+ <para>
+ The <emphasis>Mythical</emphasis> FooBar. See <ulink url="http://en.wikipedia.org/wiki/Foobar">Foobar
+ for details</ulink>
+ </para>
+ </callout>
+ <callout arearefs="quickbook1co" id="quickbook1">
+ <para>
+ return 'em, foo-bar man!
+ </para>
+ </callout>
+ </calloutlist>
<para>
Checkout <ulink url="../../test/stub.cpp">stub.cpp</ulink> to see the actual
code.
@@ -3740,13 +3736,11 @@
</para>
</entry>
<entry>
- <para>
-
+
<programlisting><!--quickbook-escape-prefix--># one
# two
# three
<!--quickbook-escape-postfix--></programlisting>
- </para>
</entry>
<entry>
<para>
@@ -3762,13 +3756,11 @@
</para>
</entry>
<entry>
- <para>
-
+
<programlisting><!--quickbook-escape-prefix-->* one
* two
* three
<!--quickbook-escape-postfix--></programlisting>
- </para>
</entry>
<entry>
<para>
@@ -4005,14 +3997,12 @@
</para>
</entry>
<entry>
- <para>
-
+
<programlisting><!--quickbook-escape-prefix-->[table Title
[[a][b][c]]
[[a][b][c]]
]
<!--quickbook-escape-postfix--></programlisting>
- </para>
</entry>
<entry>
<para>
@@ -4027,14 +4017,12 @@
</para>
</entry>
<entry>
- <para>
-
+
<programlisting><!--quickbook-escape-prefix-->[variablelist Title
[[a][b]]
[[a][b]]
]
<!--quickbook-escape-postfix--></programlisting>
- </para>
</entry>
<entry>
<para>
Modified: branches/quickbook-1.5-spirit2/test/template-section.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/template-section.gold (original)
+++ branches/quickbook-1.5-spirit2/test/template-section.gold 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -6,22 +6,20 @@
<articleinfo>
</articleinfo>
<para>
+ Some text before the section.
+ </para>
+ <section id="section_in_a_template.test">
+ <title><link linkend="section_in_a_template.test">Test</link></title>
<para>
- It's a pity if the whole template is wrapped in a paragraph.
+ Hello.
</para>
- <section id="section_in_a_template.test">
- <title><link linkend="section_in_a_template.test">Test</link></title>
- <para>
- Hello.
- </para>
- <anchor id="section_in_a_template.test.just_to_test_id_generation"/>
- <bridgehead renderas="sect3">
- <link linkend="section_in_a_template.test.just_to_test_id_generation">Just
- to test id generation</link>
- </bridgehead>
- <para>
- Goodbye.
- </para>
- </section>
- </para>
+ <anchor id="section_in_a_template.test.just_to_test_id_generation"/>
+ <bridgehead renderas="sect3">
+ <link linkend="section_in_a_template.test.just_to_test_id_generation">Just
+ to test id generation</link>
+ </bridgehead>
+ <para>
+ Goodbye.
+ </para>
+ </section>
</article>
Modified: branches/quickbook-1.5-spirit2/test/template-section.quickbook
==============================================================================
--- branches/quickbook-1.5-spirit2/test/template-section.quickbook (original)
+++ branches/quickbook-1.5-spirit2/test/template-section.quickbook 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -4,7 +4,7 @@
[template nestedsection[]
-It's a pity if the whole template is wrapped in a paragraph.
+Some text before the section.
[section Test]
Modified: branches/quickbook-1.5-spirit2/test/templates.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/templates.gold (original)
+++ branches/quickbook-1.5-spirit2/test/templates.gold 2010-06-20 16:30:32 EDT (Sun, 20 Jun 2010)
@@ -13,24 +13,18 @@
foo baz
</para>
<para>
- <para>
- foo baz
- </para>
+ foo baz
</para>
<para>
- <para>
- This is a complete paragraph. kalamazoo kalamazoo kalamazoo kalamazoo kalamazoo
- kalamazoo kalamazoo kalamazoo kalamazoo.... blah blah blah......
- </para>
+ This is a complete paragraph. kalamazoo kalamazoo kalamazoo kalamazoo kalamazoo
+ kalamazoo kalamazoo kalamazoo kalamazoo.... blah blah blah......
</para>
<para>
<hey>baz</hey>
</para>
<para>
- <para>
- This is a complete paragraph. madagascar madagascar madagascar madagascar
- madagascar madagascar madagascar madagascar madagascar.... blah blah blah......
- </para>
+ This is a complete paragraph. madagascar madagascar madagascar madagascar madagascar
+ madagascar madagascar madagascar madagascar.... blah blah blah......
</para>
<para>
zoom peanut zoom
@@ -44,14 +38,12 @@
<para>
wxyz wxyz trail
</para>
- <para>
-
+
<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase>
<phrase role="special">{</phrase>
<phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">cout</phrase> <phrase role="special"><<</phrase> "Hello, World" <phrase role="special"><<</phrase> <phrase role="identifier">std</phrase><phrase role="special">::</phrase><phrase role="identifier">endl</phrase><phrase role="special">;</phrase>
<phrase role="special">}</phrase>
</programlisting>
- </para>
<para>
x<superscript>2</superscript>
</para>
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