Update of /cvsroot/boost/boost/tools/quickbook/detail
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv15575/detail

Modified Files:
        actions.cpp post_process.cpp utils.cpp utils.hpp 
Log Message:
added callouts

Index: actions.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/quickbook/detail/actions.cpp,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- actions.cpp 13 Jan 2007 01:48:53 -0000      1.46
+++ actions.cpp 21 Feb 2007 00:48:28 -0000      1.47
@@ -12,6 +12,7 @@
 #include <functional>
 #include <boost/bind.hpp>
 #include <boost/filesystem/convenience.hpp>
+#include <boost/lexical_cast.hpp>
 #include "./actions.hpp"
 #include "./utils.hpp"
 #include "./markups.hpp"
@@ -52,14 +53,14 @@
         }
         else // version 1.3 and above
         {
-            std::string anchor = 
+            std::string anchor =
                 library_id + '.' + qualified_section_id + '.' +
                 detail::make_identifier(str.begin(), str.end());
 
             out << "<anchor id=\"" << anchor << "\"/>"
-                << pre 
+                << pre
                 << "<link linkend=\"" << anchor << "\">"
-                << str 
+                << str
                 << "</link>"
                 << post
                 ;
@@ -68,23 +69,23 @@
 
     void generic_header_action::operator()(iterator first, iterator last) const
     {
-        int level_ = section_level + 2;     // section_level is zero-based. We 
need to use a 
+        int level_ = section_level + 2;     // section_level is zero-based. We 
need to use a
                                             // 0ne-based heading which is one 
greater
                                             // than the current. Thus: 
section_level + 2.
-        if (level_ > 6)                     // The max is h6, clip it if it 
goes 
+        if (level_ > 6)                     // The max is h6, clip it if it 
goes
             level_ = 6;                     // further than that
         std::string str;
         phrase.swap(str);
 
-        std::string anchor = 
+        std::string anchor =
             library_id + '.' + qualified_section_id + '.' +
             detail::make_identifier(str.begin(), str.end());
 
-        out 
+        out
             << "<anchor id=\"" << anchor << "\"/>"
             << "<bridgehead renderas=\"sect" << level_ << "\">"
             << "<link linkend=\"" << anchor << "\">"
-            << str 
+            << str
             << "</link>"
             << "</bridgehead>"
             ;
@@ -282,7 +283,7 @@
         {
             parse(first_, last_, python_p);
         }
-        
+
         std::string str;
         temp.swap(str);
         phrase.swap(save);
@@ -296,7 +297,7 @@
     {
         std::string save;
         out.swap(save);
- 
+
         // print the code with syntax coloring
         if (source_mode == "c++")
         {
@@ -378,8 +379,8 @@
             boost::spirit::file_position const pos = first.get_position();
             detail::outerr(pos.file,pos.line)
                 << "Template Redefinition: " << actions.template_info[0] << 
std::endl;
-        }            
-        
+        }
+
         actions.template_info.push_back(std::string(first, last));
         actions.templates.add(
             actions.template_info[0]
@@ -403,7 +404,7 @@
                     // and push it into the back of template_info. Do this
                     // recursively until we have all the expected number of
                     // arguments, or if there is no more spaces left.
-                    
+
                     std::string& str = template_info.back();
                     std::string::size_type l_pos = str.find_first_of(" 
\t\r\n");
                     if (l_pos == std::string::npos)
@@ -414,7 +415,7 @@
                     str = first;
                     template_info.push_back(second);
                 }
-                
+
                 if (template_.size()-1 != template_info.size())
                 {
                     detail::outerr(pos.file, pos.line)
@@ -423,7 +424,7 @@
                         << " argument(s), got: "
                         << template_info.size()-1
                         << " argument(s) instead."
-                        << std::endl;                    
+                        << std::endl;
                     return false;
                 }
             }
@@ -438,8 +439,8 @@
           , quickbook::actions& actions
         )
         {
-            std::vector<std::string>::const_iterator arg = 
template_info.begin()+1; 
-            std::vector<std::string>::const_iterator tpl = 
template_.begin()+1; 
+            std::vector<std::string>::const_iterator arg = 
template_info.begin()+1;
+            std::vector<std::string>::const_iterator tpl = template_.begin()+1;
 
             // Store each of the argument passed in as local templates:
             while (arg != template_info.end())
@@ -478,7 +479,7 @@
             // a phrase? We apply a simple heuristic: if the body starts with
             // a newline, then we regard it as a block, otherwise, we parse
             // it as a phrase.
-            
+
             std::string::const_iterator iter = body.begin();
             while (iter != body.end() && ((*iter == ' ') || (*iter == '\t')))
                 ++iter; // skip spaces and tabs
@@ -524,20 +525,20 @@
             --actions.template_depth;
             return;
         }
-        
+
         std::string result;
         actions.push(); // scope the actions' states
         {
-            template_symbol const* symbol = 
+            template_symbol const* symbol =
                 actions.templates.find(actions.template_info[0]);
             BOOST_ASSERT(symbol);
-            
+
             std::vector<std::string> template_ = boost::get<0>(*symbol);
             boost::spirit::file_position template_pos = boost::get<1>(*symbol);
 
             std::vector<std::string> template_info;
             std::swap(template_info, actions.template_info);
-            
+
             ///////////////////////////////////
             // Break the arguments
             if (!break_arguments(template_info, template_, pos))
@@ -551,7 +552,7 @@
             // Prepare the arguments as local templates
             bool get_arg_result;
             std::vector<std::string>::const_iterator tpl;
-            boost::tie(get_arg_result, tpl) = 
+            boost::tie(get_arg_result, tpl) =
                 get_arguments(template_info, template_, pos, actions);
 
             if (!get_arg_result)
@@ -668,7 +669,7 @@
         {
             actions.out << "</informaltable>\n";
         }
-                     
+
         actions.table_span = 0;
         actions.table_header.clear();
         actions.table_title.clear();
@@ -693,7 +694,7 @@
 
     void start_col_action::operator()(char) const
     {
-        phrase << start_cell_; 
+        phrase << start_cell_;
         ++span;
     }
 
@@ -711,12 +712,12 @@
 
         if (qbk_version_n < 103) // version 1.2 and below
         {
-            out << "\n<section id=\"" 
+            out << "\n<section id=\""
                 << library_id << "." << section_id << "\">\n";
         }
         else // version 1.3 and above
         {
-            out << "\n<section id=\"" << library_id 
+            out << "\n<section id=\"" << library_id
                 << "." << qualified_section_id << "\">\n";
         }
         std::string str;
@@ -728,10 +729,10 @@
         }
         else // version 1.3 and above
         {
-            out << "<title>" 
+            out << "<title>"
                 << "<link linkend=\"" << library_id
                     << "." << qualified_section_id << "\">"
-                << str 
+                << str
                 << "</link>"
                 << "</title>\n"
                 ;
@@ -757,7 +758,7 @@
         }
         else
         {
-            std::string::size_type const n = 
+            std::string::size_type const n =
                 qualified_section_id.find_last_of('.');
             BOOST_ASSERT(std::string::npos != n);
             qualified_section_id.erase(n, std::string::npos);
@@ -802,12 +803,29 @@
         detail::print_string(detail::escape_uri(path.string()), out.get());
         out << "\" />\n";
     }
-   
+
     void cpp_code_snippet_grammar::pass_thru(iterator first, iterator last) 
const
     {
         code += *first;
     }
 
+    namespace detail
+    {
+        int callout_id = 0;
+    }
+
+    void cpp_code_snippet_grammar::callout(iterator first, iterator last) const
+    {
+        using detail::callout_id;
+        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 += "'''``";
+
+        callouts.push_back(std::string(first, last));
+    }
+
     void cpp_code_snippet_grammar::escaped_comment(iterator first, iterator 
last) const
     {
         if (!code.empty())
@@ -823,17 +841,36 @@
 
     void cpp_code_snippet_grammar::compile(iterator first, iterator last) const
     {
+        using detail::callout_id;
         if (!code.empty())
         {
             detail::unindent(code); // remove all indents
-            snippet += "\n\n``\n" + code + "``\n\n";
+            snippet += "\n\n```\n" + code + "```\n\n";
+
+            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(boost::make_tuple(tinfo, first.get_position()));
 
+        callout_id += callouts.size();
+        callouts.clear();
         code.clear();
         snippet.clear();
         id.clear();
@@ -841,9 +878,10 @@
 
     void load_snippets(
         std::string const& file
-      , std::vector<template_symbol>& storage   // snippets are stored in a 
+      , std::vector<template_symbol>& storage   // snippets are stored in a
                                                 // vector of template_symbols
-      , std::string const& extension)
+      , std::string const& extension
+      , std::string const& doc_id)
     {
         std::string code;
         int err = detail::load(file, code);
@@ -854,7 +892,7 @@
         iterator_type first(code.begin(), code.end(), file);
         iterator_type last(code.end(), code.end());
 
-        cpp_code_snippet_grammar g(storage);
+        cpp_code_snippet_grammar g(storage, doc_id);
         boost::spirit::parse(first, last, g);
     }
 
@@ -871,8 +909,8 @@
 
         std::string ext = fs::extension(path);
         std::vector<template_symbol> storage;
-        load_snippets(path.string(), storage, ext);
-        
+        load_snippets(path.string(), storage, ext, actions.doc_id);
+
         BOOST_FOREACH(template_symbol const& ts, storage)
         {
             std::string tname = boost::get<0>(ts)[0];
@@ -958,7 +996,7 @@
 
     void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo)
     {
-        // The doc_info in the file has been parsed. Here's what we'll do 
+        // The doc_info in the file has been parsed. Here's what we'll do
         // *before* anything else.
 
         if (actions.doc_id.empty())
@@ -975,7 +1013,7 @@
             char strdate[64];
             strftime(
                 strdate, sizeof(strdate),
-                (debug_mode ? 
+                (debug_mode ?
                     "DEBUG MODE Date: %Y/%m/%d %H:%M:%S $" :
                     "$" /* prevent CVS substitution */ "Date: %Y/%m/%d 
%H:%M:%S $"),
                 current_gm_time
@@ -1001,7 +1039,7 @@
         }
         else
         {
-            qbk_version_n = (qbk_major_version * 100) + qbk_minor_version; 
+            qbk_version_n = (qbk_major_version * 100) + qbk_minor_version;
         }
 
         out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"

Index: post_process.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/quickbook/detail/post_process.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- post_process.cpp    19 Dec 2006 13:05:08 -0000      1.30
+++ post_process.cpp    21 Feb 2007 00:48:28 -0000      1.31
@@ -19,13 +19,13 @@
     using namespace boost::spirit;
     using boost::bind;
     typedef std::string::const_iterator iter_type;
-    
+
     struct printer
     {
         printer(std::string& out, int& current_indent, int linewidth)
             : prev(0), out(out), current_indent(current_indent) , column(0)
             , in_string(false), linewidth(linewidth) {}
-                
+
         void indent()
         {
             BOOST_ASSERT(current_indent >= 0); // this should not happen!
@@ -40,7 +40,7 @@
             out += '\n';
             indent();
         }
-        
+
         bool line_is_empty() const
         {
             for (iter_type i = out.end()-(column-current_indent); i != 
out.end(); ++i)
@@ -50,7 +50,7 @@
             }
             return true;
         }
-        
+
         void align_indent()
         {
             // make sure we are at the proper indent position
@@ -73,7 +73,7 @@
                 else
                 {
                     // will this happen? (i.e. column <= current_indent)
-                    while (column != current_indent) 
+                    while (column != current_indent)
                     {
                         out += ' ';
                         ++column;
@@ -86,17 +86,17 @@
         {
             // Print a char. Attempt to break the line if we are exceeding
             // the target linewidth. The linewidth is not an absolute limit.
-            // There are many cases where a line will exceed the linewidth 
+            // There are many cases where a line will exceed the linewidth
             // and there is no way to properly break the line. Preformatted
             // code that exceeds the linewidth are examples. We cannot break
             // preformatted code. We shall not attempt to be very strict with
             // line breaking. What's more important is to have a reproducable
-            // output (i.e. processing two logically equivalent xml files 
-            // results in two lexically equivalent xml files). *** pretty 
+            // output (i.e. processing two logically equivalent xml files
+            // results in two lexically equivalent xml files). *** pretty
             // formatting is a secondary goal ***
 
             // Strings will occur only in tag attributes. Normal content
-            // will have &quot; instead. We shall deal only with tag 
+            // will have &quot; instead. We shall deal only with tag
             // attributes here.
             if (ch == '"')
                 in_string = !in_string; // don't break strings!
@@ -124,11 +124,11 @@
             }
             else
             {
-                // we can break tag boundaries and stuff after 
+                // we can break tag boundaries and stuff after
                 // delimiters if they are not inside strings
                 // and *only-if* the preceding char is a space
-                if (!in_string 
-                    && column >= linewidth 
+                if (!in_string
+                    && column >= linewidth
                     && (ch == '<' && std::isspace(static_cast<unsigned 
char>(prev))))
                     break_line();
                 out += ch;
@@ -138,14 +138,14 @@
             prev = ch;
         }
 
-        void         
+        void
         print(iter_type f, iter_type l)
         {
             for (iter_type i = f; i != l; ++i)
                 print(*i);
         }
 
-        void         
+        void
         print_tag(iter_type f, iter_type l, bool is_flow_tag)
         {
             if (is_flow_tag)
@@ -154,7 +154,7 @@
             }
             else
             {
-                // This is not a flow tag, so, we're going to do a 
+                // This is not a flow tag, so, we're going to do a
                 // carriage return anyway. Let us remove extra right
                 // spaces.
                 std::string str(f, l);
@@ -163,7 +163,7 @@
                 while (i != str.begin() && std::isspace(static_cast<unsigned 
char>(*(i-1))))
                     --i;
                 print(str.begin(), i);
-            }            
+            }
         }
 
         char prev;
@@ -172,9 +172,9 @@
         int column;
         bool in_string;
         int linewidth;
-    };    
+    };
 
-    char const* block_tags_[] = 
+    char const* block_tags_[] =
     {
           "author"
         , "blockquote"
@@ -202,9 +202,11 @@
         , "warning"
         , "xml"
         , "xi:include"
+        , "calloutlist"
+        , "callout"
     };
 
-    char const* doc_types_[] = 
+    char const* doc_types_[] =
     {
           "book"
         , "article"
@@ -238,7 +240,7 @@
                 block_tags.insert(doc_types_[i] + std::string("purpose"));
             }
         }
-        
+
         bool is_flow_tag(std::string const& tag)
         {
             return block_tags.find(tag) == block_tags.end();
@@ -250,8 +252,8 @@
         int current_indent;
         printer printer_;
         std::string current_tag;
-    };    
-    
+    };
+
     struct tidy_grammar : grammar<tidy_grammar>
     {
         tidy_grammar(tidy_compiler& state, int indent)
@@ -273,25 +275,25 @@
                 // What's the business of lexeme_d['>' >> *space_p]; ?
                 // It is there to preserve the space after the tag that is
                 // otherwise consumed by the space_p skipper.
-                
-                escape = 
-                    str_p("<!--quickbook-escape-prefix-->") >> 
+
+                escape =
+                    str_p("<!--quickbook-escape-prefix-->") >>
                     (*(anychar_p - str_p("<!--quickbook-escape-postfix-->")))
                     [
                         bind(&tidy_grammar::do_escape, &self, _1, _2)
                     ]
                     >>  lexeme_d
                         [
-                            str_p("<!--quickbook-escape-postfix-->") >> 
+                            str_p("<!--quickbook-escape-postfix-->") >>
                             (*space_p)
                             [
                                 bind(&tidy_grammar::do_escape_post, &self, _1, 
_2)
                             ]
                         ]
                     ;
-                
+
                 start_tag = '<' >> tag >> *(anychar_p - '>') >> lexeme_d['>' 
>> *space_p];
-                start_end_tag = 
+                start_end_tag =
                         '<' >> tag >> *(anychar_p - ("/>" | ch_p('>'))) >> 
lexeme_d["/>" >> *space_p]
                     |   "<?" >> tag >> *(anychar_p - '?') >> lexeme_d["?>" >> 
*space_p]
                     |   "<!--" >> *(anychar_p - "-->") >> lexeme_d["-->" >> 
*space_p]
@@ -300,7 +302,7 @@
                 content = lexeme_d[ +(anychar_p - '<') ];
                 end_tag = "</" >> +(anychar_p - '>') >> lexeme_d['>' >> 
*space_p];
 
-                markup = 
+                markup =
                         escape
                     |   code            [bind(&tidy_grammar::do_code, &self, 
_1, _2)]
                     |   start_end_tag   [bind(&tidy_grammar::do_start_end_tag, 
&self, _1, _2)]
@@ -336,7 +338,7 @@
         void do_code(iter_type f, iter_type l) const
         {
             state.out += '\n';
-            // print the string taking care of line 
+            // print the string taking care of line
             // ending CR/LF platform issues
             for (iter_type i = f; i != l; ++i)
             {
@@ -380,7 +382,7 @@
 
         void do_start_tag(iter_type f, iter_type l) const
         {
-            state.tags.push(state.current_tag);                     
+            state.tags.push(state.current_tag);
             bool is_flow_tag = state.is_flow_tag(state.current_tag);
             if (!is_flow_tag)
                 state.printer_.align_indent();
@@ -408,9 +410,9 @@
             state.printer_.print_tag(f, l, is_flow_tag);
             if (!is_flow_tag)
                 state.printer_.break_line();
-            state.tags.pop();                     
+            state.tags.pop();
         }
-        
+
         tidy_compiler& state;
         int indent;
     };
@@ -440,17 +442,17 @@
             {
                 // fallback!
                 ::quickbook::detail::outerr("",0)
-                    << "Warning: Post Processing Failed." 
+                    << "Warning: Post Processing Failed."
                     << std::endl;
-                out << in;                
+                out << in;
             }
         }
-        
+
         catch(...)
         {
             // fallback!
             ::quickbook::detail::outerr("",0)
-                << "Warning: Post Processing Failed." 
+                << "Warning: Post Processing Failed."
                 << std::endl;
             out << in;
         }

Index: utils.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/quickbook/detail/utils.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- utils.cpp   13 Jan 2007 01:48:54 -0000      1.13
+++ utils.cpp   21 Feb 2007 00:48:28 -0000      1.14
@@ -31,7 +31,7 @@
             case '&': out << "&amp;";   break;
             case '"': out << "&quot;";  break;
             default:  out << ch;        break;
-            // note &apos; is not included. see the curse of apos: 
+            // note &apos; is not included. see the curse of apos:
             // http://fishbowl.pastiche.org/2003/07/01/the_curse_of_apos
         }
     }
@@ -133,7 +133,7 @@
         }
         return uri;
     }
-    
+
     std::ostream& outerr(std::string const& file, int line)
     {
         if (line >= 0)
@@ -148,7 +148,7 @@
             return std::clog << file << ": error: ";
         }
     }
-    
+
     std::ostream& outwarn(std::string const& file, int line)
     {
         if (line >= 0)

Index: utils.hpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/quickbook/detail/utils.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- utils.hpp   20 Dec 2006 15:41:20 -0000      1.8
+++ utils.hpp   21 Feb 2007 00:48:28 -0000      1.9
@@ -56,9 +56,9 @@
 
     // remove the extension from a filename
     std::string remove_extension(std::string const& filename);
-    
+
     std::string escape_uri(std::string uri);
-    
+
     // Preformats an error/warning message so that it can be parsed by
     // common IDEs. Uses the ms_errors global to determine if VS format
     // or GCC format. Returns the stream to continue ouput of the verbose
@@ -67,18 +67,18 @@
     std::ostream & outwarn(std::string const& file, int line);
 
     // load file into memory with extra trailing newlines to eliminate
-    //  the need to check for end of file in the grammar. 
+    //  the need to check for end of file in the grammar.
     int load(std::string const& filename, std::string& storage);
-    
+
     // given a file extension, return the type of the source file
     // we'll have an internal database for known file types.
-    
+
     enum file_type
     {
         cpp_file
       , python_file
     };
-    
+
     file_type get_file_type(std::string const& extension);
 }}
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs

Reply via email to