Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61065 - in branches/release/tools/quickbook: . detail doc test
From: daniel_james_at_[hidden]
Date: 2010-04-05 05:03:31


Author: danieljames
Date: 2010-04-05 05:03:29 EDT (Mon, 05 Apr 2010)
New Revision: 61065
URL: http://svn.boost.org/trac/boost/changeset/61065

Log:
Merge quickbook

 - Define macros at the command line.
 - Some inspect fixes.

Properties modified:
   branches/release/tools/quickbook/ (props changed)
Text files modified:
   branches/release/tools/quickbook/detail/actions.hpp | 9 ++-
   branches/release/tools/quickbook/detail/quickbook.cpp | 96 +++++++++++++++++++++++++++++++++++++--
   branches/release/tools/quickbook/doc/Jamfile.v2 | 10 ++++
   branches/release/tools/quickbook/index.html | 5 ++
   branches/release/tools/quickbook/test/callouts.cpp | 5 ++
   5 files changed, 114 insertions(+), 11 deletions(-)

Modified: branches/release/tools/quickbook/detail/actions.hpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions.hpp (original)
+++ branches/release/tools/quickbook/detail/actions.hpp 2010-04-05 05:03:29 EDT (Mon, 05 Apr 2010)
@@ -43,6 +43,7 @@
     extern tm* current_gm_time; // the current UTC time
     extern bool debug_mode;
     extern std::vector<std::string> include_path;
+ extern std::vector<std::string> preset_defines;
 
     // forward declarations
     struct actions;
@@ -370,10 +371,10 @@
     
     struct escape_unicode_action
     {
- escape_unicode_action(collector& phrase) : phrase(phrase) {}
- void operator()(iterator first, iterator last) const;
-
- collector& phrase;
+ escape_unicode_action(collector& phrase) : phrase(phrase) {}
+ void operator()(iterator first, iterator last) const;
+
+ collector& phrase;
     };
 
     struct attribute_action

Modified: branches/release/tools/quickbook/detail/quickbook.cpp
==============================================================================
--- branches/release/tools/quickbook/detail/quickbook.cpp (original)
+++ branches/release/tools/quickbook/detail/quickbook.cpp 2010-04-05 05:03:29 EDT (Mon, 05 Apr 2010)
@@ -43,6 +43,79 @@
     unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
     bool ms_errors = false; // output errors/warnings as if for VS
     std::vector<std::string> include_path;
+ std::vector<std::string> preset_defines;
+
+ ///////////////////////////////////////////////////////////////////////////
+ //
+ // Parse the macros passed as command line parameters
+ //
+ ///////////////////////////////////////////////////////////////////////////
+ template <typename Actions>
+ struct command_line_grammar
+ : public grammar<command_line_grammar<Actions> >
+ {
+ command_line_grammar(Actions& actions)
+ : actions(actions) {}
+
+ template <typename Scanner>
+ struct definition
+ {
+ definition(command_line_grammar const& self)
+ : unused(false), common(self.actions, unused)
+ {
+ Actions& actions = self.actions;
+
+ macro =
+ *space_p
+ >> macro_identifier [actions.macro_identifier]
+ >> *space_p
+ >> ( '='
+ >> *space_p
+ >> phrase [actions.macro_definition]
+ >> *space_p
+ )
+ | eps_p [actions.macro_definition]
+ ;
+
+ macro_identifier =
+ +(anychar_p - (space_p | ']'))
+ ;
+
+ phrase =
+ *( common
+ | (anychar_p - ']') [actions.plain_char]
+ )
+ ;
+ }
+
+ bool unused;
+ rule<Scanner> macro, macro_identifier, phrase;
+ phrase_grammar<Actions> common;
+
+ rule<Scanner> const&
+ start() const { return macro; }
+ };
+
+ Actions& actions;
+ };
+
+ static void set_macros(actions& actor)
+ {
+ quickbook::command_line_grammar<actions> grammar(actor);
+
+ for(std::vector<std::string>::const_iterator
+ it = preset_defines.begin(),
+ end = preset_defines.end();
+ it != end; ++it)
+ {
+ typedef position_iterator<std::string::const_iterator> iterator_type;
+ iterator_type first(it->begin(), it->end(), "command line parameter");
+ iterator_type last(it->end(), it->end());
+
+ parse(first, last, grammar);
+ // TODO: Check result?
+ }
+ }
 
     ///////////////////////////////////////////////////////////////////////////
     //
