diff options
author | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2012-09-07 08:55:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-09-08 11:42:06 (GMT) |
commit | 3a9e373a69345afbdafef9357eced5857a569f81 (patch) | |
tree | 2c008567c1d4fad2a80ddaa0c310536c0d250c1f /Source/cmDocumentationFormatterDocbook.cxx | |
parent | 67e7d49cb8e226221b46ce9182d9620fa3efcb63 (diff) | |
download | CMake-3a9e373a69345afbdafef9357eced5857a569f81.zip CMake-3a9e373a69345afbdafef9357eced5857a569f81.tar.gz CMake-3a9e373a69345afbdafef9357eced5857a569f81.tar.bz2 |
docbook: Add support for <abstract> at section level 1
If a section has subsections (ie. subelemens with a title), all elements
before the first title are written inside an <abstract>. Also wrap
<programlisting> in <para>, to allow preformatted output in abstracts.
Diffstat (limited to 'Source/cmDocumentationFormatterDocbook.cxx')
-rw-r--r-- | Source/cmDocumentationFormatterDocbook.cxx | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/Source/cmDocumentationFormatterDocbook.cxx b/Source/cmDocumentationFormatterDocbook.cxx index 51b93ae..9ff7847 100644 --- a/Source/cmDocumentationFormatterDocbook.cxx +++ b/Source/cmDocumentationFormatterDocbook.cxx @@ -115,11 +115,28 @@ void cmDocumentationFormatterDocbook std::string prefix = this->ComputeSectionLinkPrefix(name); const std::vector<cmDocumentationEntry> &entries = section.GetEntries(); + bool hasSubSections = false; for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); op != entries.end(); ++op) { if(op->Name.size()) { + hasSubSections = true; + break; + } + } + + bool inAbstract = false; + for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); + op != entries.end(); ++op) + { + if(op->Name.size()) + { + if(inAbstract) + { + os << "</abstract>\n"; + inAbstract = false; + } os << "<sect2 id=\""; this->PrintId(os, prefix.c_str(), op->Name); os << "\">\n<title>"; @@ -140,6 +157,11 @@ void cmDocumentationFormatterDocbook } else { + if(hasSubSections && op == entries.begin()) + { + os << "<abstract>\n"; + inAbstract = true; + } this->PrintFormatted(os, op->Brief.c_str()); } } @@ -157,9 +179,9 @@ void cmDocumentationFormatterDocbook void cmDocumentationFormatterDocbook ::PrintPreformatted(std::ostream& os, const char* text) { - os << "<programlisting>"; + os << "<para>\n<programlisting>"; cmDocumentationPrintDocbookEscapes(os, text); - os << "</programlisting>\n"; + os << "</programlisting>\n</para>\n"; } void cmDocumentationFormatterDocbook |