Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75532 - in branches/quickbook-dev/tools/quickbook: src test/doc-info
From: dnljms_at_[hidden]
Date: 2011-11-17 16:05:19


Author: danieljames
Date: 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
New Revision: 75532
URL: http://svn.boost.org/trac/boost/changeset/75532

Log:
Quickbook: Empty ids and titles.
Added:
   branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_1.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_1.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_5.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_5.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_6.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_6.quickbook (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp | 7 +-
   branches/quickbook-dev/tools/quickbook/src/id_manager.cpp | 88 +++++++++++++++++++--------------------
   branches/quickbook-dev/tools/quickbook/src/id_manager.hpp | 5 +
   branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2 | 3 +
   4 files changed, 52 insertions(+), 51 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -236,14 +236,13 @@
         if (!use_doc_info)
         {
             actions.ids.start_file(compatibility_version, include_doc_id_, id_,
- doc_title.check() ? doc_title.get_quickbook() : std::string());
+ doc_title);
             return "";
         }
 
         std::string id_placeholder =
             actions.ids.start_file_with_docinfo(
- compatibility_version, include_doc_id_, id_,
- doc_title.check() ? doc_title.get_quickbook() : std::string());
+ compatibility_version, include_doc_id_, id_, doc_title);
 
         // Make sure we really did have a document info block.
 
@@ -312,7 +311,7 @@
                 << "\"\n";
         }
 
- if(doc_type == "library")
+ if(doc_type == "library" && !doc_title.empty())
         {
             out << " name=\"" << doc_info_output(doc_title, 106) << "\"\n";
         }

Modified: branches/quickbook-dev/tools/quickbook/src/id_manager.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/id_manager.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/id_manager.cpp 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -154,12 +154,12 @@
                 unsigned compatibility_version,
                 std::string const& include_doc_id,
                 std::string const& id,
- std::string const& title,
+ value const& title,
                 std::string* placeholder) = 0;
 
         virtual std::string docinfo(
- std::string const& id = std::string(),
- id_category = id_category()) = 0;
+ std::string const& id,
+ value const& title) = 0;
 
         virtual bool end_file() = 0;
 
@@ -205,7 +205,7 @@
             unsigned compatibility_version,
             std::string const& include_doc_id,
             std::string const& id,
- std::string const& title)
+ value const& title)
     {
         boost::scoped_ptr<section_manager> new_section(
             current_section->start_file(false,
@@ -222,7 +222,7 @@
             unsigned compatibility_version,
             std::string const& include_doc_id,
             std::string const& id,
- std::string const& title)
+ value const& title)
     {
         std::string result;
 
@@ -365,12 +365,12 @@
                 unsigned compatibility_version,
                 std::string const& include_doc_id,
                 std::string const& id,
- std::string const& title,
+ value const& title,
                 std::string* placeholder);
 
         virtual std::string docinfo(
                 std::string const& id,
- id_category);
+ value const& title);
 
         virtual bool end_file();
 
@@ -399,35 +399,26 @@
             unsigned compatibility_version,
             std::string const& include_doc_id,
             std::string const& id,
- std::string const& title,
+ value const& title,
             std::string* placeholder)
     {
         // This is set even when docinfo is otherwise ignored.
- if (!title.empty()) state.last_title_1_1 = title;
+ if (compatibility_version < 106u && title.check())
+ state.last_title_1_1 = title.get_quickbook();
 
- // This is true because the first section manager is always v1.1,
- // and always gets a title.
- assert(!state.last_title_1_1.empty());
-
- std::string initial_doc_id =
- !id.empty() ? id :
- !include_doc_id.empty() ? include_doc_id :
- detail::make_identifier(state.last_title_1_1);
-
- id_category category =
- !id.empty() || !include_doc_id.empty() ?
- id_category::explicit_section_id :
- id_category::generated_doc;
+ std::string initial_doc_id = !id.empty() ? id : include_doc_id;
 
         if (have_docinfo) {
             std::auto_ptr<section_manager> new_section_manager =
                 create_section_manager(state, compatibility_version);
             std::string initial_placeholder = new_section_manager->docinfo(
- initial_doc_id, category);
+ initial_doc_id, title);
             if (placeholder) *placeholder = initial_placeholder;
             return new_section_manager;
         }
         else {
+ if (initial_doc_id.empty()) initial_doc_id =
+ detail::make_identifier(state.last_title_1_1);
             doc_id_stack.push_back(doc_id);
             doc_id = initial_doc_id;
             if (placeholder) *placeholder = "";
@@ -437,11 +428,17 @@
 
     std::string section_manager_1_1::docinfo(
         std::string const& id,
- id_category category)
+ value const& title)
     {
- doc_id = id;
         ++level;
- return state.add_placeholder(id, category)->to_string();
+ if (!id.empty()) {
+ doc_id = id;
+ return state.add_placeholder(id, id_category::explicit_section_id)->to_string();
+ }
+ else {
+ doc_id = detail::make_identifier(state.last_title_1_1);
+ return state.add_placeholder(doc_id, id_category::generated_doc)->to_string();
+ }
     }
 
     bool section_manager_1_1::end_file()
