From bbffbc83cba2c5939b68ccbb84dfbd50cf514f14 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 12 Jul 2010 08:13:38 +0000 Subject: [PATCH] Merge quickbook, iostreams. [SVN r63917] --- detail/actions.cpp | 113 +++++++++++++++++++------------------ detail/utils.cpp | 7 --- detail/utils.hpp | 11 ---- doc/quickbook.qbk | 8 ++- test/doc-info-1.gold | 4 ++ test/quickbook-manual.gold | 3 + 6 files changed, 71 insertions(+), 75 deletions(-) diff --git a/detail/actions.cpp b/detail/actions.cpp index 97a756a..6071316 100644 --- a/detail/actions.cpp +++ b/detail/actions.cpp @@ -30,6 +30,23 @@ namespace quickbook char const* quickbook_get_time = "__quickbook_get_time__"; namespace { + char filter_identifier_char(char ch) + { + if (!std::isalnum(static_cast(ch))) + ch = '_'; + return static_cast(std::tolower(static_cast(ch))); + } + + template + inline std::string + make_identifier(Iterator const& first, Iterator const& last) + { + std::string out_name; + for (Iterator i = first; i != last; ++i) + out_name += filter_identifier_char(*i); + return out_name; + } + std::string fully_qualified_id(std::string const& library_id, std::string const& qualified_section_id, std::string const& section_id) @@ -98,7 +115,7 @@ namespace quickbook { out << "" << pre << str << post ; @@ -106,8 +123,8 @@ namespace quickbook else // version 1.3 and above { std::string id = qbk_version_n >= 106 ? - detail::make_identifier(first, last) : - detail::make_identifier(str.begin(), str.end()); + make_identifier(first, last) : + make_identifier(str.begin(), str.end()); std::string anchor = fully_qualified_id(library_id, qualified_section_id, id); @@ -133,8 +150,8 @@ namespace quickbook phrase.swap(str); std::string id = qbk_version_n >= 106 ? - detail::make_identifier(first, last) : - detail::make_identifier(str.begin(), str.end()); + make_identifier(first, last) : + make_identifier(str.begin(), str.end()); std::string anchor = fully_qualified_id(library_id, qualified_section_id, id); @@ -1038,7 +1055,7 @@ namespace quickbook else if(has_title) { table_id = fully_qualified_id(actions.doc_id, actions.qualified_section_id, - detail::make_identifier(first, last)); + make_identifier(first, last)); } } @@ -1126,7 +1143,7 @@ namespace quickbook void begin_section_action::operator()(iterator first, iterator last) const { section_id = element_id.empty() ? - detail::make_identifier(first, last) : + make_identifier(first, last) : element_id; if (section_level != 0) @@ -1514,7 +1531,7 @@ namespace quickbook // *before* anything else. if (actions.doc_id.empty()) - actions.doc_id = detail::make_identifier( + actions.doc_id = make_identifier( actions.doc_title.begin(),actions.doc_title.end()); if (actions.doc_dirname.empty() && actions.doc_type == "library") @@ -1693,64 +1710,50 @@ namespace quickbook } } - if (qbk_version_n < 103) + if (!actions.doc_purpose.empty()) { - if (!actions.doc_purpose_1_1.empty()) + if (actions.doc_type != "library") { - if (actions.doc_type == "library") - { - out << " <" << actions.doc_type << "purpose>\n" - << " "; - detail::print_string(actions.doc_purpose_1_1, out.get()); - out << " \n" - << "\n" - ; - } - else - { - invalid_attributes.push_back("purpose"); - } + invalid_attributes.push_back("purpose"); } - } - else - { - if (!actions.doc_purpose.empty()) + + if (qbk_version_n < 103) { - if (actions.doc_type == "library") - { - out << " <" << actions.doc_type << "purpose>\n" - << " " << actions.doc_purpose - << " \n" - << "\n" - ; - } - else - { - invalid_attributes.push_back("purpose"); - } + out << " <" << actions.doc_type << "purpose>\n" + << " "; + detail::print_string(actions.doc_purpose_1_1, out.get()); + out << " \n" + << "\n" + ; + } + else + { + out << " <" << actions.doc_type << "purpose>\n" + << " " << actions.doc_purpose + << " \n" + << "\n" + ; } } if (!actions.doc_categories.empty()) { - if (actions.doc_type == "library") - { - for(actions::string_list::const_iterator - it = actions.doc_categories.begin(), - end = actions.doc_categories.end(); - it != end; ++it) - { - out << " <" << actions.doc_type << "category name=\"category:"; - detail::print_string(*it, out.get()); - out << "\">\n" - << "\n" - ; - } - } - else + if (actions.doc_type != "library") { invalid_attributes.push_back("category"); } + + for(actions::string_list::const_iterator + it = actions.doc_categories.begin(), + end = actions.doc_categories.end(); + it != end; ++it) + { + out << " <" << actions.doc_type << "category name=\"category:"; + detail::print_string(*it, out.get()); + out << "\">\n" + << "\n" + ; + } } out << " \n" @@ -1762,7 +1765,7 @@ namespace quickbook detail::outwarn(actions.filename.file_string(),1) << (invalid_attributes.size() > 1 ? "Invalid attributes" : "Invalid attribute") - << " for '" << actions.doc_type << "': " + << " for '" << actions.doc_type << " document info': " << boost::algorithm::join(invalid_attributes, ", ") << "\n" ; diff --git a/detail/utils.cpp b/detail/utils.cpp index 5856572..bd71475 100644 --- a/detail/utils.cpp +++ b/detail/utils.cpp @@ -51,13 +51,6 @@ namespace quickbook { namespace detail out << ch; } - char filter_identifier_char(char ch) - { - if (!std::isalnum(static_cast(ch))) - ch = '_'; - return static_cast(std::tolower(static_cast(ch))); - } - // un-indent a code segment void unindent(std::string& program) { diff --git a/detail/utils.hpp b/detail/utils.hpp index e48a94f..4ca060b 100644 --- a/detail/utils.hpp +++ b/detail/utils.hpp @@ -21,17 +21,6 @@ namespace quickbook { namespace detail void print_char(char ch, std::ostream& out); void print_string(std::basic_string const& str, std::ostream& out); void print_space(char ch, std::ostream& out); - char filter_identifier_char(char ch); - - template - inline std::string - make_identifier(Iterator const& first, Iterator const& last) - { - std::string out_name; - for (Iterator i = first; i != last; ++i) - out_name += filter_identifier_char(*i); - return out_name; - } template struct var_wrapper diff --git a/doc/quickbook.qbk b/doc/quickbook.qbk index b4997d6..de6db35 100644 --- a/doc/quickbook.qbk +++ b/doc/quickbook.qbk @@ -196,8 +196,7 @@ Features include: * XML encode the documentation info correctly. * Avoid generating empty paragraphs. * No longer wraps block templates in paragraphs. - * Doesn't generate invalid doc_info members for docbook document types, - warns if you use any. + * Warns if you use invalid doc_info members for docbook document types. * Fixes some other causes of invalid boostbook, although it still generates invalid boostbook in places. * Improved grammar: @@ -801,6 +800,11 @@ In its absence, version 1.1 is assumed. =version=, =id=, =dirname=, =copyright=, =purpose=, =category=, =authors=, =license=, =last-revision= and =source-mode= are optional information. +=dirname=, =purpose= and =category= are boostbook attributes which are only +valid for =library= documents. If you use them for other document types, +quickbook will warn about them, but still use them, generating invalid markup, +that's just ignored by the style sheets. + =source-type= is a lowercase string setting the initial __source_mode__. If the =source-mode= field is omitted, a default value of =c++= will be used. diff --git a/test/doc-info-1.gold b/test/doc-info-1.gold index 301c50c..92aae4a 100644 --- a/test/doc-info-1.gold +++ b/test/doc-info-1.gold @@ -12,5 +12,9 @@ Jane Doe + + Inline code test: 1 + 2 + + diff --git a/test/quickbook-manual.gold b/test/quickbook-manual.gold index fb6ca91..8877d5d 100644 --- a/test/quickbook-manual.gold +++ b/test/quickbook-manual.gold @@ -21,6 +21,9 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + WikiWiki style documentation tool +
<link linkend="quickbook.intro"> Introduction</link>