Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59315 - in branches/quickbook-1.5-spirit2: . detail
From: daniel_james_at_[hidden]
Date: 2010-01-27 17:04:57


Author: danieljames
Date: 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
New Revision: 59315
URL: http://svn.boost.org/trac/boost/changeset/59315

Log:
Move the code snippet stuff into its own files.
Added:
   branches/quickbook-1.5-spirit2/code_snippet.cpp (contents, props changed)
   branches/quickbook-1.5-spirit2/code_snippet_types.hpp (contents, props changed)
Text files modified:
   branches/quickbook-1.5-spirit2/Jamfile.v2 | 1
   branches/quickbook-1.5-spirit2/block_actions.cpp | 3
   branches/quickbook-1.5-spirit2/code_snippet.hpp | 1
   branches/quickbook-1.5-spirit2/detail/actions.cpp | 102 ----------------------------------------
   branches/quickbook-1.5-spirit2/detail/actions.hpp | 26 ----------
   5 files changed, 4 insertions(+), 129 deletions(-)

Modified: branches/quickbook-1.5-spirit2/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/Jamfile.v2 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
@@ -36,6 +36,7 @@
     block_actions.cpp
     block_list.cpp
     doc_info.cpp
+ code_snippet.cpp
     detail/syntax_highlight.cpp
     /boost//program_options
     /boost//filesystem

Modified: branches/quickbook-1.5-spirit2/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.cpp 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
@@ -12,7 +12,8 @@
 #include "./detail/actions_class.hpp"
 #include "./detail/markups.hpp"
 #include "./detail/quickbook.hpp"
-#include "./code_snippet.hpp"
+#include "./grammars.hpp"
+#include "./code_snippet_types.hpp"
 #include <numeric>
 #include <boost/assert.hpp>
 #include <boost/filesystem/convenience.hpp>

Added: branches/quickbook-1.5-spirit2/code_snippet.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/code_snippet.cpp 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
@@ -0,0 +1,126 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ Copyright (c) 2005 Thomas Guest
+ Copyright (c) 2010 Daniel James
+ 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)
+=============================================================================*/
+
+#include <numeric>
+#include <functional>
+#include <algorithm>
+#include <iterator>
+#include <boost/lexical_cast.hpp>
+#include "./detail/utils.hpp"
+#include "./detail/markups.hpp"
+#include "./detail/actions_class.hpp"
+#include "./grammars.hpp"
+#include "./code_snippet.hpp"
+
+namespace quickbook
+{
+ void code_snippet_actions::pass_thru(char x)
+ {
+ code += x;
+ }
+
+ namespace detail
+ {
+ int callout_id = 0;
+ }
+
+ void code_snippet_actions::callout(std::string const& x, char const* role)
+ {
+ using detail::callout_id;
+ code += "``'''";
+ code += std::string("<phrase role=\"") + role + "\">";
+ code += "<co id=\"";
+ code += doc_id + boost::lexical_cast<std::string>(callout_id + callouts.size()) + "co\" ";
+ code += "linkends=\"";
+ code += doc_id + boost::lexical_cast<std::string>(callout_id + callouts.size()) + "\" />";
+ code += "</phrase>";
+ code += "'''``";
+
+ callouts.push_back(x);
+ }
+
+ void code_snippet_actions::inline_callout(std::string const& x)
+ {
+ callout(x, "callout_bug");
+ }
+
+ void code_snippet_actions::line_callout(std::string const& x)
+ {
+ callout(x, "line_callout_bug");
+ }
+
+ void code_snippet_actions::escaped_comment(std::string const& x)
+ {
+ if (!code.empty())
+ {
+ detail::unindent(code); // remove all indents
+ if (code.size() != 0)
+ {
+ snippet += "\n\n";
+ snippet += source_type;
+ snippet += "``\n" + code + "``\n\n";
+ code.clear();
+ }
+ }
+ std::string temp(x);
+ detail::unindent(temp); // remove all indents
+ if (temp.size() != 0)
+ {
+ snippet += "\n" + temp; // add a linebreak to allow block marskups
+ }
+ }
+
+ void code_snippet_actions::compile(boost::iterator_range<iterator> x)
+ {
+ using detail::callout_id;
+ if (!code.empty())
+ {
+ detail::unindent(code); // remove all indents
+ if (code.size() != 0)
+ {
+ snippet += "\n\n";
+ snippet += source_type;
+ snippet += "```\n" + code + "```\n\n";
+ }
+
+ if(callouts.size() > 0)
+ {
+ snippet += "'''<calloutlist>'''";
+ for (size_t i = 0; i < callouts.size(); ++i)
+ {
+ snippet += "'''<callout arearefs=\"";
+ snippet += doc_id + boost::lexical_cast<std::string>(callout_id + i) + "co\" ";
+ snippet += "id=\"";
+ snippet += doc_id + boost::lexical_cast<std::string>(callout_id + i) + "\">";
+ snippet += "'''";
+
+ snippet += "'''<para>'''";
+ snippet += callouts[i];
+ snippet += "'''</para>'''";
+ snippet += "'''</callout>'''";
+ }
+ snippet += "'''</calloutlist>'''";
+ }
+ }
+
+ std::vector<std::string> tinfo;
+ tinfo.push_back(id);
+ tinfo.push_back(snippet);
+ storage.push_back(template_symbol(tinfo, x.begin().get_position()));
+
+ callout_id += callouts.size();
+ callouts.clear();
+ code.clear();
+ snippet.clear();
+ id.clear();
+ }
+}