@@ -528,12 +525,12 @@
                 unsigned compatibility_version,
                 std::string const& include_doc_id,
                 std::string const& id,
- std::string const& title,
+ value const& title,
                 std::string* placeholder);
 
         virtual std::string docinfo(
                 std::string const& id,
- id_category);
+ value const& title);
 
         virtual bool end_file();
 
@@ -560,28 +557,21 @@
             unsigned compatibility_version,
             std::string const& include_doc_id,
             std::string const& id,
- std::string const& title,
+ value const& title,
             std::string* placeholder)
     {
+ // This is set even when docinfo is otherwise ignored.
+ if (compatibility_version < 106u && title.check())
+ state.last_title_1_1 = title.get_quickbook();
+
+ // TODO: This doesn't work when !have_docinfo, !include_doc_id.empty()
         if (have_docinfo || !include_doc_id.empty()) {
- std::string initial_doc_id =
- !include_doc_id.empty() ? include_doc_id :
- !id.empty() ? id :
- detail::make_identifier(title);
-
- // Since either: have_docinfo is true => !title.empty()
- // Or: !include_doc_id.empty()
- assert(!initial_doc_id.empty());
-
- id_category category =
- !include_doc_id.empty() || !id.empty() ?
- id_category::explicit_section_id :
- id_category::generated_doc;
+ std::string initial_doc_id = !include_doc_id.empty() ? include_doc_id : id;
 
             std::auto_ptr<section_manager> new_section_manager =
                 create_section_manager(state, compatibility_version);
             std::string initial_placeholder = new_section_manager->docinfo(
- initial_doc_id, category);
+ initial_doc_id, title);
             if (placeholder) *placeholder = initial_placeholder;
             return new_section_manager;
         }
@@ -594,9 +584,17 @@
 
     std::string section_manager_1_6::docinfo(
         std::string const& id,
- id_category category)
+ value const& title)
     {
- return begin_section(id, category);
+ if (!id.empty()) {
+ return begin_section(id, id_category::explicit_section_id);
+ }
+ else if (!title.empty()) {
+ return begin_section(detail::make_identifier(title.get_quickbook()), id_category::generated_doc);
+ }
+ else {
+ return begin_section("doc", id_category::numbered);
+ }
     }
 
     bool section_manager_1_6::end_file()

Modified: branches/quickbook-dev/tools/quickbook/src/id_manager.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/id_manager.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/id_manager.hpp 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -11,6 +11,7 @@
 
 #include <boost/scoped_ptr.hpp>
 #include <string>
+#include "values.hpp"
 
 namespace quickbook
 {
@@ -54,13 +55,13 @@
                 unsigned compatibility_version,
                 std::string const& include_doc_id,
                 std::string const& id,
- std::string const& title);
+ value const& title);
 
         void start_file(
                 unsigned compatibility_version,
                 std::string const& include_doc_id,
                 std::string const& id,
- std::string const& title);
+ value const& title);
 
         void end_file();
 

Modified: branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/Jamfile.v2 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -27,4 +27,7 @@
     [ quickbook-test id1-1.5 ]
     [ quickbook-test title_trailing_space-1_1 ]
     [ quickbook-test title_trailing_space-1_6 ]
+ [ quickbook-test empty_title-1_1 ]
+ [ quickbook-test empty_title-1_5 ]
+ [ quickbook-test empty_title-1_6 ]
     ;

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_1.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_1.gold 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,10 @@
+<?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="" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <section id=".test">
+ <title>Test</title>
+ <para>
+ Hello
+ </para>
+ </section>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_1.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_1.quickbook 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,8 @@
+[article
+]
+
+[section Test]
+
+Hello
+
+[endsect]
\ No newline at end of file

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_5.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_5.gold 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,10 @@
+<?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="" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <section id=".test">
+ <title><link linkend=".test">Test</link></title>
+ <para>
+ Hello
+ </para>
+ </section>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_5.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_5.quickbook 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,7 @@
+[article
+[quickbook 1.5]
+]
+
+[section Test]
+Hello
+[endsect]
\ No newline at end of file

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_6.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_6.gold 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,4 @@
+<?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="doc0" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_6.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/doc-info/empty_title-1_6.quickbook 2011-11-17 16:05:17 EST (Thu, 17 Nov 2011)
@@ -0,0 +1 @@
+[quickbook 1.6][article]
\ No newline at end of file


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