mirror of
https://github.com/boostorg/quickbook.git
synced 2026-01-19 04:22:16 +00:00
Quickbook: Port Rene's sort code inclusion to quickbook-dev.
[SVN r75175]
This commit is contained in:
@@ -1871,11 +1871,16 @@ namespace quickbook
|
||||
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 @@ namespace quickbook
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -329,12 +329,6 @@ namespace quickbook
|
||||
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 @@ namespace quickbook
|
||||
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 @@ namespace quickbook
|
||||
|
||||
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)
|
||||
|
||||
@@ -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>
|
||||
This should appear when <literal>stub.py</literal> is included.
|
||||
</para>
|
||||
<para>
|
||||
This is the Python <emphasis role="bold"><emphasis>foo</emphasis></emphasis>
|
||||
function.
|
||||
This should appear when <literal>stub.cpp</literal> is included.
|
||||
</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.
|
||||
</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>
|
||||
</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>
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user