Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55913 - in trunk/tools/quickbook: . detail test
From: daniel_james_at_[hidden]
Date: 2009-08-31 07:38:00


Author: danieljames
Date: 2009-08-31 07:37:59 EDT (Mon, 31 Aug 2009)
New Revision: 55913
URL: http://svn.boost.org/trac/boost/changeset/55913

Log:
Table ids. Refs #1194.
Text files modified:
   trunk/tools/quickbook/block.hpp | 37 ++++++++++++++++++++++++++-----------
   trunk/tools/quickbook/detail/actions.cpp | 20 ++++++++++++++++----
   trunk/tools/quickbook/detail/actions.hpp | 2 +-
   trunk/tools/quickbook/detail/actions_class.hpp | 2 +-
   trunk/tools/quickbook/test/Jamfile.v2 | 1 +
   5 files changed, 45 insertions(+), 17 deletions(-)

Modified: trunk/tools/quickbook/block.hpp
==============================================================================
--- trunk/tools/quickbook/block.hpp (original)
+++ trunk/tools/quickbook/block.hpp 2009-08-31 07:37:59 EDT (Mon, 31 Aug 2009)
@@ -10,6 +10,7 @@
 #if !defined(BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP)
 #define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
 
+#include "./detail/quickbook.hpp"
 #include "./detail/utils.hpp"
 #include "./phrase.hpp"
 #include <boost/spirit/include/classic_core.hpp>
@@ -22,7 +23,6 @@
 namespace quickbook
 {
     using namespace boost::spirit::classic;
- extern unsigned qbk_version_n;
 
     template <typename Actions, bool skip_initial_spaces = false>
     struct block_grammar : grammar<block_grammar<Actions> >
@@ -122,19 +122,32 @@
                         | eps_p [actions.error]
                         )
                     ;
+
+ element_id =
+ ':'
+ >>
+ (
+ if_p(qbk_since(105u)) [space]
+ >> (+(alnum_p | '_')) [assign_a(actions.element_id)]
+ | eps_p [actions.element_id_warning]
+ [assign_a(actions.element_id)]
+ )
+ | eps_p [assign_a(actions.element_id)]
+ ;
+
+ element_id_1_5 =
+ if_p(qbk_since(105u)) [
+ element_id
+ ]
+ .else_p [
+ eps_p [assign_a(actions.element_id)]
+ ]
+ ;
 
                 begin_section =
                        "section"
>> hard_space
- >> ( ':' >>
- (
- if_p(qbk_since(105u)) [space]
- >> (+(alnum_p | '_')) [assign_a(actions.element_id)]
- | eps_p [actions.section_warning]
- [assign_a(actions.element_id)]
- )
- | eps_p [assign_a(actions.element_id)]
- )
+ >> element_id
>> phrase [actions.begin_section]
                     ;
 
@@ -290,6 +303,8 @@
                 table =
                     "table"
>> (eps_p(*blank_p >> eol_p) | hard_space)
+ >> element_id_1_5
+ >> (eps_p(*blank_p >> eol_p) | space)
>> (*(anychar_p - eol)) [assign_a(actions.table_title)]
>> +eol
>> *table_row
@@ -426,7 +441,7 @@
                             xinclude, include, hard_space, eol, paragraph_end,
                             template_, template_id, template_formal_arg,
                             template_body, identifier, dummy_block, import,
- inside_paragraph;
+ inside_paragraph, element_id, element_id_1_5;
 
             symbols<> paragraph_end_markups;
 

Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2009-08-31 07:37:59 EDT (Mon, 31 Aug 2009)
@@ -819,10 +819,19 @@
         std::string::iterator first = actions.table_title.begin();
         std::string::iterator last = actions.table_title.end();
         bool has_title = first != last;
+
+ std::string table_id;
+ if(qbk_version_n >= 105) {
+ if(!actions.element_id.empty()) table_id = actions.element_id;
+ else if(has_title) table_id = detail::make_identifier(first, last);
+ }
 
         if (has_title)
         {
- actions.out << "<table frame=\"all\">\n";
+ actions.out << "<table frame=\"all\"";
+ if(!table_id.empty())
+ actions.out << " id=\"" << table_id << "\"";
+ actions.out << ">\n";
             actions.out << "<title>";
             while (first != last)
                 detail::print_char(*first++, actions.out.get());
@@ -830,7 +839,10 @@
         }
         else
         {
- actions.out << "<informaltable frame=\"all\">\n";
+ actions.out << "<informaltable frame=\"all\"";
+ if(!table_id.empty())
+ actions.out << " id=\"" << table_id << "\"";
+ actions.out << ">\n";
         }
 
         actions.out << "<tgroup cols=\"" << actions.table_span << "\">\n";
@@ -965,10 +977,10 @@
         }
     }
     
- void section_warning_action::operator()(iterator first, iterator) const
+ void element_id_warning_action::operator()(iterator first, iterator) const
     {
         boost::spirit::classic::file_position const pos = first.get_position();
- detail::outwarn(pos.file,pos.line) << "Empty section id after 'section:'.\n";
+ detail::outwarn(pos.file,pos.line) << "Empty id.\n";
     }
 
     fs::path path_difference(fs::path const& outdir, fs::path const& path)

Modified: trunk/tools/quickbook/detail/actions.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.hpp (original)
+++ trunk/tools/quickbook/detail/actions.hpp 2009-08-31 07:37:59 EDT (Mon, 31 Aug 2009)
@@ -709,7 +709,7 @@
         int& error_count;
    };
    
- struct section_warning_action
+ struct element_id_warning_action
    {
        void operator()(iterator first, iterator last) const;
    };

Modified: trunk/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- trunk/tools/quickbook/detail/actions_class.hpp (original)
+++ trunk/tools/quickbook/detail/actions_class.hpp 2009-08-31 07:37:59 EDT (Mon, 31 Aug 2009)
@@ -192,7 +192,7 @@
 
         begin_section_action begin_section;
         end_section_action end_section;
- section_warning_action section_warning;
+ element_id_warning_action element_id_warning;
         xinclude_action xinclude;
         include_action include;
         import_action import;

Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 (original)
+++ trunk/tools/quickbook/test/Jamfile.v2 2009-08-31 07:37:59 EDT (Mon, 31 Aug 2009)
@@ -27,6 +27,7 @@
     [ quickbook-test import ]
     [ quickbook-test section_1_4 ]
     [ quickbook-test section_1_5 ]
+ [ quickbook-test table_1_5 ]
     [ quickbook-fail-test fail-include ]
     [ quickbook-fail-test fail-import ]
     [ quickbook-fail-test fail-template-arguments1 ]


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