Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68890 - in branches/quickbook-filenames/tools/quickbook: src test/doc-info
From: dnljms_at_[hidden]
Date: 2011-02-14 19:26:28


Author: danieljames
Date: 2011-02-14 19:26:26 EST (Mon, 14 Feb 2011)
New Revision: 68890
URL: http://svn.boost.org/trac/boost/changeset/68890

Log:
Richer copyright syntax.

Year ranges and multiple copyrights per copyright attribute (comma
separated).
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp | 24 +++++++++++++++++++++++-
   branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp | 30 ++++++++++++++++++++++++------
   branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp | 2 +-
   branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2 | 2 ++
   4 files changed, 50 insertions(+), 8 deletions(-)

Modified: branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_actions.cpp 2011-02-14 19:26:26 EST (Mon, 14 Feb 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: branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp 2011-02-14 19:26:26 EST (Mon, 14 Feb 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: branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_tags.hpp 2011-02-14 19:26:26 EST (Mon, 14 Feb 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: branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2 (original)
+++ branches/quickbook-filenames/tools/quickbook/test/doc-info/Jamfile.v2 2011-02-14 19:26:26 EST (Mon, 14 Feb 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