|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r84153 - in trunk/tools/quickbook: doc src test/doc-info
From: dnljms_at_[hidden]
Date: 2013-05-05 09:47:27
Author: danieljames
Date: 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
New Revision: 84153
URL: http://svn.boost.org/trac/boost/changeset/84153
Log:
Macros in docinfo blocks for 1.6. Refs #8543.
Added:
trunk/tools/quickbook/test/doc-info/macros1-1_5.gold (contents, props changed)
trunk/tools/quickbook/test/doc-info/macros1-1_5.quickbook (contents, props changed)
trunk/tools/quickbook/test/doc-info/macros1-1_6.gold (contents, props changed)
trunk/tools/quickbook/test/doc-info/macros1-1_6.quickbook (contents, props changed)
trunk/tools/quickbook/test/doc-info/macros1-inc_1_6.quickbook (contents, props changed)
Text files modified:
trunk/tools/quickbook/doc/1_6.qbk | 13 +++++++++++++
trunk/tools/quickbook/doc/change_log.qbk | 1 +
trunk/tools/quickbook/src/doc_info_grammar.cpp | 20 ++++++++++++++++++--
trunk/tools/quickbook/test/doc-info/Jamfile.v2 | 2 ++
4 files changed, 34 insertions(+), 2 deletions(-)
Modified: trunk/tools/quickbook/doc/1_6.qbk
==============================================================================
--- trunk/tools/quickbook/doc/1_6.qbk (original)
+++ trunk/tools/quickbook/doc/1_6.qbk 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -70,6 +70,19 @@
[endsect] [/docinfo]
+[section:doc-info-macros Macros in docinfo block]
+
+You can now expand macros in text fields in the docinfo block. In the top
+docinfo block only the predefined macros are available, but in nested documents
+macros defined in the parent document are also available.
+
+There's a small bug here - this leaks into older versions for the `license`
+and `purpose` fields, but since only the predefined macros are available, it's
+unlikely to break any existing documents. So I'd rather not complicate the code
+further by fixing that.
+
+[endsect]
+
[section:scope Scoping templates and macros]
A long standing quickbook bug is that macros are scoped by file, but templates
Modified: trunk/tools/quickbook/doc/change_log.qbk
==============================================================================
--- trunk/tools/quickbook/doc/change_log.qbk (original)
+++ trunk/tools/quickbook/doc/change_log.qbk 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -291,6 +291,7 @@
* 1.6 changes:
* Better template argument parsing, so that it understands things
like escaped markup.
+ * Support for using macros in the doc info block.
* Internal changes:
* Convert to use `boost::string_ref`.
* Clean up the source map implementation (used to get the correct
Modified: trunk/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ trunk/tools/quickbook/src/doc_info_grammar.cpp 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -75,7 +75,7 @@
doc_authors, doc_author,
doc_copyright, doc_copyright_holder,
doc_source_mode, doc_biblioid, doc_compatibility_mode,
- quickbook_version, char_;
+ quickbook_version, macro, char_;
cl::uint_parser<int, 10, 4, 4> doc_copyright_year;
cl::symbols<> doc_types;
cl::symbols<value::tag_type> doc_info_attributes;
@@ -119,6 +119,7 @@
// Actions
error_action error(state);
plain_char_action plain_char(state.phrase, state);
+ do_macro_action do_macro(state.phrase, state);
scoped_parser<to_value_scoped_action> to_value(state);
doc_info_details =
@@ -302,6 +303,21 @@
local.attribute_rules[doc_info_attributes::biblioid] = &local.doc_biblioid;
- local.char_ = escape | cl::anychar_p[plain_char];
+ local.char_ =
+ escape
+ | local.macro
+ | cl::anychar_p[plain_char];
+ ;
+
+ local.macro =
+ cl::eps_p
+ ( ( state.macro
+ >> ~cl::eps_p(cl::alpha_p | '_')
+ // must not be followed by alpha or underscore
+ )
+ & macro_identifier // must be a valid macro for the current version
+ )
+ >> state.macro [do_macro]
+ ;
}
}
Modified: trunk/tools/quickbook/test/doc-info/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/doc-info/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/doc-info/Jamfile.v2 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -20,6 +20,8 @@
[ quickbook-test escaped_attributes2-1_7 ]
[ quickbook-test duplicates-1.1 ]
[ quickbook-test duplicates-1.5 ]
+ [ quickbook-test macros1-1_5 ]
+ [ quickbook-test macros1-1_6 ]
[ quickbook-test source-mode-1.4 ]
[ quickbook-test source-mode-1.5 ]
[ quickbook-test source-mode-1.6 ]
Added: trunk/tools/quickbook/test/doc-info/macros1-1_5.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/doc-info/macros1-1_5.gold 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -0,0 +1,11 @@
+<?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="macro_shouldn_t_expand____date__" last-revision="__DATE__" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Macro shouldn't expand: __DATE__</title>
+ <articleinfo>
+ <articlepurpose>
+ Unfortunately this does expand: 2000-Dec-20, but I'm not fixing it, as I don't
+ think it'll cause any real problems.
+ </articlepurpose>
+ </articleinfo>
+</article>
Added: trunk/tools/quickbook/test/doc-info/macros1-1_5.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/doc-info/macros1-1_5.quickbook 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -0,0 +1,6 @@
+[article Macro shouldn't expand: __DATE__
+ [quickbook 1.5]
+ [last-revision __DATE__]
+ [purpose Unfortunately this does expand: __DATE__, but I'm not fixing it,
+ as I don't think it'll cause any real problems.]
+]
Added: trunk/tools/quickbook/test/doc-info/macros1-1_6.gold
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/doc-info/macros1-1_6.gold 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -0,0 +1,8 @@
+<?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="testing_date_date" last-revision="2000-Dec-20" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Testing date: 2000-Dec-20</title>
+ <chapter id="testing_macro_date_nested_macro" last-revision="5 May 2013" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Testing macro date: 5 May 2013</title>
+ </chapter>
+</article>
Added: trunk/tools/quickbook/test/doc-info/macros1-1_6.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/doc-info/macros1-1_6.quickbook 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -0,0 +1,7 @@
+[article Testing date: __DATE__
+ [quickbook 1.6]
+ [last-revision __DATE__]
+]
+
+[def NESTED_MACRO 5 May 2013]
+[include macros1-inc_1_6.quickbook]
Added: trunk/tools/quickbook/test/doc-info/macros1-inc_1_6.quickbook
==============================================================================
--- (empty file)
+++ trunk/tools/quickbook/test/doc-info/macros1-inc_1_6.quickbook 2013-05-05 09:47:26 EDT (Sun, 05 May 2013)
@@ -0,0 +1,4 @@
+[chapter Testing macro date: NESTED_MACRO
+ [quickbook 1.6]
+ [last-revision NESTED_MACRO]
+]
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