Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75897 - in branches/quickbook-dev/tools/quickbook: doc src test
From: dnljms_at_[hidden]
Date: 2011-12-11 06:16:07


Author: danieljames
Date: 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
New Revision: 75897
URL: http://svn.boost.org/trac/boost/changeset/75897

Log:
Quickbook: Code block callouts.
Added:
   branches/quickbook-dev/tools/quickbook/test/callouts-1_7.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/callouts-1_7.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/doc/1_6.qbk | 9 ++
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 171 ++++++++++++++++++++++-----------------
   branches/quickbook-dev/tools/quickbook/src/actions.hpp | 3
   branches/quickbook-dev/tools/quickbook/src/actions_class.cpp | 2
   branches/quickbook-dev/tools/quickbook/src/actions_class.hpp | 6 +
   branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp | 83 ++-----------------
   branches/quickbook-dev/tools/quickbook/src/files.cpp | 5
   branches/quickbook-dev/tools/quickbook/src/files.hpp | 9 +
   branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp | 66 +++++++++++++-
   branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 | 1
   10 files changed, 195 insertions(+), 160 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/doc/1_6.qbk
==============================================================================
--- branches/quickbook-dev/tools/quickbook/doc/1_6.qbk (original)
+++ branches/quickbook-dev/tools/quickbook/doc/1_6.qbk 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -330,4 +330,13 @@
 
 [endsect]
 
+[section:callouts Callouts in code block]
+
+Currently callouts can only be used in code snippets. 1.7 add
+support in normal code blocks. The same syntax is used as in
+code snippets, the callout descriptions appear immediately
+after the code block.
+
+[endsect]
+
 [endsect] [/ Quickbok 1.7]

Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -536,6 +536,83 @@
         out << "</simpara></listitem>";
     }
 
+ namespace
+ {
+ bool parse_template(value const&, quickbook::actions& actions);
+ }
+
+ void actions::start_callouts()
+ {
+ ++callout_depth;
+ }
+
+ std::string actions::add_callout(value v)
+ {
+ std::string callout_id1 = ids.add_id("c", id_category::numbered);
+ std::string callout_id2 = ids.add_id("c", id_category::numbered);
+
+ callouts.insert(encoded_value(callout_id1));
+ callouts.insert(encoded_value(callout_id2));
+ callouts.insert(v);
+
+ std::string code;
+ code += "<co id=\"" + callout_id1 + "\" ";
+ code += "linkends=\"" + callout_id2 + "\" />";
+
+ return code;
+ }
+
+ std::string actions::end_callouts()
+ {
+ assert(callout_depth > 0);
+ std::string block;
+
+ --callout_depth;
+ if (callout_depth > 0) return block;
+
+ value_consumer c = callouts.release();
+ if (!c.check()) return block;
+
+ block += "<calloutlist>";
+ while (c.check())
+ {
+ std::string callout_id1 = c.consume().get_encoded();
+ std::string callout_id2 = c.consume().get_encoded();
+ value callout_body = c.consume();
+
+ std::string callout_value;
+
+ {
+ template_state state(*this);
+ ++template_depth;
+
+ bool r = parse_template(callout_body, *this);
+
+ if(!r)
+ {
+ detail::outerr(callout_body.get_file(), callout_body.get_position())
+ << "Expanding callout." << std::endl
+ << "------------------begin------------------" << std::endl
+ << detail::utf8(callout_body.get_quickbook())
+ << std::endl
+ << "------------------end--------------------" << std::endl
+ ;
+ ++error_count;
+ }
+
+ out.swap(callout_value);
+ }
+
+ block += "<callout arearefs=\"" + callout_id1 + "\" ";
+ block += "id=\"" + callout_id2 + "\">";
+ block += callout_value;
+ block += "</callout>";
+ }
+ block += "</calloutlist>";
+
+ return block;
+ }
+
     void explicit_list_action(quickbook::actions& actions, value list)
     {
         write_anchors(actions, actions.out);
@@ -645,6 +722,8 @@
             if (f->source.empty())
                 return; // Nothing left to do here. The program is empty.
 
+ if (qbk_version_n >= 107u) actions.start_callouts();
+
             parse_iterator first_(f->source.begin());
             parse_iterator last_(f->source.end());
 
@@ -653,7 +732,7 @@
 
             // print the code with syntax coloring
             std::string str = syntax_highlight(first_, last_, actions,
- source_mode);
+ source_mode, block);
 
             boost::swap(actions.current_file, saved_file);
 