Modified: branches/quickbook-1.5-spirit2/code_snippet.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet.hpp (original)
+++ branches/quickbook-1.5-spirit2/code_snippet.hpp 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
@@ -14,6 +14,7 @@
 #include <boost/spirit/include/phoenix_core.hpp>
 #include <boost/spirit/include/phoenix_bind.hpp>
 #include <boost/spirit/include/phoenix_operator.hpp>
+#include "./code_snippet_types.hpp"
 #include "./grammars.hpp"
 #include "./parse_utils.hpp"
 #include "./detail/actions.hpp"

Added: branches/quickbook-1.5-spirit2/code_snippet_types.hpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/code_snippet_types.hpp 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
@@ -0,0 +1,48 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ Copyright (c) 2005 Thomas Guest
+ Copyright (c) 2010 Daniel James
+ 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)
+=============================================================================*/
+#if !defined(BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_TYPES_HPP)
+#define BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_TYPES_HPP
+
+#include <vector>
+#include <string>
+#include "./detail/actions.hpp"
+
+namespace quickbook
+{
+ struct code_snippet_actions
+ {
+ code_snippet_actions(std::vector<template_symbol>& storage,
+ std::string const& doc_id,
+ char const* source_type)
+ : storage(storage)
+ , doc_id(doc_id)
+ , source_type(source_type)
+ {}
+
+ void pass_thru(char);
+ void escaped_comment(std::string const&);
+ void compile(boost::iterator_range<iterator>);
+ void callout(std::string const&, char const* role);
+ void inline_callout(std::string const&);
+ void line_callout(std::string const&);
+
+ std::string code;
+ std::string snippet;
+ std::string id;
+ std::vector<std::string> callouts;
+ std::vector<template_symbol>& storage;
+ std::string const doc_id;
+ char const* const source_type;
+ };
+}
+
+#endif
\ No newline at end of file

Modified: branches/quickbook-1.5-spirit2/detail/actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/detail/actions.cpp 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
@@ -14,7 +14,6 @@
 #include <iterator>
 #include <boost/filesystem/convenience.hpp>
 #include <boost/filesystem/fstream.hpp>
-#include <boost/lexical_cast.hpp>
 #include <boost/spirit/include/support_unused.hpp>
 #include "./quickbook.hpp"
 #include "./actions.hpp"
@@ -69,107 +68,6 @@
         detail::outwarn(pos.file,pos.line) << "Empty id.\n";
     }
 
