Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54910 - in branches/release: . tools/boostbook/test/doxygen/boost tools/boostbook/xsl/doxygen tools/quickbook tools/quickbook/detail tools/quickbook/doc tools/quickbook/test
From: daniel_james_at_[hidden]
Date: 2009-07-12 12:09:06


Author: danieljames
Date: 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
New Revision: 54910
URL: http://svn.boost.org/trac/boost/changeset/54910

Log:
Merge changes to documentation tools. Fixes #1202, #3242.

Merged revisions 54812-54818 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r54812 | danieljames | 2009-07-08 22:40:14 +0100 (Wed, 08 Jul 2009) | 1 line
  
  Add a couple of tests for quickbook 1.4 behaviour to try to preserve it.
........
  r54813 | danieljames | 2009-07-08 22:40:24 +0100 (Wed, 08 Jul 2009) | 1 line
  
  Move all the syntax highlighting code into a single class.
........
  r54814 | danieljames | 2009-07-08 22:40:33 +0100 (Wed, 08 Jul 2009) | 1 line
  
  Move the code actions a bit later in actions.hpp so they can use 'plain_char_action'.
........
  r54815 | danieljames | 2009-07-08 22:40:46 +0100 (Wed, 08 Jul 2009) | 1 line
  
  Teletype source mode. Refs #1202.
........
  r54816 | danieljames | 2009-07-08 22:41:00 +0100 (Wed, 08 Jul 2009) | 14 lines
  
  Make sure that a template expansion ends with a ']'.
  
  {{{
  [template foo 1]
  [fool]
  }}}
  
  was generating `1[fool]` - the template would be expanded but then when it
  didn't match the `]` it would fail and just get copied to the output. This
  change checks for `]` before expanding the template. So it now generates
  `[fool]` which is an improvement.
  
  I'm not including a version switch as I see this as a plain bug fix - I can't
  imagine this change ever being anything but beneficial.
........
  r54817 | danieljames | 2009-07-08 22:41:10 +0100 (Wed, 08 Jul 2009) | 1 line
  
  I got a bit confused by this comment, so try to make it clearer.
........
  r54818 | danieljames | 2009-07-08 22:53:15 +0100 (Wed, 08 Jul 2009) | 3 lines
  
  Support INTERNAL ONLY enums in doxygen/boostbook documenation. Refs #3242.
  
  Patch by Mathias Gaunard.
........

Added:
   branches/release/tools/quickbook/test/code-block-teletype.gold
      - copied unchanged from r54818, /trunk/tools/quickbook/test/code-block-teletype.gold
   branches/release/tools/quickbook/test/code-block-teletype.quickbook
      - copied unchanged from r54818, /trunk/tools/quickbook/test/code-block-teletype.quickbook
   branches/release/tools/quickbook/test/templates_1_4.gold
      - copied unchanged from r54818, /trunk/tools/quickbook/test/templates_1_4.gold
   branches/release/tools/quickbook/test/templates_1_4.quickbook
      - copied unchanged from r54818, /trunk/tools/quickbook/test/templates_1_4.quickbook
Properties modified:
   branches/release/ (props changed)
Text files modified:
   branches/release/tools/boostbook/test/doxygen/boost/example.hpp | 3
   branches/release/tools/boostbook/xsl/doxygen/doxygen2boostbook.xsl | 37 +++++--
   branches/release/tools/quickbook/detail/actions.cpp | 55 +++++++-----
   branches/release/tools/quickbook/detail/actions.hpp | 178 +++++++++++++++++++++------------------
   branches/release/tools/quickbook/detail/actions_class.cpp | 7
   branches/release/tools/quickbook/detail/actions_class.hpp | 1
   branches/release/tools/quickbook/detail/template_stack.hpp | 12 +
   branches/release/tools/quickbook/doc/quickbook.qbk | 1
   branches/release/tools/quickbook/doc_info.hpp | 1
   branches/release/tools/quickbook/phrase.hpp | 2
   branches/release/tools/quickbook/syntax_highlight.hpp | 79 +++++++++++++++++
   branches/release/tools/quickbook/test/Jamfile.v2 | 2
   branches/release/tools/quickbook/test/templates.gold | 3
   branches/release/tools/quickbook/test/templates.quickbook | 6 +
   14 files changed, 262 insertions(+), 125 deletions(-)

