Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85326 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2013-08-12 17:35:29


Author: danieljames
Date: 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013)
New Revision: 85326
URL: http://svn.boost.org/trac/boost/changeset/85326

Log:
Generate `simpara` for `ordered_list` and `itemized_list`.

Also fixes block elements nested in lists.

Text files modified:
   trunk/tools/quickbook/src/actions.cpp | 5 ++
   trunk/tools/quickbook/src/actions.hpp | 15 ++++++++
   trunk/tools/quickbook/src/block_element_grammar.cpp | 7 +++
   trunk/tools/quickbook/src/main_grammar.cpp | 75 +++++++++++++++++++++++++--------------
   trunk/tools/quickbook/src/state.cpp | 1
   trunk/tools/quickbook/src/state.hpp | 1
   trunk/tools/quickbook/test/elements-1_6.gold | 16 ++++----
   trunk/tools/quickbook/test/list_test-1_6.gold | 8 ++--
   trunk/tools/quickbook/test/templates-1_6.gold | 4 +-
   trunk/tools/quickbook/test/templates-1_7.gold | 4 +-
   10 files changed, 91 insertions(+), 45 deletions(-)

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/src/actions.cpp 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -331,6 +331,11 @@
         }
     }
 
+ void explicit_list_action::operator()() const
+ {
+ state.explicit_list = true;
+ }
+
     void phrase_end_action::operator()() const
     {
         write_anchors(state, state.phrase);

Modified: trunk/tools/quickbook/src/actions.hpp
==============================================================================
--- trunk/tools/quickbook/src/actions.hpp Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/src/actions.hpp 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -119,6 +119,21 @@
         quickbook::state& state;
     };
 
+ struct explicit_list_action
+ {
+ // implicit paragraphs
+ // doesn't output the paragraph if it's only whitespace.
+
+ explicit_list_action(
+ quickbook::state& state)
+ : state(state) {}
+
+ void operator()() const;
+ void operator()(parse_iterator, parse_iterator) const { (*this)(); }
+
+ quickbook::state& state;
+ };
+
     struct phrase_end_action
     {
         phrase_end_action(quickbook::state& state) :

Modified: trunk/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/block_element_grammar.cpp Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/src/block_element_grammar.cpp 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -48,6 +48,7 @@
         error_action error(state);
         element_id_warning_action element_id_warning(state);
         raw_char_action raw_char(state.phrase);
+ explicit_list_action explicit_list(state);
         scoped_parser<to_value_scoped_action> to_value(state);
 
         local.element_id =
@@ -261,7 +262,11 @@
             ("itemized_list", element_info(element_info::nested_block, &local.list, block_tags::itemized_list, 106))
             ;
 
- local.list = *local.cell;
+ local.list =
+ *( cl::eps_p [explicit_list]
+ >> local.cell
+ )
+ ;
 
         local.cell =
                 space

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -35,11 +35,18 @@
     struct list_stack_item {
         // Is this the root of the context
         // (e.g. top, template, table cell etc.)
- enum root_type {
- not_root = 0,
- top_root = 1,
- nested_root = 2
- } root;
+ enum list_item_type {
+ // flags
+ is_list = 1,
+ indented_code = 2,
+ block_root = 4,
+
+ // item types
+ syntactic_list = 3,
+ explicit_list = 5,
+ top_level = 6,
+ nested_level = 4
+ } type;
 
         unsigned int indent; // Indent of list marker
                               // (or paragraph if not in a list)
@@ -52,11 +59,11 @@
         // * List item
         // |indent2
 
- list_stack_item(root_type r) :
- root(r), indent(0), indent2(0), mark('\0') {}
+ list_stack_item(list_item_type r) :
+ type(r), indent(0), indent2(0), mark('\0') {}
 
         list_stack_item(char mark, unsigned int indent, unsigned int indent2) :
- root(not_root), indent(indent), indent2(indent2), mark(mark)
+ type(syntactic_list), indent(indent), indent2(indent2), mark(mark)
         {}
 
     };
@@ -163,12 +170,13 @@
 
         void push_list_item(list_stack_item const& item) {
             list_stack.push(item);
- state_.in_list = !list_stack.top().root;
+ state_.in_list = list_stack.top().type & list_stack_item::is_list;
         }
 
         void pop_list_item() {
             list_stack.pop();
- state_.in_list = !list_stack.empty() && !list_stack.top().root;
+ state_.in_list = !list_stack.empty() &&
+ list_stack.top().type & list_stack_item::is_list;
         }
     };
 
