|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70018 - in branches/quickbook-filenames/tools/quickbook: src test test/snippets
From: dnljms_at_[hidden]
Date: 2011-03-16 05:12:09
Author: danieljames
Date: 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
New Revision: 70018
URL: http://svn.boost.org/trac/boost/changeset/70018
Log:
Pass-thru comments.
Added:
branches/quickbook-filenames/tools/quickbook/test/snippets/
branches/quickbook-filenames/tools/quickbook/test/snippets/Jamfile.v2 (contents, props changed)
branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.cpp (contents, props changed)
branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.gold (contents, props changed)
branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.py (contents, props changed)
branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.quickbook (contents, props changed)
branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.xml (contents, props changed)
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp | 36 +++++++++++++++++++++++++++++++++---
branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 | 1 +
2 files changed, 34 insertions(+), 3 deletions(-)
Modified: branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -99,6 +99,7 @@
start_snippet [boost::bind(&actions_type::start_snippet, &actions, _1, _2)]
| end_snippet [boost::bind(&actions_type::end_snippet, &actions, _1, _2)]
| escaped_comment
+ | pass_thru_comment
| ignore
| cl::anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)]
;
@@ -142,11 +143,25 @@
"\"\"\""
)
;
+
+ // Note: Unlike escaped_comment and ignore, this doesn't
+ // swallow preceeding whitespace.
+ pass_thru_comment
+ = "#="
+ >> ( *(cl::anychar_p - cl::eol_p)
+ >> (cl::eol_p | cl::end_p)
+ ) [boost::bind(&actions_type::pass_thru, &actions, _1, _2)]
+ | cl::confix_p(
+ "\"\"\"=",
+ (*cl::anychar_p) [boost::bind(&actions_type::pass_thru, &actions, _1, _2)],
+ "\"\"\""
+ )
+ ;
}
cl::rule<Scanner>
start_, identifier, code_elements, start_snippet, end_snippet,
- escaped_comment, ignore;
+ escaped_comment, pass_thru_comment, ignore;
cl::rule<Scanner> const&
start() const { return start_; }
@@ -182,6 +197,7 @@
| end_snippet [boost::bind(&actions_type::end_snippet, &actions, _1, _2)]
| escaped_comment
| ignore
+ | pass_thru_comment
| line_callout
| inline_callout
| cl::anychar_p [boost::bind(&actions_type::pass_thru_char, &actions, _1)]
@@ -249,11 +265,25 @@
"*/"
)
;
+
+ // Note: Unlike escaped_comment and ignore, this doesn't
+ // swallow preceeding whitespace.
+ pass_thru_comment
+ = "//="
+ >> ( *(cl::anychar_p - cl::eol_p)
+ >> (cl::eol_p | cl::end_p)
+ ) [boost::bind(&actions_type::pass_thru, &actions, _1, _2)]
+ | cl::confix_p(
+ "/*`",
+ (*cl::anychar_p) [boost::bind(&actions_type::pass_thru, &actions, _1, _2)],
+ "*/"
+ )
+ ;
}
cl::rule<Scanner>
start_, identifier, code_elements, start_snippet, end_snippet,
- escaped_comment, inline_callout, line_callout, ignore;
+ escaped_comment, pass_thru_comment, inline_callout, line_callout, ignore;
cl::rule<Scanner> const&
start() const { return start_; }
@@ -334,7 +364,7 @@
void code_snippet_actions::pass_thru(iterator first, iterator last)
{
if(snippet_stack.empty()) return;
- code += *first;
+ code.append(first, last);
}
void code_snippet_actions::pass_thru_char(char c)
Modified: branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/quickbook-filenames/tools/quickbook/test/Jamfile.v2 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -15,6 +15,7 @@
build-project doc-info ;
build-project command-line ;
+build-project snippets ;
import quickbook-testing : quickbook-test quickbook-error-test ;
Added: branches/quickbook-filenames/tools/quickbook/test/snippets/Jamfile.v2
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/snippets/Jamfile.v2 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -0,0 +1,15 @@
+#
+# Copyright (c) 2011 Daniel James
+#
+# Distributed under 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)
+#
+
+project quickook/tests/snippets ;
+
+import quickbook-testing : quickbook-test quickbook-error-test ;
+
+test-suite quickbook.test :
+ [ quickbook-test pass_thru ]
+ ;
Added: branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.cpp 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -0,0 +1,14 @@
+//[foo_cpp
+struct Foo{
+
+ Foo()//=;
+//<-
+ : x( 10 )
+ {}
+//->
+
+//<-
+ int x;
+//->
+};
+//]
\ No newline at end of file
Added: branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.gold 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="pass_thru_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Pass thru test</title>
+ <para>
+
+<programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">Foo</phrase><phrase role="special">{</phrase>
+
+ <phrase role="identifier">Foo</phrase><phrase role="special">();</phrase>
+
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">def</phrase> <phrase role="identifier">foo</phrase><phrase role="special">:</phrase>
+ <phrase role="keyword">print</phrase><phrase role="special">(</phrase><phrase role="string">'foo'</phrase><phrase role="special">)</phrase>
+</programlisting>
+ </para>
+</article>
Added: branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.py
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.py 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -0,0 +1,7 @@
+#[foo_py
+def foo:
+ #=print('foo')
+ #<-
+ print('bar')
+ #->
+#]
\ No newline at end of file
Added: branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.quickbook 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -0,0 +1,10 @@
+[article Pass thru test
+[quickbook 1.5]
+]
+
+[import pass_thru.cpp]
+[import pass_thru.py]
+
+[foo_cpp]
+
+[foo_py]
\ No newline at end of file
Added: branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.xml
==============================================================================
--- (empty file)
+++ branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.xml 2011-03-16 05:12:01 EDT (Wed, 16 Mar 2011)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<article id="pass_thru_test" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Pass thru test</title>
+ <para>
+
+<programlisting><phrase role="keyword">struct</phrase> <phrase role="identifier">Foo</phrase><phrase role="special">{</phrase>
+
+ <phrase role="identifier">Foo</phrase><phrase role="special">()//=;</phrase>
+
+<phrase role="special">};</phrase>
+</programlisting>
+ </para>
+ <para>
+
+<programlisting><phrase role="keyword">def</phrase> <phrase role="identifier">foo</phrase><phrase role="special">:</phrase>
+ <phrase role="comment">#= print('foo')
+</phrase></programlisting>
+ </para>
+</article>
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