Modified: branches/release/tools/boostbook/test/doxygen/boost/example.hpp
==============================================================================
--- branches/release/tools/boostbook/test/doxygen/boost/example.hpp (original)
+++ branches/release/tools/boostbook/test/doxygen/boost/example.hpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -22,6 +22,9 @@
         static const int static_const_integer;
 
         enum class_enum { enumerator };
+
+ /// INTERNAL ONLY
+ enum internal_enum { internal_enumerator };
     protected:
         int protected_integer;
         static int protected_static_integer;

Modified: branches/release/tools/boostbook/xsl/doxygen/doxygen2boostbook.xsl
==============================================================================
--- branches/release/tools/boostbook/xsl/doxygen/doxygen2boostbook.xsl (original)
+++ branches/release/tools/boostbook/xsl/doxygen/doxygen2boostbook.xsl 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -292,21 +292,32 @@
   </xsl:template>
 
   <xsl:template match="enumvalue">
- <enumvalue>
- <xsl:attribute name="name">
- <xsl:value-of select="name"/>
- </xsl:attribute>
+ <xsl:choose>
+ <!-- If the string INTERNAL ONLY is in the description, don't
+ emit this entity. This hack is necessary because Doxygen doesn't
+ tell us what is \internal and what isn't. -->
+ <xsl:when test="contains(detaileddescription/para, 'INTERNAL ONLY')"/>
+ <xsl:when test="contains(briefdescription/para, 'INTERNAL ONLY')"/>
+ <xsl:when test="contains(inbodydescription/para, 'INTERNAL ONLY')"/>
+ <xsl:otherwise>
+
+ <enumvalue>
+ <xsl:attribute name="name">
+ <xsl:value-of select="name"/>
+ </xsl:attribute>
 
- <xsl:if test="initializer">
- <default>
- <xsl:apply-templates select="initializer" mode="passthrough"/>
- </default>
- </xsl:if>
+ <xsl:if test="initializer">
+ <default>
+ <xsl:apply-templates select="initializer" mode="passthrough"/>
+ </default>
+ </xsl:if>
 
- <xsl:apply-templates select="briefdescription" mode="passthrough"/>
- <xsl:apply-templates select="detaileddescription" mode="passthrough"/>
- <xsl:apply-templates select="inbodydescription" mode="passthrough"/>
- </enumvalue>
+ <xsl:apply-templates select="briefdescription" mode="passthrough"/>
+ <xsl:apply-templates select="detaileddescription" mode="passthrough"/>
+ <xsl:apply-templates select="inbodydescription" mode="passthrough"/>
+ </enumvalue>
+ </xsl:otherwise>
+ </xsl:choose>
   </xsl:template>
 
   <xsl:template name="doxygen.include.header.rec">

Modified: branches/release/tools/quickbook/detail/actions.cpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions.cpp (original)
+++ branches/release/tools/quickbook/detail/actions.cpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -308,12 +308,35 @@
         out << escape_actions.phrase.str();
         escape_actions.phrase.pop(); // restore the stream
     }
+
+ std::string syntax_highlight::operator()(iterator first, iterator last) const
+ {
+ // print the code with syntax coloring
+ if (source_mode == "c++")
+ {
+ parse(first, last, cpp_p);
+ }
+ else if (source_mode == "python")
+ {
+ parse(first, last, python_p);
+ }
+ else if (source_mode == "teletype")
+ {
+ parse(first, last, teletype_p);
+ }
+ else
+ {
+ BOOST_ASSERT(0);
+ }
+
+ std::string str;
+ temp.swap(str);
+
+ return str;
+ }
 
     void code_action::operator()(iterator first, iterator last) const
     {
- std::string save;
- phrase.swap(save);
-
         // preprocess the code section to remove the initial indentation
         std::string program(first, last);
         detail::unindent(program);
@@ -324,18 +347,12 @@
         iterator last_(program.end(), program.end());
         first_.set_position(first.get_position());
 
+ std::string save;
+ phrase.swap(save);
+
         // print the code with syntax coloring
- if (source_mode == "c++")
- {
- parse(first_, last_, cpp_p);
- }
- else if (source_mode == "python")
- {
- parse(first_, last_, python_p);
- }
+ std::string str = syntax_p(first_, last_);
 
- std::string str;
- temp.swap(str);
         phrase.swap(save);
 
         //
@@ -353,16 +370,8 @@
         out.swap(save);
 
         // print the code with syntax coloring
- if (source_mode == "c++")
- {
- parse(first, last, cpp_p);
- }
- else if (source_mode == "python")
- {
- parse(first, last, python_p);
- }
- std::string str;
- temp.swap(str);
+ std::string str = syntax_p(first, last);
+
         out.swap(save);
 
         out << "<code>";

Modified: branches/release/tools/quickbook/detail/actions.hpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions.hpp (original)
+++ branches/release/tools/quickbook/detail/actions.hpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -345,88 +345,6 @@
         std::string& save;
     };
 
