|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64988 - in trunk/tools/quickbook: . detail doc test
From: dnljms_at_[hidden]
Date: 2010-08-24 15:47:49
Author: danieljames
Date: 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
New Revision: 64988
URL: http://svn.boost.org/trac/boost/changeset/64988
Log:
Escapes in doc info fields.
Text files modified:
trunk/tools/quickbook/detail/actions.cpp | 62 +++++++++++++++++++--------------------
trunk/tools/quickbook/detail/actions_class.cpp | 11 ++++++
trunk/tools/quickbook/detail/actions_class.hpp | 17 ++++++++++
trunk/tools/quickbook/doc/quickbook.qbk | 1
trunk/tools/quickbook/doc_info.hpp | 57 +++++++++++++++++++++++------------
trunk/tools/quickbook/phrase.hpp | 3 -
trunk/tools/quickbook/test/doc-info-1.gold | 11 ++++--
trunk/tools/quickbook/test/doc-info-1.quickbook | 5 +-
8 files changed, 106 insertions(+), 61 deletions(-)
Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -1569,12 +1569,12 @@
void xml_author::operator()(std::pair<std::string, std::string> const& author) const
{
out << " <author>\n"
- << " <firstname>";
- detail::print_string(author.first, out.get());
- out << "</firstname>\n"
- << " <surname>";
- detail::print_string(author.second, out.get());
- out << "</surname>\n"
+ << " <firstname>"
+ << author.first
+ << "</firstname>\n"
+ << " <surname>"
+ << author.second
+ << "</surname>\n"
<< " </author>\n";
}
@@ -1587,9 +1587,9 @@
, copyright.first.end()
, xml_year(out));
- out << " <holder>";
- detail::print_string(copyright.second, out.get());
- out << "</holder>\n"
+ out << " <holder>"
+ << copyright.second
+ << "</holder>\n"
<< " </copyright>\n"
<< "\n"
;
@@ -1610,7 +1610,7 @@
if (actions.doc_id.empty())
actions.doc_id = detail::make_identifier(
- actions.doc_title.begin(),actions.doc_title.end());
+ actions.doc_title_raw.begin(),actions.doc_title_raw.end());
if (actions.doc_dirname.empty() && actions.doc_type == "library")
actions.doc_dirname = actions.doc_id;
@@ -1675,27 +1675,25 @@
<< " PUBLIC \"-//Boost//DTD BoostBook XML V1.0//EN\"\n"
<< " \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">\n"
<< '<' << actions.doc_type << "\n"
- << " id=\"";
- detail::print_string(actions.doc_id, out.get());
- out << "\"\n";
+ << " id=\""
+ << actions.doc_id
+ << "\"\n";
if(actions.doc_type == "library")
{
- out << " name=\"";
- detail::print_string(actions.doc_title, out.get());
- out << "\"\n";
+ out << " name=\"" << actions.doc_title << "\"\n";
}
if(!actions.doc_dirname.empty())
{
- out << " dirname=\"";
- detail::print_string(actions.doc_dirname, out.get());
- out << "\"\n";
+ out << " dirname=\""
+ << actions.doc_dirname
+ << "\"\n";
}
- out << " last-revision=\"";
- detail::print_string(actions.doc_last_revision, out.get());
- out << "\" \n"
+ out << " last-revision=\""
+ << actions.doc_last_revision
+ << "\" \n"
<< " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n";
if(actions.doc_type == "library") {
@@ -1725,11 +1723,10 @@
{
if (!actions.doc_title.empty())
{
- out<< " <title>";
- detail::print_string(actions.doc_title, out.get());
+ out << " <title>"
+ << actions.doc_title;
if (!actions.doc_version.empty()) {
- out << ' ';
- detail::print_string(actions.doc_version, out.get());
+ out << ' ' << actions.doc_version;
}
out<< "</title>\n\n\n";
}
@@ -1765,9 +1762,9 @@
{
out << " <legalnotice>\n"
<< " <para>\n"
- << " ";
- detail::print_string(actions.doc_license_1_1, out.get());
- out << "\n"
+ << " "
+ << actions.doc_license_1_1
+ << "\n"
<< " </para>\n"
<< " </legalnotice>\n"
<< "\n"
@@ -1826,9 +1823,9 @@
end = actions.doc_categories.end();
it != end; ++it)
{
- out << " <" << actions.doc_type << "category name=\"category:";
- detail::print_string(*it, out.get());
- out << "\"></" << actions.doc_type << "category>\n"
+ out << " <" << actions.doc_type << "category name=\"category:"
+ << *it
+ << "\"></" << actions.doc_type << "category>\n"
<< "\n"
;
}
@@ -1852,6 +1849,7 @@
void phrase_to_string_action::operator()(iterator first, iterator last) const
{
+ out.clear();
phrase.swap(out);
}
Modified: trunk/tools/quickbook/detail/actions_class.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.cpp (original)
+++ trunk/tools/quickbook/detail/actions_class.cpp 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -21,6 +21,7 @@
// header info
: doc_type()
, doc_title()
+ , doc_title_raw()
, doc_version()
, doc_id()
, doc_dirname()
@@ -72,9 +73,17 @@
// actions
, error(error_count)
+ , extract_doc_title(doc_title, phrase)
, extract_doc_license(doc_license, phrase)
, extract_doc_purpose(doc_purpose, phrase)
-
+ , extract_doc_version(doc_version, phrase)
+ , extract_doc_id(doc_id, phrase)
+ , extract_doc_dirname(doc_dirname, phrase)
+ , extract_copyright_second(copyright.second, phrase)
+ , extract_name_second(name.second, phrase)
+ , extract_name_first(name.first, phrase)
+ , extract_doc_last_revision(doc_last_revision, phrase)
+ , extract_doc_category(doc_category, phrase)
, syntax_p(temp, source_mode, macro, *this)
, code(out, phrase, syntax_p)
, code_block(phrase, phrase, syntax_p)
Modified: trunk/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.hpp (original)
+++ trunk/tools/quickbook/detail/actions_class.hpp 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -35,6 +35,7 @@
// header info
std::string doc_type;
std::string doc_title;
+ std::string doc_title_raw;
std::string doc_version;
std::string doc_id;
std::string doc_dirname;
@@ -47,6 +48,13 @@
std::string include_doc_id;
std::string doc_license_1_1;
std::string doc_purpose_1_1;
+ //temporary state
+ std::pair<std::string, std::string>
+ name;
+ std::pair<std::vector<std::string>, std::string>
+ copyright;
+ std::string doc_category;
+
// main output stream
collector out;
@@ -110,8 +118,17 @@
// actions
///////////////////////////////////////////////////////////////////////////
error_action error;
+ phrase_to_string_action extract_doc_title;
phrase_to_string_action extract_doc_license;
phrase_to_string_action extract_doc_purpose;
+ phrase_to_string_action extract_doc_version;
+ phrase_to_string_action extract_doc_id;
+ phrase_to_string_action extract_doc_dirname;
+ phrase_to_string_action extract_copyright_second;
+ phrase_to_string_action extract_name_second;
+ phrase_to_string_action extract_name_first;
+ phrase_to_string_action extract_doc_last_revision;
+ phrase_to_string_action extract_doc_category;
syntax_highlight syntax_p;
code_action code;
Modified: trunk/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- trunk/tools/quickbook/doc/quickbook.qbk (original)
+++ trunk/tools/quickbook/doc/quickbook.qbk 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -230,6 +230,7 @@
* In docbook, variable list entries can only have one `listitem`, so if an
entry has multiple values, merge them into one `listitem`.
* Support nested code snippets.
+* Allow escapes in doc info fields (apart from `\n`).
* Further work on quickbook 1.6, still not stable.
* Allow heading to have ids, using the syntax: `[heading:id title]`.
Modified: trunk/tools/quickbook/doc_info.hpp
==============================================================================
--- trunk/tools/quickbook/doc_info.hpp (original)
+++ trunk/tools/quickbook/doc_info.hpp 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -49,10 +49,9 @@
>> '[' >> space
>> (doc_types >> eps_p) [assign_a(actions.doc_type)]
>> hard_space
- >> ( *(anychar_p -
- (ch_p('[') | ']' | eol_p)
- )
- ) [assign_a(actions.doc_title)]
+ >> ( *(~eps_p(ch_p('[') | ']' | eol_p) >> char_)
+ ) [assign_a(actions.doc_title_raw)]
+ [actions.extract_doc_title]
>> !(
space >> '[' >>
quickbook_version
@@ -65,7 +64,7 @@
doc_version
| doc_id
| doc_dirname
- | doc_copyright [push_back_a(actions.doc_copyrights, copyright)]
+ | doc_copyright [push_back_a(actions.doc_copyrights, actions.copyright)]
| doc_purpose [actions.extract_doc_purpose]
| doc_category
| doc_authors
@@ -88,26 +87,28 @@
doc_version =
"version" >> hard_space
- >> (*(anychar_p - ']')) [assign_a(actions.doc_version)]
+ >> (*(~eps_p(']') >> char_)) [actions.extract_doc_version]
;
+ // TODO: Restrictions on doc_id?
doc_id =
"id" >> hard_space
- >> (*(anychar_p - ']')) [assign_a(actions.doc_id)]
+ >> (*(~eps_p(']') >> char_)) [actions.extract_doc_id]
;
+ // TODO: Restrictions on doc_dirname?
doc_dirname =
"dirname" >> hard_space
- >> (*(anychar_p - ']')) [assign_a(actions.doc_dirname)]
+ >> (*(~eps_p(']') >> char_)) [actions.extract_doc_dirname]
;
doc_copyright =
- "copyright" >> hard_space [clear_a(copyright.first)]
- >> +( repeat_p(4)[digit_p] [push_back_a(copyright.first)]
+ "copyright" >> hard_space [clear_a(actions.copyright.first)]
+ >> +( repeat_p(4)[digit_p] [push_back_a(actions.copyright.first)]
>> space
)
>> space
- >> (*(anychar_p - ']')) [assign_a(copyright.second)]
+ >> (*(~eps_p(']') >> char_)) [actions.extract_copyright_second]
;
doc_purpose =
@@ -117,24 +118,25 @@
doc_category =
"category" >> hard_space
- >> (*(anychar_p - ']')) [push_back_a(actions.doc_categories)]
+ >> (*(~eps_p(']') >> char_)) [actions.extract_doc_category]
+ [push_back_a(actions.doc_categories, actions.doc_category)]
;
doc_author =
'[' >> space
- >> (*(anychar_p - ',')) [assign_a(name.second)] // surname
+ >> (*(~eps_p(',') >> char_)) [actions.extract_name_second] // surname
>> ',' >> space
- >> (*(anychar_p - ']')) [assign_a(name.first)] // firstname
+ >> (*(~eps_p(']') >> char_)) [actions.extract_name_first] // firstname
>> ']'
;
doc_authors =
"authors"
>> hard_space
- >> doc_author [push_back_a(actions.doc_authors, name)]
+ >> doc_author [push_back_a(actions.doc_authors, actions.name)]
>> space
>> *( !(ch_p(',') >> space)
- >> doc_author [push_back_a(actions.doc_authors, name)]
+ >> doc_author [push_back_a(actions.doc_authors, actions.name)]
>> space
)
;
@@ -146,7 +148,7 @@
doc_last_revision =
"last-revision" >> hard_space
- >> (*(anychar_p - ']')) [assign_a(actions.doc_last_revision)]
+ >> (*(~eps_p(']') >> char_)) [actions.extract_doc_last_revision]
;
doc_source_mode =
@@ -176,16 +178,31 @@
| (anychar_p - ']') [actions.plain_char]
)
;
+
+ char_ =
+ str_p("\\n") [actions.break_]
+ | "\\ " // ignore an escaped space
+ | '\\' >> punct_p [actions.raw_char]
+ | "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")]
+ [actions.escape_unicode]
+ | "\\U" >> repeat_p(8) [chset<>("0-9a-fA-F")]
+ [actions.escape_unicode]
+ | (
+ ("'''" >> !eol_p) [actions.escape_pre]
+ >> *(anychar_p - "'''") [actions.raw_char]
+ >> str_p("'''") [actions.escape_post]
+ )
+ | anychar_p [actions.plain_char]
+ ;
}
bool unused;
- std::pair<std::string, std::string> name;
- std::pair<std::vector<std::string>, std::string> copyright;
std::string category;
rule<Scanner> doc_info, doc_title, doc_version, doc_id, doc_dirname,
doc_copyright, doc_purpose, doc_category, doc_authors,
doc_author, comment, space, hard_space, doc_license,
- doc_last_revision, doc_source_mode, phrase, quickbook_version;
+ doc_last_revision, doc_source_mode, phrase, quickbook_version,
+ char_;
phrase_grammar<Actions> common;
symbols<> doc_types;
Modified: trunk/tools/quickbook/phrase.hpp
==============================================================================
--- trunk/tools/quickbook/phrase.hpp (original)
+++ trunk/tools/quickbook/phrase.hpp 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -275,8 +275,7 @@
;
escape =
- str_p("\\n") [actions.break_]
- | "\\ " // ignore an escaped char
+ str_p("\\ ") // ignore an escaped space
| '\\' >> punct_p [actions.raw_char]
| "\\u" >> repeat_p(4) [chset<>("0-9a-fA-F")]
[actions.escape_unicode]
Modified: trunk/tools/quickbook/test/doc-info-1.gold
==============================================================================
--- trunk/tools/quickbook/test/doc-info-1.gold (original)
+++ trunk/tools/quickbook/test/doc-info-1.gold 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -1,17 +1,20 @@
<?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="document_information_1" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+<article id="karel_vom_u00e1_u010dka_and_tom_u00e1_u0161_martin_u00edk" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
xmlns:xi="http://www.w3.org/2001/XInclude">
- <title>Document Information 1</title>
+ <title>Karel Vomáčka and Tomáš Martiník</title>
<articleinfo>
<authorgroup>
<author>
- <firstname>Joe</firstname> <surname>Blow</surname>
+ <firstname>Matti</firstname> <surname>Meikäläinen</surname>
</author>
<author>
- <firstname>Jane</firstname> <surname>Doe</surname>
+ <firstname>Pero</firstname> <surname>Perić</surname>
</author>
</authorgroup>
+ <copyright>
+ <year>2010</year> <holder>Meðal-Jón and Jóna Jónsdóttir</holder>
+ </copyright>
<articlepurpose>
Inline code test: <code>1 + 2</code>
</articlepurpose>
Modified: trunk/tools/quickbook/test/doc-info-1.quickbook
==============================================================================
--- trunk/tools/quickbook/test/doc-info-1.quickbook (original)
+++ trunk/tools/quickbook/test/doc-info-1.quickbook 2010-08-24 15:47:46 EDT (Tue, 24 Aug 2010)
@@ -1,6 +1,7 @@
-[article Document Information 1
+[article Karel Vom\u00E1\u010Dka and Tom\u00E1\u0161 Martin\u00EDk
[quickbook 1.5]
-[authors [Blow, Joe], [Doe, Jane]]
+[authors [Meik\u00E4l\u00E4inen, Matti][Peri\u0107, Pero]]
+[copyright 2010 Me\u00F0al-J\u00F3n and J\u00F3na J\u00F3nsd\u00F3ttir]
[source-mode teletype]
[purpose Inline code test: `1 + 2`]
[category tests]
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