$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r70207 - in trunk/tools/quickbook: . doc src test test/snippets
From: dnljms_at_[hidden]
Date: 2011-03-19 15:22:46
Author: danieljames
Date: 2011-03-19 15:22:45 EDT (Sat, 19 Mar 2011)
New Revision: 70207
URL: http://svn.boost.org/trac/boost/changeset/70207
Log:
Quickbook: pass-thru comments.
Added:
   trunk/tools/quickbook/test/snippets/
      - copied from r70018, /branches/quickbook-filenames/tools/quickbook/test/snippets/
   trunk/tools/quickbook/test/snippets/Jamfile.v2
      - copied unchanged from r70018, /branches/quickbook-filenames/tools/quickbook/test/snippets/Jamfile.v2
   trunk/tools/quickbook/test/snippets/pass_thru.cpp
      - copied unchanged from r70018, /branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.cpp
   trunk/tools/quickbook/test/snippets/pass_thru.gold
      - copied unchanged from r70018, /branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.gold
   trunk/tools/quickbook/test/snippets/pass_thru.py
      - copied unchanged from r70018, /branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.py
   trunk/tools/quickbook/test/snippets/pass_thru.quickbook
      - copied unchanged from r70018, /branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.quickbook
   trunk/tools/quickbook/test/snippets/pass_thru.xml
      - copied unchanged from r70018, /branches/quickbook-filenames/tools/quickbook/test/snippets/pass_thru.xml
Properties modified: 
   trunk/tools/quickbook/   (props changed)
Text files modified: 
   trunk/tools/quickbook/doc/quickbook.qbk    |    13 +++++++++++++                           
   trunk/tools/quickbook/src/code_snippet.cpp |    36 +++++++++++++++++++++++++++++++++---    
   trunk/tools/quickbook/test/Jamfile.v2      |     1 +                                       
   3 files changed, 47 insertions(+), 3 deletions(-)
Modified: trunk/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- trunk/tools/quickbook/doc/quickbook.qbk	(original)
+++ trunk/tools/quickbook/doc/quickbook.qbk	2011-03-19 15:22:45 EDT (Sat, 19 Mar 2011)
@@ -283,6 +283,7 @@
 * Allow more block elements to be nested.
 * Go back to using invalid markup for lists. It generates better html.
 * Better anchor placement for lists.
+* Pass-thru comments in code snippets.
 * Quickbook 1.6:
   * Scope source mode changes to the file they're made in.
 
@@ -1937,6 +1938,18 @@
 can be used to inhibit code from passing through to quickbook. All text between
 the delimeters will simply be ignored.
 
+Comments of this form:
+
+    //=int main() {}
+
+or
+
+    /*=foo()*/
+
+will be displayed as code that isn't in comments. This allows you to
+include some code in the snippet but not actually use it when
+compiling your example.
+
 [heading Callouts]
 
 Special comments of the form:
Modified: trunk/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- trunk/tools/quickbook/src/code_snippet.cpp	(original)
+++ trunk/tools/quickbook/src/code_snippet.cpp	2011-03-19 15:22:45 EDT (Sat, 19 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: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2	(original)
+++ trunk/tools/quickbook/test/Jamfile.v2	2011-03-19 15:22:45 EDT (Sat, 19 Mar 2011)
@@ -14,6 +14,7 @@
 build-project doc-info ;
 build-project unit ;
 build-project command-line ;
+build-project snippets ;
 
 import quickbook-testing : quickbook-test quickbook-error-test ;