- typedef cpp_highlight<
- span
- , space
- , string_symbols
- , do_macro_action
- , pre_escape_back
- , post_escape_back
- , actions
- , unexpected_char
- , collector>
- cpp_p_type;
-
- typedef python_highlight<
- span
- , space
- , string_symbols
- , do_macro_action
- , pre_escape_back
- , post_escape_back
- , actions
- , unexpected_char
- , collector>
- python_p_type;
-
- struct code_action
- {
- // Does the actual syntax highlighing of code
-
- code_action(
- collector& out
- , collector& phrase
- , collector& temp
- , std::string const& source_mode
- , string_symbols const& macro
- , actions& escape_actions)
- : out(out)
- , phrase(phrase)
- , temp(temp)
- , source_mode(source_mode)
- , cpp_p(temp, macro, do_macro_action(temp), escape_actions)
- , python_p(temp, macro, do_macro_action(temp), escape_actions)
- {
- }
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- collector& phrase;
- collector& temp;
- std::string const& source_mode;
-
- cpp_p_type cpp_p;
- python_p_type python_p;
- };
-
- struct inline_code_action
- {
- // Does the actual syntax highlighing of code inlined in text
-
- inline_code_action(
- collector& out
- , collector& temp
- , std::string const& source_mode
- , string_symbols const& macro
- , actions& escape_actions)
- : out(out)
- , source_mode(source_mode)
- , temp(temp)
- , cpp_p(temp, macro, do_macro_action(temp), escape_actions)
- , python_p(temp, macro, do_macro_action(temp), escape_actions)
- {}
-
- void operator()(iterator first, iterator last) const;
-
- collector& out;
- std::string const& source_mode;
- collector& temp;
-
- cpp_p_type cpp_p;
- python_p_type python_p;
- };
-
     struct raw_char_action
     {
         // Prints a single raw (unprocessed) char.
@@ -490,6 +408,102 @@
         std::string str;
     };
 