@@ -262,7 +270,6 @@
             l(l) {}
 
         bool operator()() const {
- //return !l.list_stack.top().root;
             return l.state_.in_list;
         }
     };
@@ -443,11 +450,13 @@
         // Blocks contains within an element, e.g. a table cell or a footnote.
         inside_paragraph =
             state.values.save()
- [ qbk_ver(107u)
- >> (*eol) [start_nested_blocks]
- >> (*local.top_level) [end_blocks]
- | qbk_ver(0, 107u)
- >> local.inside_paragraph
+ [ cl::eps_p [start_nested_blocks]
+ >> ( qbk_ver(107u)
+ >> (*eol)
+ >> (*local.top_level)
+ | qbk_ver(0, 107u)
+ >> local.inside_paragraph
+ ) [end_blocks]
             ]
             ;
 
@@ -1044,12 +1053,17 @@
 
     void main_grammar_local::start_blocks_impl(parse_iterator, parse_iterator)
     {
- push_list_item(list_stack_item(list_stack_item::top_root));
+ push_list_item(list_stack_item(list_stack_item::top_level));
     }
 
     void main_grammar_local::start_nested_blocks_impl(parse_iterator, parse_iterator)
     {
- push_list_item(list_stack_item(list_stack_item::nested_root));
+ bool explicit_list = state_.explicit_list;
+ state_.explicit_list = false;
+
+ push_list_item(list_stack_item(explicit_list ?
+ list_stack_item::explicit_list :
+ list_stack_item::nested_level));
     }
 
     void main_grammar_local::end_blocks_impl(parse_iterator, parse_iterator)
@@ -1088,7 +1102,7 @@
             unsigned int new_indent = indent_length(first, last);
 
             if (new_indent > list_stack.top().indent2) {
- if (list_stack.top().root != list_stack_item::nested_root) {
+ if (list_stack.top().type & list_stack_item::indented_code) {
                     block_type = block_types::code;
                 }
                 else {
@@ -1096,7 +1110,8 @@
                 }
             }
             else {
- while (!list_stack.top().root && new_indent < list_stack.top().indent)
+ while (list_stack.top().type == list_stack_item::syntactic_list
+ && new_indent < list_stack.top().indent)
                 {
                     char mark = list_stack.top().mark;
 
@@ -1106,7 +1121,8 @@
                     list_indent = list_stack.top().indent;
                 }
 
- if (!list_stack.top().root && new_indent == list_stack.top().indent)
+ if (list_stack.top().type == list_stack_item::syntactic_list
+ && new_indent == list_stack.top().indent)
                 {
                     // If the paragraph is aligned with the list item's marker,
                     // then end the current list item if that's aligned (or to
@@ -1129,7 +1145,7 @@
                     list_stack_item save = list_stack.top();
                     pop_list_item();
 
- assert(list_stack.top().root ?
+ assert(list_stack.top().type != list_stack_item::syntactic_list ?
                         new_indent >= list_stack.top().indent :
                         new_indent > list_stack.top().indent);
 
@@ -1148,7 +1164,8 @@
                 block_type = block_types::paragraph;
             }
 
- if (qbk_version_n == 106u && !list_stack.top().root) {
+ if (qbk_version_n == 106u &&
+ list_stack.top().type == list_stack_item::syntactic_list) {
                 detail::outerr(state_.current_file, first)
                     << "Nested blocks in lists won't be supported in "
                     << "quickbook 1.6"
@@ -1159,7 +1176,7 @@
         else {
             clear_stack();
 
- if (list_stack.top().root != list_stack_item::nested_root &&
+ if (list_stack.top().type & list_stack_item::indented_code &&
                     last != first)
                 block_type = block_types::code;
             else
@@ -1174,13 +1191,14 @@
         unsigned int new_indent2 = indent_length(first, last);
         char mark = *mark_pos;
 
- if (list_stack.top().root == list_stack_item::top_root &&
+ if (list_stack.top().type == list_stack_item::top_level &&
                 new_indent > 0) {
             block_type = block_types::code;
             return;
         }
 
- if (list_stack.top().root || new_indent > list_indent) {
+ if (list_stack.top().type != list_stack_item::syntactic_list ||
+ new_indent > list_indent) {
             state_.start_list(mark);
             push_list_item(list_stack_item(mark, new_indent, new_indent2));
         }
@@ -1190,7 +1208,8 @@
         else {
             // This should never reach root, since the first list
             // has indentation 0.
- while(!list_stack.top().root && new_indent < list_stack.top().indent)
+ while(list_stack.top().type == list_stack_item::syntactic_list &&
+ new_indent < list_stack.top().indent)
             {
                 char mark = list_stack.top().mark;
 
@@ -1219,7 +1238,7 @@
 
     void main_grammar_local::clear_stack()
     {
- while (!list_stack.top().root) {
+ while (list_stack.top().type == list_stack_item::syntactic_list) {
             char mark = list_stack.top().mark;
 
             state_.end_list_item();

Modified: trunk/tools/quickbook/src/state.cpp
==============================================================================
--- trunk/tools/quickbook/src/state.cpp Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/src/state.cpp 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -40,6 +40,7 @@
         , callouts()
         , callout_depth(0)
         , dependencies()
+ , explicit_list(false)
         , in_list(false)
 
         , imported(false)

Modified: trunk/tools/quickbook/src/state.hpp
==============================================================================
--- trunk/tools/quickbook/src/state.hpp Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/src/state.hpp 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -52,6 +52,7 @@
         value_builder callouts; // callouts are global as
         int callout_depth; // they don't nest.
         dependency_tracker dependencies;
+ bool explicit_list; // set when using a list
         bool in_list;
 
     // state saved for files and templates.

Modified: trunk/tools/quickbook/test/elements-1_6.gold
==============================================================================
--- trunk/tools/quickbook/test/elements-1_6.gold Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/test/elements-1_6.gold 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -5,26 +5,26 @@
   <title>1.6 Elements</title>
   <orderedlist>
     <listitem>
- <para>
+ <simpara>
         item1
- </para>
+ </simpara>
     </listitem>
     <listitem>
- <para>
+ <simpara>
         item2
- </para>
+ </simpara>
     </listitem>
   </orderedlist>
   <itemizedlist>
     <listitem>
- <para>
+ <simpara>
         item1
- </para>
+ </simpara>
     </listitem>
     <listitem>
- <para>
+ <simpara>
         item2
- </para>
+ </simpara>
     </listitem>
   </itemizedlist>
   <simplesect><title>A <emphasis role="bold">simplesect</emphasis>!</title></simplesect>

Modified: trunk/tools/quickbook/test/list_test-1_6.gold
==============================================================================
--- trunk/tools/quickbook/test/list_test-1_6.gold Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/test/list_test-1_6.gold 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -315,18 +315,18 @@
           <thead>
             <row>
               <entry>
- <simpara>
+ <para>
                   Heading
- </simpara>
+ </para>
               </entry>
             </row>
           </thead>
           <tbody>
             <row>
               <entry>
- <simpara>
+ <para>
                   Cell
- </simpara>
+ </para>
               </entry>
             </row>
           </tbody>

Modified: trunk/tools/quickbook/test/templates-1_6.gold
==============================================================================
--- trunk/tools/quickbook/test/templates-1_6.gold Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/test/templates-1_6.gold 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -240,9 +240,9 @@
     </orderedlist>
     <orderedlist>
       <listitem>
- <para>
+ <simpara>
           <code><phrase role="identifier">code</phrase></code>
- </para>
+ </simpara>
       </listitem>
     </orderedlist>
   </section>

Modified: trunk/tools/quickbook/test/templates-1_7.gold
==============================================================================
--- trunk/tools/quickbook/test/templates-1_7.gold Mon Aug 12 17:22:53 2013 (r85325)
+++ trunk/tools/quickbook/test/templates-1_7.gold 2013-08-12 17:35:29 EDT (Mon, 12 Aug 2013) (r85326)
@@ -285,9 +285,9 @@
     </orderedlist>
     <orderedlist>
       <listitem>
- <para>
+ <simpara>
           <code><phrase role="identifier">code</phrase></code>
- </para>
+ </simpara>
       </listitem>
     </orderedlist>
   </section>


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