Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76645 - in branches/quickbook-dev/tools/quickbook: doc src test/doc-info
From: dnljms_at_[hidden]
Date: 2012-01-22 18:07:28


Author: danieljames
Date: 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
New Revision: 76645
URL: http://svn.boost.org/trac/boost/changeset/76645

Log:
Quickbook: Escaped markup in docinfo blocks.
Added:
   branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes1-1_7.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes1-1_7.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes2-1_7.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes2-1_7.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/doc/1_6.qbk | 24 ++++++++++++++++++++++++
   branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp | 22 ++++++++++++++++------
   branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp | 18 +++++++++++++++---
   branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp | 1 +
   branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2 | 2 ++
   5 files changed, 58 insertions(+), 9 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 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -341,4 +341,28 @@
 
 [endsect]
 
+[section:escaped_docinfo_attributes Escaped docbook in docinfo blocks]
+
+Quickbook docinfo attributes will probably never be as rich as docbook
+attributes so to allow more flexible markup, not supported by quickbook
+escaped docbook can be included in the docinfo block:
+
+```
+[article Some article
+[quickbook 1.7]
+'''<author>
+ <firstname>John</firstname>
+ <surname>Doe</surname>
+ <email>john.doe_at_[hidden]</email>
+</author>'''
+]
+```
+
+The escaped docbook is always placed at the end of the docinfo block,
+so it shouldn't be assumed that it will interleave the markup. A mixture
+of quickbook and docbook attributes for the same information will not work
+well.
+
+[endsect] [/escaped_docinfo_attributes]
+
 [endsect] [/ Quickbok 1.7]

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -76,7 +76,7 @@
     }
 
     // Any number of attributes, so stuff them into a vector.
- std::vector<value> consume_multiple_lists(value_consumer& c, value::tag_type tag)
+ std::vector<value> consume_multiple_values(value_consumer& c, value::tag_type tag)
     {
         std::vector<value> values;
         
@@ -166,21 +166,23 @@
 
         std::vector<std::string> duplicates;
 
+ std::vector<value> escaped_attributes = consume_multiple_values(values, doc_info_tags::escaped_attribute);
+
         value qbk_version = consume_list(values, doc_attributes::qbk_version, &duplicates);
         value compatibility_mode = consume_list(values, doc_attributes::compatibility_mode, &duplicates);
- consume_multiple_lists(values, doc_attributes::source_mode);
+ consume_multiple_values(values, doc_attributes::source_mode);
 
         value id = consume_value_in_list(values, doc_info_attributes::id, &duplicates);
         value dirname = consume_value_in_list(values, doc_info_attributes::dirname, &duplicates);
         value last_revision = consume_value_in_list(values, doc_info_attributes::last_revision, &duplicates);
         value purpose = consume_value_in_list(values, doc_info_attributes::purpose, &duplicates);
- std::vector<value> categories = consume_multiple_lists(values, doc_info_attributes::category);
+ std::vector<value> categories = consume_multiple_values(values, doc_info_attributes::category);
         value lang = consume_value_in_list(values, doc_info_attributes::lang, &duplicates);
         value version = consume_value_in_list(values, doc_info_attributes::version, &duplicates);
- std::vector<value> authors = consume_multiple_lists(values, doc_info_attributes::authors);
- std::vector<value> copyrights = consume_multiple_lists(values, doc_info_attributes::copyright);
+ std::vector<value> authors = consume_multiple_values(values, doc_info_attributes::authors);
+ std::vector<value> copyrights = consume_multiple_values(values, doc_info_attributes::copyright);
         value license = consume_value_in_list(values, doc_info_attributes::license, &duplicates);
- std::vector<value> biblioids = consume_multiple_lists(values, doc_info_attributes::biblioid);
+ std::vector<value> biblioids = consume_multiple_values(values, doc_info_attributes::biblioid);
         value xmlbase = consume_value_in_list(values, doc_info_attributes::xmlbase, &duplicates);
 
         values.finish();
@@ -504,6 +506,14 @@
             biblioid.finish();
         }
 