+ typedef cpp_highlight<
+ span
+ , space
+ , string_symbols
+ , do_macro_action
+ , pre_escape_back
+ , post_escape_back
+ , actions
+ , unexpected_char
+ , collector>
+ cpp_p_type;
+
+ typedef python_highlight<
+ span
+ , space
+ , string_symbols
+ , do_macro_action
+ , pre_escape_back
+ , post_escape_back
+ , actions
+ , unexpected_char
+ , collector>
+ python_p_type;
+
+ typedef teletype_highlight<
+ plain_char_action
+ , string_symbols
+ , do_macro_action
+ , pre_escape_back
+ , post_escape_back
+ , actions
+ , collector>
+ teletype_p_type;
+
+ struct syntax_highlight
+ {
+ syntax_highlight(
+ collector& temp
+ , std::string const& source_mode
+ , string_symbols const& macro
+ , actions& escape_actions)
+ : temp(temp)
+ , source_mode(source_mode)
+ , cpp_p(temp, macro, do_macro_action(temp), escape_actions)
+ , python_p(temp, macro, do_macro_action(temp), escape_actions)
+ , teletype_p(temp, macro, do_macro_action(temp), escape_actions)
+ {
+ }
+
+ std::string operator()(iterator first, iterator last) const;
+
+ collector& temp;
+ std::string const& source_mode;
+ cpp_p_type cpp_p;
+ python_p_type python_p;
+ teletype_p_type teletype_p;
+ };
+
+ struct code_action
+ {
+ // Does the actual syntax highlighing of code
+
+ code_action(
+ collector& out
+ , collector& phrase
+ , syntax_highlight& syntax_p)
+ : out(out)
+ , phrase(phrase)
+ , syntax_p(syntax_p)
+ {
+ }
+
+ void operator()(iterator first, iterator last) const;
+
+ collector& out;
+ collector& phrase;
+ syntax_highlight& syntax_p;
+ };
+
+ struct inline_code_action
+ {
+ // Does the actual syntax highlighing of code inlined in text
+
+ inline_code_action(
+ collector& out
+ , syntax_highlight& syntax_p)
+ : out(out)
+ , syntax_p(syntax_p)
+ {}
+
+ void operator()(iterator first, iterator last) const;
+
+ collector& out;
+ syntax_highlight& syntax_p;
+ };
+
     struct start_varlistitem_action
     {
         start_varlistitem_action(collector& phrase)

Modified: branches/release/tools/quickbook/detail/actions_class.cpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions_class.cpp (original)
+++ branches/release/tools/quickbook/detail/actions_class.cpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -69,9 +69,10 @@
         , extract_doc_license(doc_license, phrase)
         , extract_doc_purpose(doc_purpose, phrase)
 
- , code(out, phrase, temp, source_mode, macro, *this)
- , code_block(phrase, phrase, temp, source_mode, macro, *this)
- , inline_code(phrase, temp, source_mode, macro, *this)
+ , syntax_p(temp, source_mode, macro, *this)
+ , code(out, phrase, syntax_p)
+ , code_block(phrase, phrase, syntax_p)
+ , inline_code(phrase, syntax_p)
         , paragraph(out, phrase, paragraph_pre, paragraph_post)
         , inside_paragraph(temp_para, phrase, paragraph_pre, paragraph_post)
         , h(out, phrase, doc_id, section_id, qualified_section_id, section_level)

Modified: branches/release/tools/quickbook/detail/actions_class.hpp
==============================================================================
--- branches/release/tools/quickbook/detail/actions_class.hpp (original)
+++ branches/release/tools/quickbook/detail/actions_class.hpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -103,6 +103,7 @@
         phrase_to_string_action extract_doc_license;
         phrase_to_string_action extract_doc_purpose;
 
+ syntax_highlight syntax_p;
         code_action code;
         code_action code_block;
         inline_code_action inline_code;

Modified: branches/release/tools/quickbook/detail/template_stack.hpp
==============================================================================
--- branches/release/tools/quickbook/detail/template_stack.hpp (original)
+++ branches/release/tools/quickbook/detail/template_stack.hpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -21,14 +21,18 @@
 
 namespace quickbook
 {
- // template symbols are stored as follows:
+ // template symbols with N arguments are stored as follows:
     //
- // template name
- // template param name[0]
- // template param name[1]
+ // vector<std::string>
+ // 0: template name
+ // 1: template param name[0]
+ // 2: template param name[1]
     // ...
     // template param name[N]
     // template body
+ // N: template param name[N-1]
+ // N+1: template body
+ // file position
 
     typedef boost::tuple<
             std::vector<std::string>

Modified: branches/release/tools/quickbook/doc/quickbook.qbk
==============================================================================
--- branches/release/tools/quickbook/doc/quickbook.qbk (original)
+++ branches/release/tools/quickbook/doc/quickbook.qbk 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -436,6 +436,7 @@
     [[Mode] [Source Mode Markup]]
     [[C++] [[^\[c++\]]]]
     [[Python] [[^\[python\]]]]
+ [[Plain Text] [[^\[teletype\]]]]
 ]
 
 [note The source mode strings are lowercase.]

Modified: branches/release/tools/quickbook/doc_info.hpp
==============================================================================
--- branches/release/tools/quickbook/doc_info.hpp (original)
+++ branches/release/tools/quickbook/doc_info.hpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -153,6 +153,7 @@
>> (
                            str_p("c++")
                         | "python"
+ | "teletype"
                         ) [assign_a(actions.source_mode)]
                     ;
 

Modified: branches/release/tools/quickbook/phrase.hpp
==============================================================================
--- branches/release/tools/quickbook/phrase.hpp (original)
+++ branches/release/tools/quickbook/phrase.hpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -145,6 +145,7 @@
>> !(hard_space
>> template_args)
                     ) )
+ >> eps_p(']')
                     ;
 
                 brackets =
