Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51402 - in trunk/tools/quickbook: detail test
From: daniel_james_at_[hidden]
Date: 2009-02-22 18:48:39


Author: danieljames
Date: 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
New Revision: 51402
URL: http://svn.boost.org/trac/boost/changeset/51402

Log:
Generate slightly more valid boostbook.

For document types other than library:
* Don't generate name or dirname for document types.
* Put title before document info.

Ref #2771
Removed:
   trunk/tools/quickbook/test/stub.xml
Text files modified:
   trunk/tools/quickbook/detail/actions.cpp | 84 ++++++++++++++++++++++++++-------------
   trunk/tools/quickbook/test/code-block-1.gold | 4
   trunk/tools/quickbook/test/code-block-2.gold | 4
   trunk/tools/quickbook/test/code-snippet.gold | 4
   trunk/tools/quickbook/test/escape.gold | 5 -
   trunk/tools/quickbook/test/import.gold | 5 -
   trunk/tools/quickbook/test/link-side-by-side.gold | 6 +-
   trunk/tools/quickbook/test/preformatted.gold | 4
   trunk/tools/quickbook/test/quickbook-manual.gold | 5 -
   trunk/tools/quickbook/test/templates.gold | 4
   trunk/tools/quickbook/test/xinclude.gold | 5 -
   11 files changed, 77 insertions(+), 53 deletions(-)

Modified: trunk/tools/quickbook/detail/actions.cpp
==============================================================================
--- trunk/tools/quickbook/detail/actions.cpp (original)
+++ trunk/tools/quickbook/detail/actions.cpp 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1212,6 +1212,9 @@
         out << " <year>" << year << "</year>\n";
     }
 
