Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85126 - in trunk/tools/quickbook: doc src test
From: dnljms_at_[hidden]
Date: 2013-07-23 04:21:56


Author: danieljames
Date: 2013-07-23 04:21:56 EDT (Tue, 23 Jul 2013)
New Revision: 85126
URL: http://svn.boost.org/trac/boost/changeset/85126

Log:
Allow block markup inside nested blocks (e.g. tables)

Since this is often indented, does not treat indented blocks as code
blocks. This is inconsistent for lists, so maybe indented blocks in
lists should always be code, or never be code. Or maybe it should be a
bit smarter about nested indented blocks.

Added:
   trunk/tools/quickbook/test/table-1_7.gold (contents, props changed)
   trunk/tools/quickbook/test/table-1_7.quickbook (contents, props changed)
Text files modified:
   trunk/tools/quickbook/doc/1_6.qbk | 11
   trunk/tools/quickbook/src/main_grammar.cpp | 84 ++++-
   trunk/tools/quickbook/test/Jamfile.v2 | 1
   trunk/tools/quickbook/test/table-1_7.gold | 514 ++++++++++++++++++++++++++++++++++++++++
   trunk/tools/quickbook/test/table-1_7.quickbook | 148 +++++++++++
   5 files changed, 733 insertions(+), 25 deletions(-)

Modified: trunk/tools/quickbook/doc/1_6.qbk
==============================================================================
--- trunk/tools/quickbook/doc/1_6.qbk Tue Jul 23 04:21:32 2013 (r85125)
+++ trunk/tools/quickbook/doc/1_6.qbk 2013-07-23 04:21:56 EDT (Tue, 23 Jul 2013) (r85126)
@@ -444,4 +444,15 @@
 
 [endsect] [/templates_in_link_values]
 
+[section:list_markup_in_tables List Markup in Nested Blocks]
+
+Can now place list markup in nested blocks, e.g in tables, variables lists etc.
+Unfortunately indented code blocks are more tricky, because the contents of
+these blocks are often indented already. It seemed easier to just not support
+indented code blocks in this context than to try to work out sensible actions
+for the edges cases. If you want to use code blocks in this context, you should
+still be able to use explicit markup.
+
+[endsect]
+
 [endsect] [/ Quickbok 1.7]

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp Tue Jul 23 04:21:32 2013 (r85125)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2013-07-23 04:21:56 EDT (Tue, 23 Jul 2013) (r85126)
@@ -33,8 +33,14 @@
     namespace cl = boost::spirit::classic;
 
     struct list_stack_item {
- bool root; // Is this the root of the context
- // (e.g. top, template, table cell etc.)
+ // 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;
+
         unsigned int indent; // Indent of list marker
                               // (or paragraph if not in a list)
         unsigned int indent2; // Indent of paragraph
@@ -46,11 +52,11 @@
         // * List item
         // |indent2
 
- list_stack_item() :
- root(true), indent(0), indent2(0), mark('\0') {}
+ list_stack_item(root_type r) :
+ root(r), indent(0), indent2(0), mark('\0') {}
 
         list_stack_item(char mark, unsigned int indent, unsigned int indent2) :
- root(false), indent(indent), indent2(indent2), mark(mark)
+ root(not_root), indent(indent), indent2(indent2), mark(mark)
         {}
 
     };
@@ -82,6 +88,7 @@
         // Local actions
 
         void start_blocks_impl(parse_iterator first, parse_iterator last);
+ void start_nested_blocks_impl(parse_iterator first, parse_iterator last);
         void end_blocks_impl(parse_iterator first, parse_iterator last);
         void check_indentation_impl(parse_iterator first, parse_iterator last);
         void check_code_block_impl(parse_iterator first, parse_iterator last);
@@ -95,7 +102,7 @@
 
         cl::rule<scanner>
                         top_level, indent_check,
- paragraph_separator,
+ paragraph_separator, inside_paragraph,
                         code, code_line, blank_line, hr,
                         inline_code, skip_inline_code,
                         template_,
@@ -327,6 +334,8 @@
             &main_grammar_local::check_code_block_impl);
         member_action<main_grammar_local> start_blocks(local,
             &main_grammar_local::start_blocks_impl);
+ member_action<main_grammar_local> start_nested_blocks(local,
+ &main_grammar_local::start_nested_blocks_impl);
         member_action<main_grammar_local> end_blocks(local,
             &main_grammar_local::end_blocks_impl);
 
@@ -398,8 +407,24 @@
 
         // Top level blocks
         block_start =
- (*eol) [start_blocks]
- >> (*local.top_level) [end_blocks]
+ (*eol) [start_blocks]
+ >> ( *( local.top_level
+ >> !( cl::ch_p(']')
+ >> cl::eps_p [error("Mismatched close bracket")]
+ )
+ )
+ ) [end_blocks]
+ ;
+
+ // 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
+ ]
             ;
 
         local.top_level =