@@ -403,6 +404,7 @@
                     (
                         str_p("c++")
                     | "python"
+ | "teletype"
                     ) [assign_a(actions.source_mode)]
                     ;
 

Modified: branches/release/tools/quickbook/syntax_highlight.hpp
==============================================================================
--- branches/release/tools/quickbook/syntax_highlight.hpp (original)
+++ branches/release/tools/quickbook/syntax_highlight.hpp 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -323,6 +323,85 @@
         DoMacro do_macro;
         EscapeActions& escape_actions;
     };
+
+ // Grammar for plain text (no actual highlighting)
+ template <
+ typename CharProcess
+ , typename Macro
+ , typename DoMacro
+ , typename PreEscape
+ , typename PostEscape
+ , typename EscapeActions
+ , typename Out>
+ struct teletype_highlight
+ : public grammar<teletype_highlight<CharProcess, Macro, DoMacro, PreEscape, PostEscape, EscapeActions, Out> >
+ {
+ teletype_highlight(Out& out, Macro const& macro, DoMacro do_macro, EscapeActions& escape_actions)
+ : out(out), macro(macro), do_macro(do_macro), escape_actions(escape_actions) {}
+
+ template <typename Scanner>
+ struct definition
+ {
+ definition(teletype_highlight const& self)
+ : common(self.escape_actions, unused)
+ , unused(false)
+ {
+ program
+ =
+ *( macro
+ | escape
+ | repeat_p(1)[anychar_p] [CharProcess(self.out)]
+ )
+ ;
+
+ macro =
+ eps_p(self.macro // must not be followed by
+ >> (eps_p - (alpha_p | '_'))) // alpha or underscore
+ >> self.macro [self.do_macro]
+ ;
+
+ qbk_phrase =
+ *( common
+ | (anychar_p - str_p("``")) [self.escape_actions.plain_char]
+ )
+ ;
+
+ escape =
+ str_p("``") [PreEscape(self.escape_actions, save)]
+ >>
+ (
+ (
+ (
+ (+(anychar_p - "``") >> eps_p("``"))
+ & qbk_phrase
+ )
+ >> str_p("``")
+ )
+ |
+ (
+ eps_p [self.escape_actions.error]
+ >> *anychar_p
+ )
+ ) [PostEscape(self.out, self.escape_actions, save)]
+ ;
+ }
+
+ rule<Scanner> program, macro, qbk_phrase, escape;
+
+ phrase_grammar<EscapeActions> common;
+ std::string save;
+ bool unused;
+
+ rule<Scanner> const&
+ start() const { return program; }
+ };
+
+ Out& out;
+ Macro const& macro;
+ DoMacro do_macro;
+ EscapeActions& escape_actions;
+ };
+
 }
 
 #endif // BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP

Modified: branches/release/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/release/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/release/tools/quickbook/test/Jamfile.v2 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -15,11 +15,13 @@
     [ quickbook-test code-block-1 ]
     [ quickbook-test code-block-2 ]
     [ quickbook-test code-block-3 ]
+ [ quickbook-test code-block-teletype ]
     [ quickbook-test code-snippet ]
     [ quickbook-test preformatted ]
     [ quickbook-test link-side-by-side ]
     [ quickbook-test escape ]
     [ quickbook-test templates ]
+ [ quickbook-test templates_1_4 ]
     [ quickbook-test xinclude ]
     [ quickbook-test import ]
     [ quickbook-fail-test fail-include ]

Modified: branches/release/tools/quickbook/test/templates.gold
==============================================================================
--- branches/release/tools/quickbook/test/templates.gold (original)
+++ branches/release/tools/quickbook/test/templates.gold 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -67,5 +67,8 @@
     <para>
       .0 00
     </para>
+ <para>
+ [fool]
+ </para>
   </section>
 </article>

Modified: branches/release/tools/quickbook/test/templates.quickbook
==============================================================================
--- branches/release/tools/quickbook/test/templates.quickbook (original)
+++ branches/release/tools/quickbook/test/templates.quickbook 2009-07-12 12:09:04 EDT (Sun, 12 Jul 2009)
@@ -100,4 +100,10 @@
 [template test[x] [join1 [join2 0 [x]]...0]]
 [test 0]
 
+[/-------------------------------- Mismatched template ]
+
+[template foo 1]
+[fool]
+
 [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