|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70527 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-03-24 17:24:51
Author: danieljames
Date: 2011-03-24 17:24:50 EDT (Thu, 24 Mar 2011)
New Revision: 70527
URL: http://svn.boost.org/trac/boost/changeset/70527
Log:
Quickbook: Encapsulate markups.
Text files modified:
trunk/tools/quickbook/src/actions.cpp | 43 ++++++------
trunk/tools/quickbook/src/markups.cpp | 140 ++++++++++-----------------------------
trunk/tools/quickbook/src/markups.hpp | 91 -------------------------
trunk/tools/quickbook/src/phrase_tags.hpp | 1
4 files changed, 60 insertions(+), 215 deletions(-)
Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp (original)
+++ trunk/tools/quickbook/src/actions.cpp 2011-03-24 17:24:50 EDT (Thu, 24 Mar 2011)
@@ -11,6 +11,7 @@
#include <numeric>
#include <functional>
#include <vector>
+#include <map>
#include <boost/filesystem/v3/convenience.hpp>
#include <boost/filesystem/v3/fstream.hpp>
#include <boost/range/distance.hpp>
@@ -181,7 +182,7 @@
actions.warned_about_breaks = true;
}
- phrase << break_mark;
+ phrase << detail::get_markup(phrase_tags::break_mark).pre;
}
void error_message_action::operator()(iterator first, iterator last) const
@@ -210,7 +211,7 @@
void block_action(quickbook::actions& actions, value block)
{
if(!actions.output_pre(actions.out)) return;
- detail::markup markup = detail::markups[block.get_tag()];
+ detail::markup markup = detail::get_markup(block.get_tag());
value_consumer values = block;
actions.out << markup.pre << values.consume().get_boostbook() << markup.post;
@@ -220,14 +221,14 @@
void block_empty_action(quickbook::actions& actions, value block)
{
if(!actions.output_pre(actions.out)) return;
- detail::markup markup = detail::markups[block.get_tag()];
+ 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;
- detail::markup markup = detail::markups[phrase.get_tag()];
+ detail::markup markup = detail::get_markup(phrase.get_tag());
value_consumer values = phrase;
actions.phrase << markup.pre << values.consume().get_boostbook() << markup.post;
@@ -237,7 +238,7 @@
void raw_phrase_action(quickbook::actions& actions, value phrase)
{
if(!actions.output_pre(actions.phrase)) return;
- detail::markup markup = detail::markups[phrase.get_tag()];
+ detail::markup markup = detail::get_markup(phrase.get_tag());
actions.phrase << markup.pre << phrase.get_quickbook() << markup.post;
}
@@ -255,7 +256,7 @@
while(pos != end && cl::space_p.test(*pos)) ++pos;
if(pos != end) {
- detail::markup markup = detail::markups[block_tags::paragraph];
+ detail::markup markup = detail::get_markup(block_tags::paragraph);
actions.out << markup.pre << str;
actions.output_pre(actions.out);
actions.out << markup.post;
@@ -345,7 +346,7 @@
0;
assert(tag != 0);
- detail::markup markup = detail::markups[tag];
+ detail::markup markup = detail::get_markup(tag);
value_consumer values = actions.values.get();
value content = values.consume();
@@ -476,7 +477,7 @@
void explicit_list_action(quickbook::actions& actions, value list)
{
if(!actions.output_pre(actions.out)) return;
- detail::markup markup = detail::markups[list.get_tag()];
+ detail::markup markup = detail::get_markup(list.get_tag());
actions.out << markup.pre;
@@ -1319,7 +1320,7 @@
void link_action(quickbook::actions& actions, value link)
{
if(!actions.output_pre(actions.phrase)) return;
- detail::markup markup = detail::markups[link.get_tag()];
+ detail::markup markup = detail::get_markup(link.get_tag());
value_consumer values = link;
value dst = values.consume();
@@ -1352,21 +1353,21 @@
actions.out << "</title>\n";
BOOST_FOREACH(value_consumer entry, values) {
- actions.out << start_varlistentry_;
+ actions.out << "<varlistentry>";
if(entry.check()) {
- actions.out << start_varlistterm_;
+ actions.out << "<term>";
actions.out << entry.consume().get_boostbook();
- actions.out << end_varlistterm_;
+ actions.out << "</term>";
}
if(entry.check()) {
- actions.out << start_varlistitem_;
+ actions.out << "<listitem>";
BOOST_FOREACH(value phrase, entry) actions.out << phrase.get_boostbook();
- actions.out << end_varlistitem_;
+ actions.out << "</listitem>";
}
- actions.out << end_varlistentry_;
+ actions.out << "</varlistentry>\n";
}
actions.out << "</variablelist>\n";
@@ -1434,21 +1435,21 @@
if (row_count > 1)
{
- actions.out << "<thead>" << start_row_;
+ actions.out << "<thead>" << "<row>";
BOOST_FOREACH(value cell, values.consume()) {
- actions.out << start_cell_ << cell.get_boostbook() << end_cell_;
+ actions.out << "<entry>" << cell.get_boostbook() << "</entry>";
}
- actions.out << end_row_ << "</thead>\n";
+ actions.out << "</row>\n" << "</thead>\n";
}
actions.out << "<tbody>\n";
BOOST_FOREACH(value row, values) {
- actions.out << start_row_;
+ actions.out << "<row>";
BOOST_FOREACH(value cell, row) {
- actions.out << start_cell_ << cell.get_boostbook() << end_cell_;
+ actions.out << "<entry>" << cell.get_boostbook() << "</entry>";
}
- actions.out << end_row_;
+ actions.out << "</row>\n";
}
values.finish();
Modified: trunk/tools/quickbook/src/markups.cpp
==============================================================================
--- trunk/tools/quickbook/src/markups.cpp (original)
+++ trunk/tools/quickbook/src/markups.cpp 2011-03-24 17:24:50 EDT (Thu, 24 Mar 2011)
@@ -14,84 +14,10 @@
#include "phrase_tags.hpp"
#include <boost/foreach.hpp>
#include <ostream>
+#include <map>
namespace quickbook
{
- const char* comment_pre = "<!--";
- const char* comment_post = "-->";
- const char* paragraph_pre = "<para>\n";
- const char* paragraph_post = "</para>\n";
- const char* hr_ = "<para/>";
- const char* blurb_pre = "<sidebar role=\"blurb\">\n";
- const char* blurb_post = "</sidebar>\n";
- const char* blockquote_pre = "<blockquote>";
- const char* blockquote_post = "</blockquote>";
- const char* preformatted_pre = "<programlisting>";
- const char* preformatted_post = "</programlisting>";
- const char* warning_pre = "<warning>";
- const char* warning_post = "</warning>";
- const char* caution_pre = "<caution>";
- const char* caution_post = "</caution>";
- const char* important_pre = "<important>";
- const char* important_post = "</important>";
- const char* note_pre = "<note>";
- const char* note_post = "</note>";
- const char* tip_pre = "<tip>";
- const char* tip_post = "</tip>";
- const char* list_item_pre = "<listitem><simpara>\n";
- const char* list_item_post = "\n</simpara></listitem>";
- const char* bold_pre_ = "<emphasis role=\"bold\">";
- const char* bold_post_ = "</emphasis>";
- const char* italic_pre_ = "<emphasis>";
- const char* italic_post_ = "</emphasis>";
- const char* underline_pre_ = "<emphasis role=\"underline\">";
- const char* underline_post_ = "</emphasis>";
- const char* teletype_pre_ = "<literal>";
- const char* teletype_post_ = "</literal>";
- const char* strikethrough_pre_ = "<emphasis role=\"strikethrough\">";
- const char* strikethrough_post_ = "</emphasis>";
- const char* quote_pre_ = "<quote>";
- const char* quote_post_ = "</quote>";
- const char* break_mark = "<sbr/>\n";
- const char* url_pre_ = "<ulink url=\"";
- const char* url_post_ = "</ulink>";
- const char* link_pre_ = "<link linkend=\"";
- const char* link_post_ = "</link>";
- const char* start_varlistentry_ = "<varlistentry>";
- const char* end_varlistentry_ = "</varlistentry>\n";
- const char* start_varlistterm_ = "<term>";
- const char* end_varlistterm_ = "</term>";
- const char* start_varlistitem_ = "<listitem>";
- const char* end_varlistitem_ = "</listitem>";
- const char* start_header_ = "<thead>";
- const char* end_header_ = "</thead>\n";
- const char* start_row_ = "<row>";
- const char* end_row_ = "</row>\n";
- const char* start_cell_ = "<entry>";
- const char* end_cell_ = "</entry>";
- const char* funcref_pre_ = "<functionname alt=\"";
- const char* funcref_post_ = "</functionname>";
- const char* classref_pre_ = "<classname alt=\"";
- const char* classref_post_ = "</classname>";
- const char* memberref_pre_ = "<methodname alt=\"";
- const char* memberref_post_ = "</methodname>";
- const char* enumref_pre_ = "<enumname alt=\"";
- const char* enumref_post_ = "</enumname>";
- const char* macroref_pre_ = "<macroname alt=\"";
- const char* macroref_post_ = "</macroname>";
- const char* headerref_pre_ = "<headername alt=\"";
- const char* headerref_post_ = "</headername>";
- const char* conceptref_pre_ = "<conceptname alt=\"";
- const char* conceptref_post_ = "</conceptname>";
- const char* globalref_pre_ = "<globalname alt=\"";
- const char* globalref_post_ = "</globalname>";
- const char* footnote_pre_ = "<footnote><para>";
- const char* footnote_post_ = "</para></footnote>";
- const char* escape_pre_ = "<!--quickbook-escape-prefix-->";
- const char* escape_post_ = "<!--quickbook-escape-postfix-->";
- const char* replaceable_pre_ = "<replaceable>";
- const char* replaceable_post_ = "</replaceable>";
-
namespace detail
{
std::map<value::tag_type, markup> markups;
@@ -99,37 +25,38 @@
void initialise_markups()
{
markup init_markups[] = {
- { block_tags::paragraph, paragraph_pre, paragraph_post },
- { block_tags::blurb, blurb_pre, blurb_post },
- { block_tags::blockquote, blockquote_pre, blockquote_post },
- { block_tags::preformatted, preformatted_pre, preformatted_post },
- { block_tags::warning, warning_pre, warning_post },
- { block_tags::caution, caution_pre, caution_post },
- { block_tags::important, important_pre, important_post },
- { block_tags::note, note_pre, note_post },
- { block_tags::tip, tip_pre, tip_post },
+ { block_tags::paragraph, "<para>\n", "</para>\n" },
+ { block_tags::blurb, "<sidebar role=\"blurb\">\n", "</sidebar>\n" },
+ { block_tags::blockquote, "<blockquote>", "</blockquote>" },
+ { block_tags::preformatted, "<programlisting>", "</programlisting>" },
+ { block_tags::warning, "<warning>", "</warning>" },
+ { block_tags::caution, "<caution>", "</caution>" },
+ { block_tags::important, "<important>", "</important>" },
+ { block_tags::note, "<note>", "</note>" },
+ { block_tags::tip, "<tip>", "</tip>" },
{ block_tags::ordered_list, "<orderedlist>", "</orderedlist>" },
{ block_tags::itemized_list, "<itemizedlist>", "</itemizedlist>" },
- { block_tags::hr, hr_, 0 },
- { phrase_tags::url, url_pre_, url_post_ },
- { phrase_tags::link, link_pre_, link_post_ },
- { phrase_tags::funcref, funcref_pre_, funcref_post_ },
- { phrase_tags::classref, classref_pre_, classref_post_ },
- { phrase_tags::memberref, memberref_pre_, memberref_post_ },
- { phrase_tags::enumref, enumref_pre_, enumref_post_ },
- { phrase_tags::macroref, macroref_pre_, macroref_post_ },
- { phrase_tags::headerref, headerref_pre_, headerref_post_ },
- { phrase_tags::conceptref, conceptref_pre_, conceptref_post_ },
- { phrase_tags::globalref, globalref_pre_, globalref_post_ },
- { phrase_tags::bold, bold_pre_, bold_post_ },
- { phrase_tags::italic, italic_pre_, italic_post_ },
- { phrase_tags::underline, underline_pre_, underline_post_ },
- { phrase_tags::teletype, teletype_pre_, teletype_post_ },
- { phrase_tags::strikethrough, strikethrough_pre_, strikethrough_post_ },
- { phrase_tags::quote, quote_pre_, quote_post_ },
- { phrase_tags::replaceable, replaceable_pre_, replaceable_post_ },
- { phrase_tags::footnote, footnote_pre_, footnote_post_ },
- { phrase_tags::escape, escape_pre_, escape_post_ }
+ { block_tags::hr, "<para/>", 0 },
+ { phrase_tags::url, "<ulink url=\"", "</ulink>" },
+ { phrase_tags::link, "<link linkend=\"", "</link>" },
+ { phrase_tags::funcref, "<functionname alt=\"", "</functionname>" },
+ { phrase_tags::classref, "<classname alt=\"", "</classname>" },
+ { phrase_tags::memberref, "<methodname alt=\"", "</methodname>" },
+ { phrase_tags::enumref, "<enumname alt=\"", "</enumname>" },
+ { phrase_tags::macroref, "<macroname alt=\"", "</macroname>" },
+ { phrase_tags::headerref, "<headername alt=\"", "</headername>" },
+ { phrase_tags::conceptref, "<conceptname alt=\"", "</conceptname>" },
+ { phrase_tags::globalref, "<globalname alt=\"", "</globalname>" },
+ { phrase_tags::bold, "<emphasis role=\"bold\">", "</emphasis>" },
+ { phrase_tags::italic, "<emphasis>", "</emphasis>" },
+ { phrase_tags::underline, "<emphasis role=\"underline\">", "</emphasis>" },
+ { phrase_tags::teletype, "<literal>", "</literal>" },
+ { phrase_tags::strikethrough, "<emphasis role=\"strikethrough\">", "</emphasis>" },
+ { phrase_tags::quote, "<quote>", "</quote>" },
+ { phrase_tags::replaceable, "<replaceable>", "</replaceable>" },
+ { phrase_tags::footnote, "<footnote><para>", "</para></footnote>" },
+ { phrase_tags::escape, "<!--quickbook-escape-prefix-->", "<!--quickbook-escape-postfix-->" },
+ { phrase_tags::break_mark, "<sbr/>\n", 0 }
};
BOOST_FOREACH(markup m, init_markups)
@@ -138,6 +65,11 @@
}
}
+ markup const& get_markup(value::tag_type t)
+ {
+ return markups[t];
+ }
+
std::ostream& operator<<(std::ostream& out, markup const& m)
{
return out<<"{"<<m.tag<<": \""<<m.pre<<"\", \""<<m.post<<"\"}";
Modified: trunk/tools/quickbook/src/markups.hpp
==============================================================================
--- trunk/tools/quickbook/src/markups.hpp (original)
+++ trunk/tools/quickbook/src/markups.hpp 2011-03-24 17:24:50 EDT (Thu, 24 Mar 2011)
@@ -10,99 +10,11 @@
#if !defined(BOOST_SPIRIT_MARKUPS_HPP)
#define BOOST_SPIRIT_MARKUPS_HPP
-#include <map>
#include <iosfwd>
#include "values.hpp"
namespace quickbook
{
- extern const char* comment_pre;
- extern const char* comment_post;
- extern const char* paragraph_pre;
- extern const char* paragraph_post;
- extern const char* h1_pre;
- extern const char* h1_post;
- extern const char* h2_pre;
- extern const char* h2_post;
- extern const char* h3_pre;
- extern const char* h3_post;
- extern const char* h4_pre;
- extern const char* h4_post;
- extern const char* h5_pre;
- extern const char* h5_post;
- extern const char* h6_pre;
- extern const char* h6_post;
- extern const char* hr_;
- extern const char* blurb_pre;
- extern const char* blurb_post;
- extern const char* blockquote_pre;
- extern const char* blockquote_post;
- extern const char* preformatted_pre;
- extern const char* preformatted_post;
- extern const char* warning_pre;
- extern const char* warning_post;
- extern const char* caution_pre;
- extern const char* caution_post;
- extern const char* important_pre;
- extern const char* important_post;
- extern const char* note_pre;
- extern const char* note_post;
- extern const char* tip_pre;
- extern const char* tip_post;
- extern const char* list_item_pre;
- extern const char* list_item_post;
- extern const char* bold_pre_;
- extern const char* bold_post_;
- extern const char* italic_pre_;
- extern const char* italic_post_;
- extern const char* underline_pre_;
- extern const char* underline_post_;
- extern const char* teletype_pre_;
- extern const char* teletype_post_;
- extern const char* strikethrough_pre_;
- extern const char* strikethrough_post_;
- extern const char* quote_pre_;
- extern const char* quote_post_;
- extern const char* break_mark;
- extern const char* url_pre_;
- extern const char* url_post_;
- extern const char* link_pre_;
- extern const char* link_post_;
- extern const char* start_varlistentry_;
- extern const char* end_varlistentry_;
- extern const char* start_varlistterm_;
- extern const char* end_varlistterm_;
- extern const char* start_varlistitem_;
- extern const char* end_varlistitem_;
- extern const char* start_header_;
- extern const char* end_header_;
- extern const char* start_row_;
- extern const char* end_row_;
- extern const char* start_cell_;
- extern const char* end_cell_;
- extern const char* funcref_pre_;
- extern const char* funcref_post_;
- extern const char* classref_pre_;
- extern const char* classref_post_;
- extern const char* memberref_pre_;
- extern const char* memberref_post_;
- extern const char* enumref_pre_;
- extern const char* enumref_post_;
- extern const char* macroref_pre_;
- extern const char* macroref_post_;
- extern const char* headerref_pre_;
- extern const char* headerref_post_;
- extern const char* conceptref_pre_;
- extern const char* conceptref_post_;
- extern const char* globalref_pre_;
- extern const char* globalref_post_;
- extern const char* footnote_pre_;
- extern const char* footnote_post_;
- extern const char* escape_pre_;
- extern const char* escape_post_;
- extern const char* replaceable_pre_;
- extern const char* replaceable_post_;
-
namespace detail
{
struct markup {
@@ -111,8 +23,7 @@
char const* post;
};
- extern std::map<value::tag_type, markup> markups;
-
+ markup const& get_markup(value::tag_type);
std::ostream& operator<<(std::ostream&, markup const&);
}
}
Modified: trunk/tools/quickbook/src/phrase_tags.hpp
==============================================================================
--- trunk/tools/quickbook/src/phrase_tags.hpp (original)
+++ trunk/tools/quickbook/src/phrase_tags.hpp 2011-03-24 17:24:50 EDT (Thu, 24 Mar 2011)
@@ -21,6 +21,7 @@
(bold)(italic)(underline)(teletype)(strikethrough)(quote)(replaceable)
(footnote)
(escape)
+ (break_mark)
)
QUICKBOOK_VALUE_NAMED_TAGS(source_mode_tags, 0x550,
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