@@ -451,7 +476,8 @@
 
         local.syntactic_block_item =
                 local.paragraph_separator [ph::var(local.still_in_block) = false]
- | cl::eps_p [ph::var(local.element_type) = element_info::nothing]
+ | (cl::eps_p(~cl::ch_p(']')) | qbk_ver(0, 107u))
+ [ph::var(local.element_type) = element_info::nothing]
>> local.common
                 // If the element is a block, then a newline will end the
                 // current syntactic block.
@@ -480,16 +506,12 @@
             ;
 
         // Blocks contains within an element, e.g. a table cell or a footnote.
- inside_paragraph =
- state.values.save()
- [
- scoped_context(element_info::in_nested_block)
- [ *( local.paragraph_separator
- [paragraph_action]
- | ~cl::eps_p(']')
- >> local.common
- )
- ]
+ local.inside_paragraph =
+ scoped_context(element_info::in_nested_block)
+ [ *( local.paragraph_separator [paragraph_action]
+ | ~cl::eps_p(']')
+ >> local.common
+ )
             ] [paragraph_action]
             ;
 
@@ -981,7 +1003,12 @@
 
     void main_grammar_local::start_blocks_impl(parse_iterator, parse_iterator)
     {
- list_stack.push(list_stack_item());
+ list_stack.push(list_stack_item(list_stack_item::top_root));
+ }
+
+ void main_grammar_local::start_nested_blocks_impl(parse_iterator, parse_iterator)
+ {
+ list_stack.push(list_stack_item(list_stack_item::nested_root));
     }
 
     void main_grammar_local::end_blocks_impl(parse_iterator, parse_iterator)
@@ -1020,7 +1047,12 @@
             unsigned int new_indent = indent_length(first, last);
 
             if (new_indent > list_stack.top().indent2) {
- block_type = block_types::code;
+ if (list_stack.top().root != list_stack_item::nested_root) {
+ block_type = block_types::code;
+ }
+ else {
+ block_type = block_types::paragraph;
+ }
             }
             else {
                 while (!list_stack.top().root && new_indent < list_stack.top().indent)
@@ -1082,10 +1114,11 @@
         else {
             clear_stack();
 
- if (last == first)
- block_type = block_types::paragraph;
- else
+ if (list_stack.top().root != list_stack_item::nested_root &&
+ last != first)
                 block_type = block_types::code;
+ else
+ block_type = block_types::paragraph;
         }
     }
 
@@ -1096,7 +1129,8 @@
         unsigned int new_indent2 = indent_length(first, last);
         char mark = *mark_pos;
 
- if (list_stack.top().root && new_indent > 0) {
+ if (list_stack.top().root == list_stack_item::top_root &&
+ new_indent > 0) {
             block_type = block_types::code;
             return;
         }

Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 Tue Jul 23 04:21:32 2013 (r85125)
+++ trunk/tools/quickbook/test/Jamfile.v2 2013-07-23 04:21:56 EDT (Tue, 23 Jul 2013) (r85126)
@@ -96,6 +96,7 @@
     [ quickbook-test table-1_3 ]
     [ quickbook-test table-1_5 ]
     [ quickbook-test table-1_6 ]
+ [ quickbook-test table-1_7 ]
     [ quickbook-error-test template_arguments1-1_1-fail ]
     [ quickbook-error-test template_arguments2-1_1-fail ]
     [ quickbook-error-test template_arguments3-1_1-fail ]

Added: trunk/tools/quickbook/test/table-1_7.gold
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/quickbook/test/table-1_7.gold 2013-07-23 04:21:56 EDT (Tue, 23 Jul 2013) (r85126)
@@ -0,0 +1,514 @@
+<?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="table_tests" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Table 1.7</title>
+ <table frame="all" id="table_tests.table1">
+ <title>Table 1</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.table_2">
+ <title>Table 2</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <informaltable frame="all">
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <informaltable frame="all" id="table_tests.table4">
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <table frame="all" id="table_tests.table5">
+ <title>-table5-</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.title">
+ <title>Title</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.title0">
+ <title>Title</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.title_containing_a_comment">
+ <title>Title containing a comment</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.title1">
+ <title>Title</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <informaltable frame="all">
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ Cell 1
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>
+ Cell 2
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+ <table frame="all" id="table_tests.title_on_multiple_lines_with_bol">
+ <title>Title on multiple lines with <emphasis role="bold">bold</emphasis> text?</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ Cell 1
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>
+ Cell 2
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <section id="table_tests.section1">
+ <title><link linkend="table_tests.section1">Section 1</link></title>
+ <table frame="all" id="table_tests.section1.table1">
+ <title>Table 1</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Heading
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ cell
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.section1.a_b">
+ <title>A &amp; B</title>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ A
+ </para>
+ </entry>
+ <entry>
+ <para>
+ B
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ a
+ </para>
+ </entry>
+ <entry>
+ <para>
+ b
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.section1.empty_table">
+ <title>Empty Table</title>
+ <tgroup cols="0">
+ <tbody>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.section1.table_with_an_empty_cell">
+ <title>Table with an empty cell</title>
+ <tgroup cols="1">
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ x
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.section1.indentation">
+ <title>Indentation</title>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Header 1. Paragraph 1
+ </para>
+ <para>
+ Header 1. Paragraph 2
+ </para>
+ </entry>
+ <entry>
+ <para>
+ Header 2
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ Row 1. Cell 1.
+ </para>
+ </entry>
+ <entry>
+ <para>
+ Row 1. Cell 2.
+ </para>
+ <para>
+ Row 1. Cell 2. Paragraph 2.
+ </para>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>
+ Row 2. Cell 1.
+ </para>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ Row 2. Cell 1. List item 1.
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ Row 2. Cell 1. List item 2.
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </entry>
+ <entry>
+ <para>
+ Row 2. Cell 2.
+ </para>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ Row 2. Cell 2. List item 1.
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ Row 2. Cell 2. List item 2.
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <table frame="all" id="table_tests.section1.nested_tables">
+ <title>Nested Tables</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ Header 1
+ </para>
+ </entry>
+ <entry>
+ <para>
+ Header 2
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <table frame="all" id="table_tests.section1.inner_table">
+ <title>Inner Table</title>
+ <tgroup cols="2">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ 1.1
+ </para>
+ </entry>
+ <entry>
+ <para>
+ 1.2
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ 2.1
+ </para>
+ </entry>
+ <entry>
+ <para>
+ 2.2
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </entry>
+ </row>
+ <row>
+ <entry>
+ <para>
+ Something.
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ <anchor id="id1"/>
+ <table frame="all" id="table_tests.section1.table_with_anchors">
+ <title>Table with anchors</title>
+ <tgroup cols="1">
+ <thead>
+ <row>
+ <entry>
+ <para>
+ <anchor id="id2"/>a<anchor id="id3"/>
+ </para>
+ </entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>
+ <para>
+ b
+ </para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+</article>

Added: trunk/tools/quickbook/test/table-1_7.quickbook
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/quickbook/test/table-1_7.quickbook 2013-07-23 04:21:56 EDT (Tue, 23 Jul 2013) (r85126)
@@ -0,0 +1,148 @@
+[article Table 1.7
+ [quickbook 1.7]
+ [id table_tests]
+]
+
+[table:table1 Table 1 [[Heading]][[cell]]]
+
+[table Table 2
+ [[Heading]]
+ [[cell]]
+]
+
+[table
+ [[Heading]]
+ [[cell]]
+]
+
+[table:table4
+ [[Heading]]
+ [[cell]]
+]
+
+[table:-table5-
+ [[Heading]]
+ [[cell]]
+]
+
+[table [/ Comment?] Title
+ [[Heading]]
+ [[cell]]
+]
+
+[table [/ Multi line
+comment] Title
+ [[Heading]]
+ [[cell]]
+]
+
+[table Title [/ ] containing a comment
+ [[Heading]]
+ [[cell]]
+]
+
+[table [/ Multi line
+comment]
+ Title
+ [[Heading]]
+ [[cell]]
+]
+
+[table [/ Multi line
+comment]
+ [[Heading]]
+ [[Cell 1]]
+ [[Cell 2]]
+]
+
+[table Title on multiple
+ lines with *bold* text?
+ [[Heading]]
+ [[Cell 1]]
+ [[Cell 2]]
+]
+
+[section:section1 Section 1]
+
+[table:table1 Table 1
+ [[Heading]]
+ [[cell]]
+]
+
+[table A & B
+ [[A][B]]
+ [[a][b]]
+]
+
+[table Empty Table]
+
+[table Table with an empty cell
+[[x]]]
+
+[table Indentation
+ [
+ [
+ Header 1. Paragraph 1
+
+ Header 1. Paragraph 2
+ ]
+ [
+ Header 2
+ ]
+ ]
+ [
+ [
+ Row 1. Cell 1.
+ ]
+ [
+ Row 1. Cell 2.
+
+ Row 1. Cell 2. Paragraph 2.
+ ]
+ ]
+ [
+ [
+Row 2. Cell 1.
+
+* Row 2. Cell 1. List item 1.
+* Row 2. Cell 1. List item 2.
+ ]
+ [
+ Row 2. Cell 2.
+
+ * Row 2. Cell 2. List item 1.
+ * Row 2. Cell 2. List item 2.
+ ]
+ ]
+]
+
+[table Nested Tables
+ [
+ [
+ Header 1
+ ]
+ [
+ Header 2
+ ]
+ ]
+ [
+ [
+ [table Inner Table
+ [[1.1][1.2]]
+ [[2.1][2.2]]
+ ]
+ ]
+ ]
+ [
+ [
+ Something.
+ ]
+ ]
+]
+
+[#id1]
+[table Table with anchors
+[[[#id2]a[#id3]]][[b]]
+]
+
+[endsect]


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