+ BOOST_FOREACH(value escaped, escaped_attributes)
+ {
+ tmp << "<!--quickbook-escape-prefix-->"
+ << escaped.get_quickbook()
+ << "<!--quickbook-escape-postfix-->"
+ ;
+ }
+
         if(doc_type != "library") {
             write_document_title(state.out, doc_title, version);
         }

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -70,6 +70,7 @@
 
         cl::rule<scanner>
                         doc_info_block, doc_attribute, doc_info_attribute,
+ doc_info_escaped_attributes,
                         doc_title, doc_simple, doc_phrase, doc_fallback,
                         doc_authors, doc_author,
                         doc_copyright, doc_copyright_holder,
@@ -146,9 +147,12 @@
>> !(qbk_since(106u) >> cl::eps_p(ph::var(local.source_mode_unset))
                                             [cl::assign_a(state.source_mode, "c++")]
                 )
- >> (*( local.doc_info_attribute
- >> space
- )) [state.values.sort()]
+ >> ( *( ( local.doc_info_attribute
+ | local.doc_info_escaped_attributes
+ )
+ >> space
+ )
+ ) [state.values.sort()]
>> ( ']'
>> (+eol | cl::end_p)
                 | cl::eps_p [error]
@@ -188,6 +192,14 @@
             *(~cl::eps_p(']') >> local.char_)
         ];
 
+ local.doc_info_escaped_attributes =
+ ("'''" >> !eol)
+ >> (*(cl::anychar_p - "'''")) [state.values.entry(ph::arg1, ph::arg2, doc_info_tags::escaped_attribute)]
+ >> ( cl::str_p("'''")
+ | cl::eps_p [error("Unclosed boostbook escape.")]
+ )
+ ;
+
         // Document Attributes
 
         local.quickbook_version =

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_tags.hpp 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -21,6 +21,7 @@
         (copyright_year)(copyright_year_end)(copyright_name)
         (license)
         (biblioid_class)(biblioid_value)
+ (escaped_attribute)
     )
 
     QUICKBOOK_VALUE_NAMED_TAGS(doc_attributes, 0x440,

Modified: branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -16,6 +16,8 @@
     [ quickbook-test author1 ]
     [ quickbook-test author2 ]
     [ quickbook-test empty-attributes ]
+ [ quickbook-test escaped_attributes1-1_7 ]
+ [ quickbook-test escaped_attributes2-1_7 ]
     [ quickbook-test duplicates-1.1 ]
     [ quickbook-test duplicates-1.5 ]
     [ quickbook-test source-mode-1.4 ]

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes1-1_7.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes1-1_7.gold 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
+<library id="escaped_name" name="Escaped name" dirname="escaped_name" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <libraryinfo>
+ <copyright>
+ <year>1325</year> <holder>John Doe</holder>
+ </copyright>
+ <librarycategory name="category:test"></librarycategory> <author>
+ <firstname>John</firstname>
+ <surname>Doe</surname>
+ <email>john.doe_at_[hidden]</email>
+</author>
+ </libraryinfo>
+ <title>Escaped name</title>
+</library>

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes1-1_7.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes1-1_7.quickbook 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -0,0 +1,11 @@
+[library Escaped name
+[quickbook 1.7]
+[copyright 1325 John Doe]
+'''<author>
+ <firstname>John</firstname>
+ <surname>Doe</surname>
+ <email>john.doe_at_[hidden]</email>
+</author>'''
+[category test]
+]
+

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes2-1_7.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes2-1_7.gold 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -0,0 +1,12 @@
+<?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="multiple_escaped_attributes" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Multiple escaped attributes</title>
+ <articleinfo>
+ <author>
+ <firstname>John</firstname>
+ <surname>Doe</surname>
+ <email>john.doe_at_[hidden]</email>
+</author><orgname>Acme Corporation</orgname></articleinfo>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes2-1_7.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/escaped_attributes2-1_7.quickbook 2012-01-22 18:07:26 EST (Sun, 22 Jan 2012)
@@ -0,0 +1,10 @@
+[article Multiple escaped attributes
+[quickbook 1.7]
+'''<author>
+ <firstname>John</firstname>
+ <surname>Doe</surname>
+ <email>john.doe_at_[hidden]</email>
+</author>'''
+'''<orgname>Acme Corporation</orgname>'''
+]
+


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