@@ -89,12 +162,6 @@
                 << "Syntax Error near column " << pos.column << ".\n";
             ++actor.error_count;
         }
-
- if(actor.error_count)
- {
- detail::outerr(filein_)
- << "Error count: " << actor.error_count << ".\n";
- }
 
         return actor.error_count ? 1 : 0;
     }
@@ -103,11 +170,19 @@
     parse(char const* filein_, fs::path const& outdir, string_stream& out, bool ignore_docinfo = false)
     {
         actions actor(filein_, outdir, out);
+ set_macros(actor);
         bool r = parse(filein_, actor);
         if (actor.section_level != 0)
             detail::outwarn(filein_)
                 << "Warning missing [endsect] detected at end of file."
                 << std::endl;
+
+ if(actor.error_count)
+ {
+ detail::outerr(filein_)
+ << "Error count: " << actor.error_count << ".\n";
+ }
+
         return r;
     }
 
@@ -177,6 +252,7 @@
             ("debug", "debug mode (for developers)")
             ("ms-errors", "use Microsoft Visual Studio style error & warn message format")
             ("include-path,I", value< std::vector<quickbook::detail::input_path> >(), "include path")
+ ("define,D", value< std::vector<std::string> >(), "define macro")
         ;
 
         positional_options_description p;
@@ -247,6 +323,12 @@
                 = std::vector<std::string>(paths.begin(), paths.end());
         }
 
+ if (vm.count("define"))
+ {
+ quickbook::preset_defines
+ = vm["define"].as<std::vector<std::string> >();
+ }
+
         if (vm.count("input-file"))
         {
             std::string filein
@@ -274,7 +356,7 @@
             quickbook::detail::outerr("") << "Error: No filename given\n\n"
                 << desc << std::endl;
             return 1;
- }
+ }
     }
 
     catch(std::exception& e)

Modified: branches/release/tools/quickbook/doc/Jamfile.v2
==============================================================================
--- branches/release/tools/quickbook/doc/Jamfile.v2 (original)
+++ branches/release/tools/quickbook/doc/Jamfile.v2 2010-04-05 05:03:29 EDT (Mon, 05 Apr 2010)
@@ -1,3 +1,13 @@
+#==============================================================================
+# Copyright (c) 2002 2004 2006 Joel de Guzman
+# Copyright (c) 2004 Eric Niebler
+# 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)
+#==============================================================================
+
 project boost/quickbook/doc ;
 
 import boostbook : boostbook ;

Modified: branches/release/tools/quickbook/index.html
==============================================================================
--- branches/release/tools/quickbook/index.html (original)
+++ branches/release/tools/quickbook/index.html 2010-04-05 05:03:29 EDT (Mon, 05 Apr 2010)
@@ -6,5 +6,10 @@
   <body>
     Automatic redirection failed, click this
     <a href="../../doc/html/quickbook.html">link</a>
+ <p>Copyright&nbsp;Eric Niebler 2005</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ LICENSE_1_0.txt or copy at
+ www.boost.org/LICENSE_1_0.txt).
+ </p>
   </body>
 </html>

Modified: branches/release/tools/quickbook/test/callouts.cpp
==============================================================================
--- branches/release/tools/quickbook/test/callouts.cpp (original)
+++ branches/release/tools/quickbook/test/callouts.cpp 2010-04-05 05:03:29 EDT (Mon, 05 Apr 2010)
@@ -1,3 +1,8 @@
+
+// Copyright 2009 Daniel James.
+// Distributed under the Boost Software License, Version 1.0. (See accompanying
+// file LICENSE_1_0.txt or move at http://www.boost.org/LICENSE_1_0.txt)
+
 //[ example1
 
 /*`


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