@@ -665,12 +744,14 @@
             output << "<programlisting>";
             output << str;
             output << "</programlisting>\n";
+
+ if (qbk_version_n >= 107u) output << actions.end_callouts();
         }
         else {
             parse_iterator first_(code_value.begin());
             parse_iterator last_(code_value.end());
             std::string str = syntax_highlight(first_, last_, actions,
- source_mode);
+ source_mode, block);
 
             actions.phrase << "<code>";
             actions.phrase << str;
@@ -1118,9 +1199,9 @@
             parse_iterator last(source.end());
 
             bool r = cl::parse(first, last,
- content.get_tag() == template_tags::block ?
- actions.grammar().block :
- actions.grammar().inline_phrase
+ content.get_tag() == template_tags::phrase ?
+ actions.grammar().inline_phrase :
+ actions.grammar().block
                 ).full;
 
             boost::swap(actions.current_file, saved_current_file);
@@ -1134,12 +1215,14 @@
             std::vector<value> const& args,
             string_iterator first)
     {
+ bool is_block = symbol->content.get_tag() != template_tags::phrase;
+
         // If this template contains already encoded text, then just
         // write it out, without going through any of the rigamarole.
 
         if (symbol->content.is_encoded())
         {
- if (symbol->content.get_tag() == template_tags::block)
+ if (is_block)
             {
                 actions.paragraph();
                 actions.out << symbol->content.get_encoded();
@@ -1200,7 +1283,7 @@
             {
                 detail::outerr(actions.current_file, first)
                     << "Expanding "
- << (symbol->content.get_tag() == template_tags::block ? "block" : "phrase")
+ << (is_block ? "block" : "phrase")
                     << " template: " << detail::utf8(symbol->identifier) << std::endl
                     << std::endl
                     << "------------------begin------------------" << std::endl
@@ -1225,7 +1308,7 @@
             actions.phrase.swap(phrase);
         }
 
- if(symbol->content.get_tag() == template_tags::block || !block.empty()) {
+ if(is_block || !block.empty()) {
             actions.paragraph(); // For paragraphs before the template call.
             actions.out << block;
             actions.phrase << phrase;
@@ -1240,81 +1323,19 @@
             template_symbol const* symbol,
             string_iterator first)
     {
- value_consumer values = symbol->content;
- value content = values.consume(template_tags::block);
- value callouts = values.consume();
- values.finish();
-
- std::vector<std::string> callout_ids;
+ assert(symbol->params.size() == 0);
         std::vector<value> args;
- unsigned int size = symbol->params.size();
- std::string callout_base("c");
-
- for(unsigned int i = 0; i < size; ++i)
- {
- std::string callout_id1 = actions.ids.add_id(callout_base, id_category::numbered);
- std::string callout_id2 = actions.ids.add_id(callout_base, id_category::numbered);
-
- std::string code;
- code += "<co id=\"" + callout_id1 + "\" ";
- code += "linkends=\"" + callout_id2 + "\" />";
-
- args.push_back(encoded_value(code, template_tags::phrase));
- callout_ids.push_back(callout_id1);
- callout_ids.push_back(callout_id2);
- }
 
         // Create a fake symbol for call_template
         template_symbol t(
             symbol->identifier,
             symbol->params,
- content,
+ symbol->content,
             symbol->lexical_parent);
- call_template(actions, &t, args, first);
-
- std::string block;
 
- if(!callouts.empty())
- {
- block += "<calloutlist>";
- int i = 0;
- BOOST_FOREACH(value c, callouts)
- {
- std::string callout_id1 = callout_ids[i++];
- std::string callout_id2 = callout_ids[i++];
-
- std::string callout_value;
- {
- template_state state(actions);
- ++actions.template_depth;
-
- bool r = parse_template(c, actions);
-
- if(!r)
- {
- detail::outerr(c.get_file(), c.get_position())
- << "Expanding callout." << std::endl
- << "------------------begin------------------" << std::endl
- << detail::utf8(c.get_quickbook())
- << std::endl
- << "------------------end--------------------" << std::endl
- ;
- ++actions.error_count;
- return;
- }
-
- actions.out.swap(callout_value);
- }
-
- block += "<callout arearefs=\"" + callout_id1 + "\" ";
- block += "id=\"" + callout_id2 + "\">";
- block += callout_value;
- block += "</callout>";
- }
- block += "</calloutlist>";
- }
-
- actions.out << block;
+ actions.start_callouts();
+ call_template(actions, &t, args, first);
+ actions.out << actions.end_callouts();
     }
 
     void do_template_action(quickbook::actions& actions, value template_list,

Modified: branches/quickbook-dev/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.hpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -62,7 +62,8 @@
     std::string syntax_highlight(
         parse_iterator first, parse_iterator last,
         actions& escape_actions,
- std::string const& source_mode);
+ std::string const& source_mode,
+ bool is_block);
 
     struct xinclude_path {
         xinclude_path(fs::path const& path, std::string const& uri) :

Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.cpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -32,6 +32,8 @@
         , warned_about_breaks(false)
         , conditional(true)
         , ids(ids)
+ , callouts()
+ , callout_depth(0)
 
         , imported(false)
         , macro()

Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.hpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -46,6 +46,8 @@
         bool warned_about_breaks;
         bool conditional;
         id_manager& ids;
+ value_builder callouts; // callouts are global as
+ int callout_depth; // they don't nest.
 
     // state saved for files and templates.
         bool imported;
@@ -77,6 +79,10 @@
         void start_list_item();
         void end_list_item();
 
+ void start_callouts();
+ std::string add_callout(value);
+ std::string end_callouts();
+
         scoped_parser<to_value_scoped_action>
                                 to_value;
         scoped_parser<cond_phrase_push>

Modified: branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -31,13 +31,13 @@
                                 char const* source_type)
             : last_code_pos(source_file->source.begin())
             , in_code(false)
- , callout_id(0)
             , snippet_stack()
             , storage(storage)
             , source_file(source_file)
             , source_type(source_type)
             , error_count(0)
         {
+ source_file->is_code_snippets = true;
             content.start(source_file);
         }
 
@@ -48,7 +48,6 @@
         void start_snippet_impl(std::string const&, string_iterator);
         void end_snippet(string_iterator first, string_iterator last);
         void end_snippet_impl(string_iterator);
- void callout(string_iterator first, string_iterator last);
         void end_file(string_iterator, string_iterator);
         
         void append_code(string_iterator first, string_iterator last);
@@ -56,26 +55,22 @@
 
         struct snippet_data
         {
- snippet_data(std::string const& id, int callout_base_id)
+ snippet_data(std::string const& id)
                 : id(id)
- , callout_base_id(callout_base_id)
                 , start_code(false)
             {}
             
             std::string id;
- int callout_base_id;
             bool start_code;
             std::string::const_iterator source_pos;
             mapped_file_builder::pos start_pos;
- value_builder callouts;
             boost::shared_ptr<snippet_data> next;
         };
         
- void push_snippet_data(std::string const& id, int callout_base_id,
+ void push_snippet_data(std::string const& id,
                 std::string::const_iterator pos)
         {
- boost::shared_ptr<snippet_data> new_snippet(
- new snippet_data(id, callout_base_id));
+ boost::shared_ptr<snippet_data> new_snippet(new snippet_data(id));
             new_snippet->next = snippet_stack;
             snippet_stack = new_snippet;
             snippet_stack->start_code = in_code;
@@ -95,7 +90,6 @@
         std::string::const_iterator mark_begin, mark_end;
         std::string::const_iterator last_code_pos;
         bool in_code;
- int callout_id;
         boost::shared_ptr<snippet_data> snippet_stack;
         std::vector<template_symbol>& storage;
         file_ptr source_file;
@@ -240,8 +234,6 @@
                     | escaped_comment [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
                     | ignore [boost::bind(&actions_type::append_code, &actions, _1, _2)]
                     | pass_thru_comment [boost::bind(&actions_type::pass_thru, &actions, _1, _2)]
- | line_callout [boost::bind(&actions_type::callout, &actions, _1, _2)]
- | inline_callout [boost::bind(&actions_type::callout, &actions, _1, _2)]
                     | cl::anychar_p
                     ;
 
@@ -287,23 +279,6 @@
                             "/*[*/"
                     ;
 
- inline_callout
- = cl::confix_p(
- "/*<" >> *cl::space_p,
- (*cl::anychar_p) [boost::bind(&actions_type::mark, &actions, _1, _2)],
- ">*/"
- )
- ;
-
- line_callout
- = cl::confix_p(
- "/*<<" >> *cl::space_p,
- (*cl::anychar_p) [boost::bind(&actions_type::mark, &actions, _1, _2)],
- ">>*/"
- )
- >> *cl::space_p
- ;
-
                 ignore
                     = cl::confix_p(
                             *cl::blank_p >> "//<-",
@@ -354,7 +329,7 @@
 
             cl::rule<Scanner>
             start_, identifier, code_elements, start_snippet, end_snippet,
- escaped_comment, pass_thru_comment, inline_callout, line_callout, ignore;
+ escaped_comment, pass_thru_comment, ignore;
 
             cl::rule<Scanner> const&
             start() const { return start_; }
@@ -447,27 +422,6 @@
         content.add(mark_begin, mark_end);
     }
 
- void code_snippet_actions::callout(string_iterator first, string_iterator last)
- {
- if(!snippet_stack) return;
- append_code(first, last);
-
- if (!in_code)
- {
- content.add("\n\n", first);
- content.add(source_type, first);
- content.add("```\n", first);
- in_code = true;
- }
-
- content.add(
- "``[[callout" + boost::lexical_cast<std::string>(callout_id) + "]]``",
- first);
-
- snippet_stack->callouts.insert(qbk_value(source_file, mark_begin, mark_end, template_tags::block));
- ++callout_id;
- }
-
     void code_snippet_actions::escaped_comment(string_iterator first, string_iterator last)
     {
         append_code(first, last);
@@ -549,7 +503,7 @@
     void code_snippet_actions::start_snippet_impl(std::string const& id,
             string_iterator position)
     {
- push_snippet_data(id, callout_id, position);
+ push_snippet_data(id, position);
     }
 
     void code_snippet_actions::end_snippet_impl(string_iterator position)
@@ -557,7 +511,6 @@
         assert(snippet_stack);
 
         boost::shared_ptr<snippet_data> snippet = pop_snippet_data();
- value callouts = snippet->callouts.release();
 
         mapped_file_builder f;
         f.start(source_file);
@@ -572,29 +525,11 @@
         }
 
         std::vector<std::string> params;
- int i = 0;
- for(value::iterator it = callouts.begin(); it != callouts.end(); ++it)
- {
- params.push_back("[callout" + boost::lexical_cast<std::string>(snippet->callout_base_id + i) + "]");
- ++i;
- }
 
         file_ptr body = f.release();
 
- value_builder builder;
- builder.set_tag(template_tags::snippet);
- builder.insert(qbk_value(body, body->source.begin(), body->source.end(),
- template_tags::block));
- builder.insert(callouts);
-
- template_symbol symbol(snippet->id, params, builder.release());
- storage.push_back(symbol);
-
- // Copy the snippet's callouts to its parent
-
- if(snippet_stack)
- {
- snippet_stack->callouts.extend(callouts);
- }
+ storage.push_back(template_symbol(snippet->id, params,
+ qbk_value(body, body->source.begin(), body->source.end(),
+ template_tags::snippet)));
     }
 }

Modified: branches/quickbook-dev/tools/quickbook/src/files.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/files.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/files.cpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -285,8 +285,9 @@
     struct mapped_file : file
     {
         mapped_file(file_ptr original) :
- file(original->path, std::string(), original->version()),
- original(original), mapped_sections() {}
+ file(*original, std::string()),
+ original(original), mapped_sections()
+ {}
 
         file_ptr original;
         std::vector<mapped_file_section> mapped_sections;

Modified: branches/quickbook-dev/tools/quickbook/src/files.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/files.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/files.hpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -38,13 +38,20 @@
     {
         fs::path const path;
         std::string source;
+ bool is_code_snippets;
     private:
         unsigned qbk_version;
     public:
 
         file(fs::path const& path, std::string const& source,
                 unsigned qbk_version) :
- path(path), source(source), qbk_version(qbk_version)
+ path(path), source(source), is_code_snippets(false),
+ qbk_version(qbk_version)
+ {}
+
+ file(file const& f, std::string const& source) :
+ path(f.path), source(source), is_code_snippets(f.is_code_snippets),
+ qbk_version(f.qbk_version)
         {}
 
         virtual ~file() {}

Modified: branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -93,9 +93,17 @@
         quickbook::actions& escape_actions;
         do_macro_action do_macro_impl;
 
- syntax_highlight_actions(quickbook::actions& escape_actions) :
+ // State
+ bool support_callouts;
+ string_ref marked_text;
+
+ syntax_highlight_actions(quickbook::actions& escape_actions,
+ bool is_block) :
             out(), escape_actions(escape_actions),
- do_macro_impl(out, escape_actions)
+ do_macro_impl(out, escape_actions),
+ support_callouts(is_block && (qbk_version_n >= 107u ||
+ escape_actions.current_file->is_code_snippets)),
+ marked_text()
         {}
 
         void span(parse_iterator, parse_iterator, char const*);
@@ -106,6 +114,9 @@
         void pre_escape_back(parse_iterator, parse_iterator);
         void post_escape_back(parse_iterator, parse_iterator);
         void do_macro(std::string const&);
+
+ void mark_text(parse_iterator, parse_iterator);
+ void callout(parse_iterator, parse_iterator);
     };
 
     void syntax_highlight_actions::span(parse_iterator first,
@@ -175,6 +186,19 @@
         do_macro_impl(v);
     }
 
+ void syntax_highlight_actions::mark_text(parse_iterator first,
+ parse_iterator last)
+ {
+ marked_text = string_ref(first.base(), last.base());
+ }
+
+ void syntax_highlight_actions::callout(parse_iterator, parse_iterator)
+ {
+ out << escape_actions.add_callout(qbk_value(escape_actions.current_file,
+ marked_text.begin(), marked_text.end()));
+ marked_text.clear();
+ }
+
     // Syntax
 
     struct keywords_holder
@@ -242,7 +266,9 @@
                     unexpected_char(self.actions, &syntax_highlight_actions::unexpected_char),
                     plain_char(self.actions, &syntax_highlight_actions::plain_char),
                     pre_escape_back(self.actions, &syntax_highlight_actions::pre_escape_back),
- post_escape_back(self.actions, &syntax_highlight_actions::post_escape_back);
+ post_escape_back(self.actions, &syntax_highlight_actions::post_escape_back),
+ mark_text(self.actions, &syntax_highlight_actions::mark_text),
+ callout(self.actions, &syntax_highlight_actions::callout);
                 member_action_value<syntax_highlight_actions, std::string const&>
                     do_macro(self.actions, &syntax_highlight_actions::do_macro);
 
@@ -252,6 +278,10 @@
                     | macro
                     | escape
                     | preprocessor [span("preprocessor")]
+ | cl::eps_p(ph::var(self.actions.support_callouts))
+ >> ( line_callout [callout]
+ | inline_callout [callout]
+ )
                     | comment
                     | keyword [span("keyword")]
                     | identifier [span("identifier")]
@@ -294,6 +324,23 @@
                     = '#' >> *cl::space_p >> ((cl::alpha_p | '_') >> *(cl::alnum_p | '_'))
                     ;
 
+ inline_callout
+ = cl::confix_p(
+ "/*<" >> *cl::space_p,
+ (*cl::anychar_p) [mark_text],
+ ">*/"
+ )
+ ;
+
+ line_callout
+ = cl::confix_p(
+ "/*<<" >> *cl::space_p,
+ (*cl::anychar_p) [mark_text],
+ ">>*/"
+ )
+ >> *cl::space_p
+ ;
+
                 comment
                     = cl::str_p("//") [span_start("comment")]
>> *( escape
@@ -342,7 +389,9 @@
             }
 
             cl::rule<Scanner>
- program, macro, preprocessor, comment, special, string_,
+ program, macro, preprocessor,
+ inline_callout, line_callout, comment,
+ special, string_,
                             char_, number, identifier, keyword, escape,
                             string_char;
 
@@ -377,7 +426,9 @@
                     unexpected_char(self.actions, &syntax_highlight_actions::unexpected_char),
                     plain_char(self.actions, &syntax_highlight_actions::plain_char),
                     pre_escape_back(self.actions, &syntax_highlight_actions::pre_escape_back),
- post_escape_back(self.actions, &syntax_highlight_actions::post_escape_back);
+ post_escape_back(self.actions, &syntax_highlight_actions::post_escape_back),
+ mark_text(self.actions, &syntax_highlight_actions::mark_text),
+ callout(self.actions, &syntax_highlight_actions::callout);
                 member_action_value<syntax_highlight_actions, std::string const&>
                     do_macro(self.actions, &syntax_highlight_actions::do_macro);
 
@@ -560,9 +611,10 @@
         parse_iterator first,
         parse_iterator last,
         actions& escape_actions,
- std::string const& source_mode)
+ std::string const& source_mode,
+ bool is_block)
     {
- syntax_highlight_actions syn_actions(escape_actions);
+ syntax_highlight_actions syn_actions(escape_actions, is_block);
 
         // print the code with syntax coloring
         if (source_mode == "c++")

Modified: branches/quickbook-dev/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -26,6 +26,7 @@
     [ quickbook-test anchor-1_6 ]
     [ quickbook-test blocks-1_5 ]
     [ quickbook-test callouts-1_5 ]
+ [ quickbook-test callouts-1_7 ]
     [ quickbook-test code-1_1 ]
     [ quickbook-test code-1_5 ]
     [ quickbook-test code_cpp-1_5 ]

Added: branches/quickbook-dev/tools/quickbook/test/callouts-1_7.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/callouts-1_7.gold 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -0,0 +1,247 @@
+<?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="callout_tests" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Callout Tests</title>
+ <para>
+ Example 1:
+ </para>
+ <para>
+ Now we can define a function that simulates an ordinary six-sided die.
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.c0" linkends="callout_tests.c1" />
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.c0" id="callout_tests.c1">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 2:
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.c2" linkends="callout_tests.c3" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.c2" id="callout_tests.c3">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 3:
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.c4" linkends="callout_tests.c5" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.c4" id="callout_tests.c5">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 3 (again!):
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.c6" linkends="callout_tests.c7" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.c6" id="callout_tests.c7">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 4:
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.c8" linkends="callout_tests.c9" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+ <co id="callout_tests.c10" linkends="callout_tests.c11" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.c12" linkends="callout_tests.c13" />
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.c8" id="callout_tests.c9">
+ <para>
+ callout 1
+ </para>
+ </callout>
+ <callout arearefs="callout_tests.c10" id="callout_tests.c11">
+ <para>
+ callout 2
+ </para>
+ </callout>
+ <callout arearefs="callout_tests.c12" id="callout_tests.c13">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
+<programlisting><co id="callout_tests.c14" linkends="callout_tests.c15" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.c16" linkends="callout_tests.c17" />
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.c14" id="callout_tests.c15">
+ <para>
+ callout 2
+ </para>
+ </callout>
+ <callout arearefs="callout_tests.c16" id="callout_tests.c17">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
+ <section id="callout_tests.test_section">
+ <title><link linkend="callout_tests.test_section">Try callouts in a section</link></title>
+ <para>
+ Example 1:
+ </para>
+ <para>
+ Now we can define a function that simulates an ordinary six-sided die.
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.test_section.c0" linkends="callout_tests.test_section.c1" />
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.test_section.c0" id="callout_tests.test_section.c1">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 2:
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.test_section.c2" linkends="callout_tests.test_section.c3" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.test_section.c2" id="callout_tests.test_section.c3">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 3:
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.test_section.c4" linkends="callout_tests.test_section.c5" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.test_section.c4" id="callout_tests.test_section.c5">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 3 (again!):
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.test_section.c6" linkends="callout_tests.test_section.c7" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.test_section.c6" id="callout_tests.test_section.c7">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
+ <para>
+ Example 4:
+ </para>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.test_section.c8" linkends="callout_tests.test_section.c9" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+ <co id="callout_tests.test_section.c10" linkends="callout_tests.test_section.c11" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.test_section.c12" linkends="callout_tests.test_section.c13" />
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.test_section.c8" id="callout_tests.test_section.c9">
+ <para>
+ callout 1
+ </para>
+ </callout>
+ <callout arearefs="callout_tests.test_section.c10" id="callout_tests.test_section.c11">
+ <para>
+ callout 2
+ </para>
+ </callout>
+ <callout arearefs="callout_tests.test_section.c12" id="callout_tests.test_section.c13">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
+<programlisting><co id="callout_tests.test_section.c14" linkends="callout_tests.test_section.c15" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.test_section.c16" linkends="callout_tests.test_section.c17" />
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.test_section.c14" id="callout_tests.test_section.c15">
+ <para>
+ callout 2
+ </para>
+ </callout>
+ <callout arearefs="callout_tests.test_section.c16" id="callout_tests.test_section.c17">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
+ </section>
+ <section id="callout_tests.blocks">
+ <title><link linkend="callout_tests.blocks">Callouts in code blocks</link></title>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="identifier">dist</phrase><phrase role="special">(</phrase><phrase role="number">1</phrase><phrase role="special">,</phrase> <phrase role="number">6</phrase><phrase role="special">);</phrase> <co id="callout_tests.blocks.c0" linkends="callout_tests.blocks.c1" />
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.blocks.c0" id="callout_tests.blocks.c1">
+ <para>
+ create a uniform_int distribution
+ </para>
+ </callout>
+ </calloutlist>
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">roll_die</phrase><phrase role="special">()</phrase> <phrase role="special">{</phrase>
+ <co id="callout_tests.blocks.c2" linkends="callout_tests.blocks.c3" /><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">variate_generator</phrase><phrase role="special">&lt;</phrase><phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">mt19937</phrase><phrase role="special">&amp;,</phrase> <phrase role="identifier">boost</phrase><phrase role="special">::</phrase><phrase role="identifier">uniform_int</phrase><phrase role="special">&lt;&gt;</phrase> <phrase role="special">&gt;</phrase> <phrase role="identifier">die</phrase><phrase role="special">(</phrase><phrase role="identifier">gen</phrase><phrase role="special">,</phrase> <phrase role="identifier">dist</phrase><phrase role="special">);</phrase>
+<phrase role="special">}</phrase>
+</programlisting>
+ <calloutlist>
+ <callout arearefs="callout_tests.blocks.c2" id="callout_tests.blocks.c3">
+ <important>
+ <para>
+ test
+ </para>
+ </important>
+ </callout>
+ </calloutlist>
+ <para>
+ <code><phrase role="comment">/*&lt; This shouldn't be a callout &gt;*/</phrase></code>
+ </para>
+ </section>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/callouts-1_7.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/callouts-1_7.quickbook 2011-12-11 06:16:01 EST (Sun, 11 Dec 2011)
@@ -0,0 +1,68 @@
+[article Callout Tests
+ [quickbook 1.7]
+]
+
+[import callouts.cpp]
+
+Example 1:
+
+[example1]
+
+Example 2:
+
+[example2]
+
+Example 3:
+
+[example3]
+
+Example 3 (again!):
+
+[example3]
+
+Example 4:
+
+[example4]
+[example4a]
+
+[section:test_section Try callouts in a section]
+
+Example 1:
+
+[example1]
+
+Example 2:
+
+[example2]
+
+Example 3:
+
+[example3]
+
+Example 3 (again!):
+
+[example3]
+
+Example 4:
+
+[example4]
+[example4a]
+
+[endsect]
+
+[section:blocks Callouts in code blocks]
+
+ int roll_die() {
+ boost::uniform_int<> dist(1, 6); /*< create a uniform_int distribution >*/
+ }
+
+```
+int roll_die() {
+ /*<< [important test] >>*/
+ boost::variate_generator<boost::mt19937&, boost::uniform_int<> > die(gen, dist);
+}
+```
+
+`/*< This shouldn't be a callout >*/`
+
+[endsect]
\ No newline at end of file


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