|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r70178 - in trunk/tools/quickbook: . doc src test/doc-info
From: dnljms_at_[hidden]
Date: 2011-03-19 07:58:27
Author: danieljames
Date: 2011-03-19 07:58:26 EDT (Sat, 19 Mar 2011)
New Revision: 70178
URL: http://svn.boost.org/trac/boost/changeset/70178
Log:
Richer copyright syntax.
Added:
trunk/tools/quickbook/test/doc-info/copyright-fail1.quickbook
- copied unchanged from r68925, /branches/quickbook-filenames/tools/quickbook/test/doc-info/copyright-fail1.quickbook
trunk/tools/quickbook/test/doc-info/copyright1.gold
- copied unchanged from r68925, /branches/quickbook-filenames/tools/quickbook/test/doc-info/copyright1.gold
trunk/tools/quickbook/test/doc-info/copyright1.quickbook
- copied unchanged from r68925, /branches/quickbook-filenames/tools/quickbook/test/doc-info/copyright1.quickbook
Properties modified:
trunk/tools/quickbook/ (props changed)
Text files modified:
trunk/tools/quickbook/doc/quickbook.qbk | 2 ++
trunk/tools/quickbook/src/doc_info_actions.cpp | 24 +++++++++++++++++++++++-
trunk/tools/quickbook/src/doc_info_grammar.cpp | 30 ++++++++++++++++++++++++------
trunk/tools/quickbook/src/doc_info_tags.hpp | 2 +-
trunk/tools/quickbook/test/doc-info/Jamfile.v2 | 2 ++
5 files changed, 52 insertions(+), 8 deletions(-)
Modified: trunk/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- trunk/tools/quickbook/doc/quickbook.qbk (original)
+++ trunk/tools/quickbook/doc/quickbook.qbk 2011-03-19 07:58:26 EDT (Sat, 19 Mar 2011)
@@ -277,6 +277,8 @@
This simplifies the implementation and makes it easier to parse
more complicated data structures.
* Improved error messages for unknown doc info attributes.
+* Richer copyright syntax. Now understands:
+ `[copyright 2001-2006, 2010 One person, 2008 Another person]`.
* Quickbook 1.6:
* Scope source mode changes to the file they're made in.
Modified: trunk/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_actions.cpp (original)
+++ trunk/tools/quickbook/src/doc_info_actions.cpp 2011-03-19 07:58:26 EDT (Sat, 19 Mar 2011)
@@ -11,6 +11,7 @@
#include <sstream>
#include <boost/bind.hpp>
#include <boost/algorithm/string/join.hpp>
+#include <boost/lexical_cast.hpp>
#include "quickbook.hpp"
#include "utils.hpp"
#include "input_path.hpp"
@@ -259,7 +260,28 @@
while(copyright.is(doc_info_tags::copyright_year))
{
- tmp << " <year>" << copyright.consume().get_quickbook() << "</year>\n";
+ int year_start =
+ boost::lexical_cast<int>(copyright.consume().get_quickbook());
+ int year_end =
+ copyright.is(doc_info_tags::copyright_year_end) ?
+ boost::lexical_cast<int>(copyright.consume().get_quickbook()) :
+ year_start;
+
+ if (year_end < year_start) {
+ ++actions.error_count;
+
+ detail::outerr(actions.filename,
+ copyright.begin()->get_position().line)
+ << "Invalid year range: "
+ << year_start
+ << "-"
+ << year_end
+ << "."
+ << std::endl;
+ }
+
+ for(; year_start <= year_end; ++year_start)
+ tmp << " <year>" << year_start << "</year>\n";
}
tmp << " <holder>"
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 2011-03-19 07:58:26 EDT (Sat, 19 Mar 2011)
@@ -61,7 +61,8 @@
cl::rule<scanner>
doc_title, doc_simple, doc_phrase, doc_fallback,
- doc_copyright, doc_authors, doc_author,
+ doc_authors, doc_author,
+ doc_copyright, doc_copyright_year, doc_copyright_holder,
doc_source_mode, doc_biblioid,
quickbook_version, char_;
cl::symbols<> doc_types;
@@ -152,17 +153,34 @@
local.attribute_rules[doc_info_attributes::last_revision] = &local.doc_simple;
local.attribute_rules[doc_info_attributes::lang] = &local.doc_simple;
+ local.doc_copyright_year = cl::repeat_p(4)[cl::digit_p];
+ local.doc_copyright_holder
+ = *( ~cl::eps_p
+ ( ']'
+ | ',' >> space >> local.doc_copyright_year
+ )
+ >> local.char_
+ );
+
local.doc_copyright =
- actions.values.scoped(doc_info_attributes::copyright)
+ *actions.values.scoped(doc_info_attributes::copyright)
[
- +( cl::repeat_p(4)[cl::digit_p]
+ +( local.doc_copyright_year
[actions.values.entry(doc_info_tags::copyright_year)]
- >> space
+ >> space
+ >> !( '-'
+ >> space
+ >> local.doc_copyright_year
+ [actions.values.entry(doc_info_tags::copyright_year_end)]
+ )
+ >> !cl::ch_p(',')
)
- >> space
- >> (*(~cl::eps_p(']') >> local.char_))
+ >> space
+ >> local.doc_copyright_holder
[actions.values.tag(doc_info_tags::copyright_name)]
[actions.docinfo_value]
+ >> !cl::ch_p(',')
+ >> space
]
;
Modified: trunk/tools/quickbook/src/doc_info_tags.hpp
==============================================================================
--- trunk/tools/quickbook/src/doc_info_tags.hpp (original)
+++ trunk/tools/quickbook/src/doc_info_tags.hpp 2011-03-19 07:58:26 EDT (Sat, 19 Mar 2011)
@@ -17,7 +17,7 @@
(type)
(title)
(author_surname)(author_first)
- (copyright_year)(copyright_name)
+ (copyright_year)(copyright_year_end)(copyright_name)
(license)
(biblioid_class)(biblioid_value)
)
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 2011-03-19 07:58:26 EDT (Sat, 19 Mar 2011)
@@ -21,4 +21,6 @@
[ quickbook-test source-mode-1.4 ]
[ quickbook-test source-mode-1.5 ]
[ quickbook-test source-mode-1.6 ]
+ [ quickbook-test copyright1 ]
+ [ quickbook-fail-test copyright-fail1 ]
;
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