+ static void write_document_title(collector& out, quickbook::actions& actions);
+ static void write_document_info(collector& out, quickbook::actions& actions);
+
     void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo)
     {
         // The doc_info in the file has been parsed. Here's what we'll do
@@ -1221,7 +1224,7 @@
             actions.doc_id = detail::make_identifier(
                 actions.doc_title.begin(),actions.doc_title.end());
 
- if (actions.doc_dirname.empty())
+ if (actions.doc_dirname.empty() && actions.doc_type == "library")
             actions.doc_dirname = actions.doc_id;
 
         if (actions.doc_last_revision.empty())
@@ -1264,12 +1267,58 @@
             << "<!DOCTYPE library PUBLIC \"-//Boost//DTD BoostBook XML V1.0//EN\"\n"
             << " \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">\n"
             << '<' << actions.doc_type << "\n"
- << " id=\"" << actions.doc_id << "\"\n"
- << " name=\"" << actions.doc_title << "\"\n"
- << " dirname=\"" << actions.doc_dirname << "\"\n"
- << " last-revision=\"" << actions.doc_last_revision << "\" \n"
- << " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n"
- << " <" << actions.doc_type << "info>\n";
+ << " id=\"" << actions.doc_id << "\"\n";
+
+ if(actions.doc_type == "library")
+ {
+ out << " name=\"" << actions.doc_title << "\"\n";
+ }
+
+ if(!actions.doc_dirname.empty())
+ {
+ out << " dirname=\"" << actions.doc_dirname << "\"\n";
+ }
+
+ out << " last-revision=\"" << actions.doc_last_revision << "\" \n"
+ << " xmlns:xi=\"http://www.w3.org/2001/XInclude\">\n";
+
+ if(actions.doc_type == "library") {
+ write_document_info(out, actions);
+ write_document_title(out, actions);
+ }
+ else {
+ write_document_title(out, actions);
+ write_document_info(out, actions);
+ }
+ }
+
+ void post(collector& out, quickbook::actions& actions, bool ignore_docinfo)
+ {
+ // if we're ignoring the document info, do nothing.
+ if (ignore_docinfo)
+ {
+ return;
+ }
+
+ // We've finished generating our output. Here's what we'll do
+ // *after* everything else.
+ out << "\n</" << actions.doc_type << ">\n\n";
+ }
+
+ void write_document_title(collector& out, quickbook::actions& actions)
+ {
+ if (!actions.doc_title.empty())
+ {
+ out<< " <title>" << actions.doc_title;
+ if (!actions.doc_version.empty())
+ out << ' ' << actions.doc_version;
+ out<< "</title>\n\n\n";
+ }
+ }
+
+ void write_document_info(collector& out, quickbook::actions& actions)
+ {
+ out << " <" << actions.doc_type << "info>\n";
 
         if(!actions.doc_authors.empty())
         {
@@ -1328,27 +1377,6 @@
         out << " </" << actions.doc_type << "info>\n"
             << "\n"
         ;
-
- if (!actions.doc_title.empty())
- {
- out << " <title>" << actions.doc_title;
- if (!actions.doc_version.empty())
- out << ' ' << actions.doc_version;
- out << "</title>\n\n\n";
- }
- }
-
- void post(collector& out, quickbook::actions& actions, bool ignore_docinfo)
- {
- // if we're ignoring the document info, do nothing.
- if (ignore_docinfo)
- {
- return;
- }
-
- // We've finished generating our output. Here's what we'll do
- // *after* everything else.
- out << "\n</" << actions.doc_type << ">\n\n";
     }
 
     void phrase_to_string_action::operator()(iterator first, iterator last) const

Modified: trunk/tools/quickbook/test/code-block-1.gold
==============================================================================
--- trunk/tools/quickbook/test/code-block-1.gold (original)
+++ trunk/tools/quickbook/test/code-block-1.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="code_block_1" name="Code Block 1" dirname="code_block_1" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+<article id="code_block_1" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Code Block 1</title>
   <articleinfo>
   </articleinfo>
- <title>Code Block 1</title>
   <section id="code_block_1.a_code_block">
     <title>A code block</title>
     <para>

Modified: trunk/tools/quickbook/test/code-block-2.gold
==============================================================================
--- trunk/tools/quickbook/test/code-block-2.gold (original)
+++ trunk/tools/quickbook/test/code-block-2.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="code_block_2" name="Code Block 2" dirname="code_block_2" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+<article id="code_block_2" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Code Block 2</title>
   <articleinfo>
   </articleinfo>
- <title>Code Block 2</title>
   <section id="code_block_2.a_code_block">
     <title>A code block</title>
     <para>

Modified: trunk/tools/quickbook/test/code-snippet.gold
==============================================================================
--- trunk/tools/quickbook/test/code-snippet.gold (original)
+++ trunk/tools/quickbook/test/code-snippet.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="code_snippets" name="Code Snippets" dirname="code_snippets" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+<article id="code_snippets" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Code Snippets</title>
   <articleinfo>
   </articleinfo>
- <title>Code Snippets</title>
   <section id="code_snippets.a_code_snippet">
     <title>A code snippet</title>
     <para>

Modified: trunk/tools/quickbook/test/escape.gold
==============================================================================
--- trunk/tools/quickbook/test/escape.gold (original)
+++ trunk/tools/quickbook/test/escape.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="escape" name="Escape" dirname="escape" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
- xmlns:xi="http://www.w3.org/2001/XInclude">
+<article id="escape" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Escape</title>
   <articleinfo>
   </articleinfo>
- <title>Escape</title>
   <section id="escape.escape">
     <title>Escape</title>
     <para>

Modified: trunk/tools/quickbook/test/import.gold
==============================================================================
--- trunk/tools/quickbook/test/import.gold (original)
+++ trunk/tools/quickbook/test/import.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,9 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="import" name="Import" dirname="import" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
- xmlns:xi="http://www.w3.org/2001/XInclude">
+<article id="import" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Import</title>
   <articleinfo>
   </articleinfo>
- <title>Import</title>
   <para>
     <para>
       This is the <emphasis role="bold"><emphasis>foo</emphasis></emphasis> function.

Modified: trunk/tools/quickbook/test/link-side-by-side.gold
==============================================================================
--- trunk/tools/quickbook/test/link-side-by-side.gold (original)
+++ trunk/tools/quickbook/test/link-side-by-side.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="side_by_side_links" name="Side-by-side links" dirname="side_by_side_links"
-last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+<article id="side_by_side_links" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+ xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Side-by-side links</title>
   <articleinfo>
   </articleinfo>
- <title>Side-by-side links</title>
   <section id="side_by_side_links.side_by_side_links">
     <title>Side-by-side links</title>
     <para>

Modified: trunk/tools/quickbook/test/preformatted.gold
==============================================================================
--- trunk/tools/quickbook/test/preformatted.gold (original)
+++ trunk/tools/quickbook/test/preformatted.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="preformatted" name="Preformatted" dirname="preformatted" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+<article id="preformatted" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Preformatted</title>
   <articleinfo>
   </articleinfo>
- <title>Preformatted</title>
   <section id="preformatted.preformatted">
     <title>Preformatted</title>
     <para>

Modified: trunk/tools/quickbook/test/quickbook-manual.gold
==============================================================================
--- trunk/tools/quickbook/test/quickbook-manual.gold (original)
+++ trunk/tools/quickbook/test/quickbook-manual.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="quickbook" name="Quickbook" dirname="quickbook" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
- xmlns:xi="http://www.w3.org/2001/XInclude">
+<article id="quickbook" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Quickbook 1.4</title>
   <articleinfo>
     <authorgroup>
     <author>
@@ -25,7 +25,6 @@
       <emphasis>WikiWiki</emphasis> style documentation tool
     </articlepurpose>
   </articleinfo>
- <title>Quickbook 1.4</title>
   <section id="quickbook.intro">
     <title><link linkend="quickbook.intro"> Introduction</link></title>
     <blockquote>

Deleted: trunk/tools/quickbook/test/stub.xml
==============================================================================
--- trunk/tools/quickbook/test/stub.xml 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
+++ (empty file)
@@ -1 +0,0 @@
-<para>This is a paragraph.</para>

Modified: trunk/tools/quickbook/test/templates.gold
==============================================================================
--- trunk/tools/quickbook/test/templates.gold (original)
+++ trunk/tools/quickbook/test/templates.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="templates" name="Templates" dirname="templates" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
+<article id="templates" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
  xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Templates</title>
   <articleinfo>
   </articleinfo>
- <title>Templates</title>
   <section id="templates.templates">
     <title><link linkend="templates.templates">Templates</link></title>
     <para>

Modified: trunk/tools/quickbook/test/xinclude.gold
==============================================================================
--- trunk/tools/quickbook/test/xinclude.gold (original)
+++ trunk/tools/quickbook/test/xinclude.gold 2009-02-22 18:48:37 EST (Sun, 22 Feb 2009)
@@ -1,9 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE library PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="include" name="Include" dirname="include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
- xmlns:xi="http://www.w3.org/2001/XInclude">
+<article id="include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Include</title>
   <articleinfo>
   </articleinfo>
- <title>Include</title>
   <xi:include href="../../../../../../../../../tools/quickbook/test/stub.xml" />
 </article>


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