- void code_snippet_actions::pass_thru(char x)
- {
- code += x;
- }
-
- namespace detail
- {
- int callout_id = 0;
- }
-
- void code_snippet_actions::callout(std::string const& x, char const* role)
- {
- using detail::callout_id;
- code += "``'''";
- code += std::string("<phrase role=\"") + role + "\">";
- code += "<co id=\"";
- code += doc_id + boost::lexical_cast<std::string>(callout_id + callouts.size()) + "co\" ";
- code += "linkends=\"";
- code += doc_id + boost::lexical_cast<std::string>(callout_id + callouts.size()) + "\" />";
- code += "</phrase>";
- code += "'''``";
-
- callouts.push_back(x);
- }
-
- void code_snippet_actions::inline_callout(std::string const& x)
- {
- callout(x, "callout_bug");
- }
-
- void code_snippet_actions::line_callout(std::string const& x)
- {
- callout(x, "line_callout_bug");
- }
-
- void code_snippet_actions::escaped_comment(std::string const& x)
- {
- if (!code.empty())
- {
- detail::unindent(code); // remove all indents
- if (code.size() != 0)
- {
- snippet += "\n\n";
- snippet += source_type;
- snippet += "``\n" + code + "``\n\n";
- code.clear();
- }
- }
- std::string temp(x);
- detail::unindent(temp); // remove all indents
- if (temp.size() != 0)
- {
- snippet += "\n" + temp; // add a linebreak to allow block marskups
- }
- }
-
- void code_snippet_actions::compile(boost::iterator_range<iterator> x)
- {
- using detail::callout_id;
- if (!code.empty())
- {
- detail::unindent(code); // remove all indents
- if (code.size() != 0)
- {
- snippet += "\n\n";
- snippet += source_type;
- snippet += "```\n" + code + "```\n\n";
- }
-
- if(callouts.size() > 0)
- {
- snippet += "'''<calloutlist>'''";
- for (size_t i = 0; i < callouts.size(); ++i)
- {
- snippet += "'''<callout arearefs=\"";
- snippet += doc_id + boost::lexical_cast<std::string>(callout_id + i) + "co\" ";
- snippet += "id=\"";
- snippet += doc_id + boost::lexical_cast<std::string>(callout_id + i) + "\">";
- snippet += "'''";
-
- snippet += "'''<para>'''";
- snippet += callouts[i];
- snippet += "'''</para>'''";
- snippet += "'''</callout>'''";
- }
- snippet += "'''</calloutlist>'''";
- }
- }
-
- std::vector<std::string> tinfo;
- tinfo.push_back(id);
- tinfo.push_back(snippet);
- storage.push_back(template_symbol(tinfo, x.begin().get_position()));
-
- callout_id += callouts.size();
- callouts.clear();
- code.clear();
- snippet.clear();
- id.clear();
- }
-
     void xml_author::operator()(std::pair<std::string, std::string> const& author) const
     {
         out << " <author>\n"

Modified: branches/quickbook-1.5-spirit2/detail/actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/detail/actions.hpp 2010-01-27 17:04:56 EST (Wed, 27 Jan 2010)
@@ -180,32 +180,6 @@
     void pre(collector& out, quickbook::actions& actions, doc_info& info, bool ignore_docinfo = false);
     void post(collector& out, quickbook::actions& actions, doc_info& info, bool ignore_docinfo = false);
 
- struct code_snippet_actions
- {
- code_snippet_actions(std::vector<template_symbol>& storage,
- std::string const& doc_id,
- char const* source_type)
- : storage(storage)
- , doc_id(doc_id)
- , source_type(source_type)
- {}
-
- void pass_thru(char);
- void escaped_comment(std::string const&);
- void compile(boost::iterator_range<iterator>);
- void callout(std::string const&, char const* role);
- void inline_callout(std::string const&);
- void line_callout(std::string const&);
-
- std::string code;
- std::string snippet;
- std::string id;
- std::vector<std::string> callouts;
- std::vector<template_symbol>& storage;
- std::string const doc_id;
- char const* const source_type;
- };
-
     struct process_action
     {
         process_action(quickbook::actions& actions)


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