|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75175 - in branches/quickbook-dev/tools/quickbook: src test test/include
From: dnljms_at_[hidden]
Date: 2011-10-30 05:30:00
Author: danieljames
Date: 2011-10-30 05:29:56 EDT (Sun, 30 Oct 2011)
New Revision: 75175
URL: http://svn.boost.org/trac/boost/changeset/75175
Log:
Quickbook: Port Rene's sort code inclusion to quickbook-dev.
Text files modified:
branches/quickbook-dev/tools/quickbook/src/actions.cpp | 29 +++++-
branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp | 23 ++--
branches/quickbook-dev/tools/quickbook/test/include/code-include.gold | 167 ---------------------------------------
branches/quickbook-dev/tools/quickbook/test/stub.c | 6 +
branches/quickbook-dev/tools/quickbook/test/stub.cpp | 3
branches/quickbook-dev/tools/quickbook/test/stub.py | 2
6 files changed, 48 insertions(+), 182 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-10-30 05:29:56 EDT (Sun, 30 Oct 2011)
@@ -1871,11 +1871,16 @@
actions.error_count +=
load_snippets(paths.filename, storage, ext, load_type);
- if (load_type == block_tags::import)
+ if (load_type == block_tags::include)
{
- BOOST_FOREACH(template_symbol& ts, storage)
+ actions.templates.push();
+ }
+
+ BOOST_FOREACH(template_symbol& ts, storage)
+ {
+ std::string tname = ts.identifier;
+ if (tname != "!")
{
- std::string tname = ts.identifier;
ts.parent = &actions.templates.top_scope();
if (!actions.templates.add(ts))
{
@@ -1885,11 +1890,21 @@
}
}
}
- else
+
+ if (load_type == block_tags::include)
{
- template_symbol* snippet = &storage.back();
- snippet->parent = &actions.templates.top_scope();
- call_code_snippet(actions, false, snippet, pos);
+ BOOST_FOREACH(template_symbol& ts, storage)
+ {
+ std::string tname = ts.identifier;
+
+ if (tname == "!")
+ {
+ ts.parent = &actions.templates.top_scope();
+ call_code_snippet(actions, false, &ts, pos);
+ }
+ }
+
+ actions.templates.pop();
}
}
Modified: branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp 2011-10-30 05:29:56 EDT (Sun, 30 Oct 2011)
@@ -329,12 +329,6 @@
code_snippet_actions a(storage, file, is_python ? "[python]" : "[c++]");
// TODO: Should I check that parse succeeded?
- if (load_type == block_tags::include) {
- // Use an id that couldn't occur normally.
- a.id = "global tag";
- a.start_snippet(first, first);
- }
-
if(is_python) {
boost::spirit::classic::parse(first, last, python_code_snippet_grammar(a));
}
@@ -342,10 +336,6 @@
boost::spirit::classic::parse(first, last, cpp_code_snippet_grammar(a));
}
- if (load_type == block_tags::include) {
- a.end_snippet(first, first);
- }
-
return 0;
}
@@ -411,17 +401,28 @@
void code_snippet_actions::escaped_comment(iterator first, iterator last)
{
- if(!snippet_stack) return;
+ if (!snippet_stack)
+ {
+ id = "!";
+ start_snippet(first,first);
+ }
+
snippet_data& snippet = *snippet_stack;
append_code();
close_code();
std::string temp(first, last);
detail::unindent(temp); // remove all indents
+
if (temp.size() != 0)
{
snippet.content += "\n" + temp; // add a linebreak to allow block markups
}
+
+ if (snippet.id == "!")
+ {
+ end_snippet(first,first);
+ }
}
void code_snippet_actions::start_snippet(iterator, iterator)
Modified: branches/quickbook-dev/tools/quickbook/test/include/code-include.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/include/code-include.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/include/code-include.gold 2011-10-30 05:29:56 EDT (Sun, 30 Oct 2011)
@@ -3,17 +3,7 @@
<article id="include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Include</title>
<para>
-
-<programlisting><phrase role="comment">/*=============================================================================
- Copyright (c) 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- Use, modification and distribution is subject to the Boost Software
- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/</phrase>
-
-</programlisting>
+ This should appear when <literal>stub.c</literal> is included.
</para>
<para>
This is the C <emphasis role="bold"><emphasis>foo</emphasis></emphasis> function.
@@ -46,162 +36,11 @@
</programlisting>
</para>
<para>
-
-<programlisting><phrase role="comment"># Copyright 2009 Daniel James</phrase>
-<phrase role="comment">#</phrase>
-<phrase role="comment"># Use, modification and distribution is subject to the Boost Software</phrase>
-<phrase role="comment"># License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</phrase>
-<phrase role="comment"># http://www.boost.org/LICENSE_1_0.txt)</phrase>
-
-</programlisting>
- </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>
-
-<phrase role="keyword">print</phrase> <phrase role="identifier">foo</phrase><phrase role="special">()</phrase></programlisting>
- </para>
- <para>
-
-<programlisting><phrase role="comment">/*=============================================================================
- Copyright (c) 2006 Joel de Guzman
- http://spirit.sourceforge.net/
-
- Use, modification and distribution is subject to the Boost Software
- License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
- http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/</phrase>
-<phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">string</phrase><phrase role="special">></phrase>
-
-</programlisting>
- </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>
- 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.
+ This should appear when <literal>stub.py</literal> is included.
</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>
-<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="include.c0" linkends="include.c1" />
-<phrase role="special">{</phrase>
- <phrase role="keyword">return</phrase> <phrase role="string">"foo-bar"</phrase><phrase role="special">;</phrase> <co id="include.c2" linkends="include.c3" />
-<phrase role="special">}</phrase>
-<phrase role="keyword">class</phrase> <phrase role="identifier">x</phrase>
-<phrase role="special">{</phrase>
-<phrase role="keyword">public</phrase><phrase role="special">:</phrase>
-
- <co id="include.c4" linkends="include.c5" /><phrase role="identifier">x</phrase><phrase role="special">()</phrase> <phrase role="special">:</phrase> <phrase role="identifier">n</phrase><phrase role="special">(</phrase><phrase role="number">0</phrase><phrase role="special">)</phrase>
- <phrase role="special">{</phrase>
- <phrase role="special">}</phrase>
-
- <co id="include.c6" linkends="include.c7" /><phrase role="special">~</phrase><phrase role="identifier">x</phrase><phrase role="special">()</phrase>
- <phrase role="special">{</phrase>
- <phrase role="special">}</phrase>
-
- <co id="include.c8" linkends="include.c9" /><phrase role="keyword">int</phrase> <phrase role="identifier">get</phrase><phrase role="special">()</phrase> <phrase role="keyword">const</phrase>
- <phrase role="special">{</phrase>
- <phrase role="keyword">return</phrase> <phrase role="identifier">n</phrase><phrase role="special">;</phrase>
- <phrase role="special">}</phrase>
-
- <co id="include.c10" linkends="include.c11" /><phrase role="keyword">void</phrase> <phrase role="identifier">set</phrase><phrase role="special">(</phrase><phrase role="keyword">int</phrase> <phrase role="identifier">n_</phrase><phrase role="special">)</phrase>
- <phrase role="special">{</phrase>
- <phrase role="identifier">n</phrase> <phrase role="special">=</phrase> <phrase role="identifier">n_</phrase><phrase role="special">;</phrase>
- <phrase role="special">}</phrase>
-<phrase role="special">};</phrase>
-</programlisting>
+ This should appear when <literal>stub.cpp</literal> is included.
</para>
- <calloutlist>
- <callout arearefs="include.c0" id="include.c1">
- <para>
- The <emphasis>Mythical</emphasis> FooBar. See <ulink url="http://en.wikipedia.org/wiki/Foobar">Foobar
- for details</ulink>
- </para>
- </callout>
- <callout arearefs="include.c2" id="include.c3">
- <para>
- return 'em, foo-bar man!
- </para>
- </callout>
- <callout arearefs="include.c4" id="include.c5">
- <para>
- Constructor
- </para>
- </callout>
- <callout arearefs="include.c6" id="include.c7">
- <para>
- Destructor
- </para>
- </callout>
- <callout arearefs="include.c8" id="include.c9">
- <para>
- Get the <code><phrase role="identifier">n</phrase></code> member variable
- </para>
- </callout>
- <callout arearefs="include.c10" id="include.c11">
- <para>
- Set the <code><phrase role="identifier">n</phrase></code> member variable
- </para>
- </callout>
- </calloutlist>
<para>
[foo]
</para>
Modified: branches/quickbook-dev/tools/quickbook/test/stub.c
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/stub.c (original)
+++ branches/quickbook-dev/tools/quickbook/test/stub.c 2011-10-30 05:29:56 EDT (Sun, 30 Oct 2011)
@@ -7,6 +7,12 @@
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
+/*`
+This should appear when =stub.c= is included.
+
+[foo_c]
+*/
+
/*[foo_c */
/*`
This is the C [*['foo]] function.
Modified: branches/quickbook-dev/tools/quickbook/test/stub.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/stub.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/test/stub.cpp 2011-10-30 05:29:56 EDT (Sun, 30 Oct 2011)
@@ -6,6 +6,9 @@
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
+
+/*` This should appear when =stub.cpp= is included. */
+
#include <string>
//[ bar
Modified: branches/quickbook-dev/tools/quickbook/test/stub.py
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/stub.py (original)
+++ branches/quickbook-dev/tools/quickbook/test/stub.py 2011-10-30 05:29:56 EDT (Sun, 30 Oct 2011)
@@ -4,6 +4,8 @@
# License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
+#` This should appear when =stub.py= is included.
+
#[foo_py
"""`
This is the Python [*['foo]] function.
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