|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70564 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-03-26 07:12:47
Author: danieljames
Date: 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
New Revision: 70564
URL: http://svn.boost.org/trac/boost/changeset/70564
Log:
Quickbook: Clean up anchor stuff.
Text files modified:
trunk/tools/quickbook/src/actions.cpp | 135 +++++++++++++++++++++++----------------
trunk/tools/quickbook/src/actions.hpp | 11 ---
trunk/tools/quickbook/src/actions_class.cpp | 2
trunk/tools/quickbook/src/actions_class.hpp | 2
trunk/tools/quickbook/src/block_element_grammar.cpp | 4
trunk/tools/quickbook/test/table_1_5.gold | 24 +++++++
trunk/tools/quickbook/test/table_1_5.quickbook | 7 +
trunk/tools/quickbook/test/variablelist.gold | 12 +++
trunk/tools/quickbook/test/variablelist.quickbook | 11 ++
9 files changed, 134 insertions(+), 74 deletions(-)
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -49,6 +49,21 @@
id += section_id;
return id;
}
+
+ void write_anchors(quickbook::actions& actions, collector& tgt)
+ {
+ for(quickbook::actions::string_list::iterator
+ it = actions.anchors.begin(),
+ end = actions.anchors.end();
+ it != end; ++it)
+ {
+ tgt << "<anchor id=\"";
+ detail::print_string(*it, tgt.get());
+ tgt << "\"/>\n";
+ }
+
+ actions.anchors.clear();
+ }
}
void list_action(quickbook::actions&, value);
@@ -72,7 +87,7 @@
void raw_phrase_action(quickbook::actions&, value);
void source_mode_action(quickbook::actions&, value);
void do_template_action(quickbook::actions&, value, file_position);
-
+
void element_action::operator()(iterator first, iterator) const
{
value_consumer values = actions.values.release();
@@ -164,7 +179,8 @@
// Handles line-breaks (DEPRECATED!!!)
void break_action::operator()(iterator first, iterator) const
{
- if(!actions.output_pre(phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, phrase);
file_position const pos = first.get_position();
if(*first == '\\')
@@ -212,7 +228,9 @@
void block_action(quickbook::actions& actions, value block)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
+
detail::markup markup = detail::get_markup(block.get_tag());
value_consumer values = block;
@@ -222,14 +240,18 @@
void block_empty_action(quickbook::actions& actions, value block)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
+
detail::markup markup = detail::get_markup(block.get_tag());
actions.out << markup.pre;
}
void phrase_action(quickbook::actions& actions, value phrase)
{
- if(!actions.output_pre(actions.phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.phrase);
+
detail::markup markup = detail::get_markup(phrase.get_tag());
value_consumer values = phrase;
@@ -239,7 +261,9 @@
void raw_phrase_action(quickbook::actions& actions, value phrase)
{
- if(!actions.output_pre(actions.phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.phrase);
+
detail::markup markup = detail::get_markup(phrase.get_tag());
actions.phrase << markup.pre << phrase.get_quickbook() << markup.post;
}
@@ -260,7 +284,7 @@
if(pos != end) {
detail::markup markup = detail::get_markup(block_tags::paragraph);
actions.out << markup.pre << str;
- actions.output_pre(actions.out);
+ write_anchors(actions, actions.out);
actions.out << markup.post;
}
}
@@ -330,7 +354,7 @@
}
actions.anchors.push_back(anchor);
- actions.output_pre(actions.out);
+ write_anchors(actions, actions.out);
write_bridgehead(actions.out, level,
content.get_boostbook(), anchor + "-heading", linkend);
@@ -338,7 +362,8 @@
void simple_phrase_action::operator()(char mark) const
{
- if(!actions.output_pre(out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, out);
int tag =
mark == '*' ? phrase_tags::bold :
@@ -405,7 +430,8 @@
void list_action(quickbook::actions& actions, value list)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
typedef std::pair<char, int> mark_type;
std::stack<mark_type> list_marks;
@@ -478,7 +504,9 @@
void explicit_list_action(quickbook::actions& actions, value list)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
+
detail::markup markup = detail::get_markup(list.get_tag());
actions.out << markup.pre;
@@ -530,7 +558,8 @@
void do_macro_action::operator()(std::string const& str) const
{
- if(!actions.output_pre(phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, phrase);
if (str == quickbook_get_date)
{
@@ -568,7 +597,7 @@
void post_escape_back::operator()(iterator, iterator) const
{
- escape_actions.output_pre(escape_actions.phrase);
+ write_anchors(escape_actions, escape_actions.phrase);
out << escape_actions.phrase.str();
escape_actions.phrase.pop(); // restore the stream
}
@@ -580,7 +609,8 @@
void code_action::operator()(iterator first, iterator last) const
{
- if(!actions.output_pre(out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, out);
// preprocess the code section to remove the initial indentation
std::string program(first, last);
@@ -612,7 +642,8 @@
void inline_code_action::operator()(iterator first, iterator last) const
{
- if(!actions.output_pre(out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, out);
std::string save;
out.swap(save);
@@ -629,31 +660,40 @@
void raw_char_action::operator()(char ch) const
{
- if(!actions.output_pre(phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, phrase);
+
phrase << ch;
}
void raw_char_action::operator()(iterator first, iterator /*last*/) const
{
- if(!actions.output_pre(phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, phrase);
+
phrase << *first;
}
void plain_char_action::operator()(char ch) const
{
- if(!actions.output_pre(phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, phrase);
+
detail::print_char(ch, phrase.get());
}
void plain_char_action::operator()(iterator first, iterator /*last*/) const
{
- if(!actions.output_pre(phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, phrase);
+
detail::print_char(*first, phrase.get());
}
void escape_unicode_action::operator()(iterator first, iterator last) const
{
- if(!actions.output_pre(phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, phrase);
while(first != last && *first == '0') ++first;
@@ -674,7 +714,8 @@
void image_action(quickbook::actions& actions, value image)
{
- if(!actions.output_pre(actions.phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.phrase);
typedef std::map<std::string, value> attribute_map;
attribute_map attributes;
@@ -1309,7 +1350,9 @@
void link_action(quickbook::actions& actions, value link)
{
- if(!actions.output_pre(actions.phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.phrase);
+
detail::markup markup = detail::get_markup(link.get_tag());
value_consumer values = link;
@@ -1332,6 +1375,7 @@
void variable_list_action(quickbook::actions& actions, value variable_list)
{
if(actions.suppress) return;
+ write_anchors(actions, actions.out);
value_consumer values = variable_list;
std::string title = values.consume(table_tags::title).get_quickbook();
@@ -1368,6 +1412,7 @@
void table_action(quickbook::actions& actions, value table)
{
if(actions.suppress) return;
+ write_anchors(actions, actions.out);
value_consumer values = table;
@@ -1482,8 +1527,6 @@
actions::string_list saved_anchors;
saved_anchors.swap(actions.anchors);
- actions.output_pre(actions.out);
-
if (qbk_version_n < 103) // version 1.2 and below
{
actions.out << "\n<section id=\""
@@ -1498,7 +1541,7 @@
actions.out << "<title>";
actions.anchors.swap(saved_anchors);
- actions.output_pre(actions.out);
+ write_anchors(actions, actions.out);
if (qbk_version_n < 103) // version 1.2 and below
{
@@ -1518,7 +1561,8 @@
void end_section_action(quickbook::actions& actions, value end_section, file_position pos)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
if (actions.section_level <= actions.min_section_level)
{
@@ -1663,7 +1707,8 @@
void xinclude_action(quickbook::actions& actions, value xinclude)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
value_consumer values = xinclude;
fs::path path = calculate_relative_path(
@@ -1721,7 +1766,8 @@
void import_action(quickbook::actions& actions, value import)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
value_consumer values = import;
include_search_return paths = include_search(
@@ -1748,7 +1794,8 @@
void include_action(quickbook::actions& actions, value include)
{
- if(!actions.output_pre(actions.out)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.out);
value_consumer values = include;
value include_doc_id = values.optional_consume(general_tags::include_id);
@@ -1823,7 +1870,8 @@
void phrase_to_docinfo_action_impl::operator()(iterator first, iterator last,
value::tag_type tag) const
{
- if(!actions.output_pre(actions.phrase)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, actions.phrase);
std::string encoded;
actions.phrase.swap(encoded);
@@ -1838,37 +1886,14 @@
void collector_to_value_action::operator()(iterator, iterator) const
{
- if(!actions.output_pre(output)) return;
+ if (actions.suppress) return;
+ write_anchors(actions, output);
std::string value;
output.swap(value);
actions.values.builder.insert(bbk_value(value, value::default_tag));
}
- bool pre_output_action::operator()(collector& tgt) const
- {
- if(actions.suppress) return false;
-
- for(quickbook::actions::string_list::iterator
- it = actions.anchors.begin(),
- end = actions.anchors.end();
- it != end; ++it)
- {
- tgt << "<anchor id=\"";
- detail::print_string(*it, tgt.get());
- tgt << "\"/>\n";
- }
-
- actions.anchors.clear();
-
- return true;
- }
-
- bool pre_output_action::operator()(iterator, iterator) const
- {
- return (*this)(actions.out);
- }
-
bool scoped_output_push::start()
{
actions.out.push();
Modified: trunk/tools/quickbook/src/actions.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions.hpp (original)
+++ trunk/tools/quickbook/src/actions.hpp 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -367,17 +367,6 @@
collector& output;
};
- struct pre_output_action
- {
- pre_output_action(quickbook::actions& actions)
- : actions(actions) {}
-
- bool operator()(collector& tgt) const;
- bool operator()(iterator, iterator) const;
-
- quickbook::actions& actions;
- };
-
struct scoped_output_push : scoped_action_base
{
scoped_output_push(quickbook::actions& actions)
Modified: trunk/tools/quickbook/src/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.cpp (original)
+++ trunk/tools/quickbook/src/actions_class.cpp 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -82,8 +82,6 @@
, do_macro(phrase, *this)
, element_id_warning(*this)
-
- , output_pre(*this)
{
// add the predefined macros
macro.add
Modified: trunk/tools/quickbook/src/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions_class.hpp (original)
+++ trunk/tools/quickbook/src/actions_class.hpp 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -131,8 +131,6 @@
do_macro_action do_macro;
element_id_warning_action element_id_warning;
-
- pre_output_action output_pre;
};
}
Modified: trunk/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_element_grammar.cpp (original)
+++ trunk/tools/quickbook/src/block_element_grammar.cpp 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -173,7 +173,7 @@
local.variablelist =
(cl::eps_p(*cl::blank_p >> cl::eol_p) | space)
>> (*(cl::anychar_p - eol)) [actions.values.entry(ph::arg1, ph::arg2, table_tags::title)]
- >> (+eol) [actions.output_pre]
+ >> (+eol)
>> *local.varlistentry
;
@@ -213,7 +213,7 @@
>> local.element_id_1_5
>> (cl::eps_p(*cl::blank_p >> cl::eol_p) | space)
>> (*(cl::anychar_p - eol)) [actions.values.entry(ph::arg1, ph::arg2, table_tags::title)]
- >> (+eol) [actions.output_pre]
+ >> (+eol)
>> *local.table_row
;
Modified: trunk/tools/quickbook/test/table_1_5.gold
==============================================================================
--- trunk/tools/quickbook/test/table_1_5.gold (original)
+++ trunk/tools/quickbook/test/table_1_5.gold 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -298,5 +298,29 @@
</tbody>
</tgroup>
</table>
+ <anchor id="id1"/>
+ <table frame="all" id="table_1_5.section1.table_with_anchors">
+ <title>Table with anchors</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ <anchor id="id2"/> a<anchor id="id3"/>
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ b
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</section>
</article>
Modified: trunk/tools/quickbook/test/table_1_5.quickbook
==============================================================================
--- trunk/tools/quickbook/test/table_1_5.quickbook (original)
+++ trunk/tools/quickbook/test/table_1_5.quickbook 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -93,4 +93,9 @@
]
]
-[endsect]
\ No newline at end of file
+[#id1]
+[table Table with anchors
+[[[#id2]a[#id3]]][[b]]
+]
+
+[endsect]
Modified: trunk/tools/quickbook/test/variablelist.gold
==============================================================================
--- trunk/tools/quickbook/test/variablelist.gold (original)
+++ trunk/tools/quickbook/test/variablelist.gold 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -92,4 +92,16 @@
</listitem>
</varlistentry>
</variablelist>
+ <anchor id="id1"/>
+ <variablelist>
+ <title>Variable List with anchors</title>
+ <varlistentry>
+ <term><anchor id="id2"/> a<anchor id="id3"/> </term>
+ <listitem>
+ <para>
+ <anchor id="id4"/> b<anchor id="id5"/>
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
</article>
Modified: trunk/tools/quickbook/test/variablelist.quickbook
==============================================================================
--- trunk/tools/quickbook/test/variablelist.quickbook (original)
+++ trunk/tools/quickbook/test/variablelist.quickbook 2011-03-26 07:12:45 EDT (Sat, 26 Mar 2011)
@@ -19,4 +19,13 @@
[[a][b][c][d]]
[[a][b][c][d][e]]
[[a][b]]
-]
\ No newline at end of file
+]
+
+[#id1]
+[variablelist Variable List with anchors
+ [
+ [[#id2]a[#id3]]
+ [[#id4]b[#id5]]
+ ]
+]
+
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