From 4175b514fc65cd452fbf1f62bd5c0c494568e9fd Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Mon, 21 Jul 2008 17:52:59 -0400 Subject: [PATCH] ENH: handle HTML documentation for single items better: no warning about ComputeSectionLinkPrefix, don't create an index for only one item Alex --- Source/cmDocumentation.cxx | 4 ++- Source/cmDocumentationFormatter.cxx | 4 +++ Source/cmDocumentationFormatterHTML.cxx | 45 ++++++++++++++++--------- 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 3b3dab736..72a819225 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -1350,7 +1350,9 @@ void cmDocumentation ::PrintDocumentationCommand(std::ostream& os, const cmDocumentationEntry &entry) { - cmDocumentationSection *sec = new cmDocumentationSection("",""); + // the string "SingleItem" will be used in a few places to detect the case + // that only the documentation for a single item is printed + cmDocumentationSection *sec = new cmDocumentationSection("SingleItem",""); sec->Append(entry); this->AllSections["temp"] = sec; this->ClearSections(); diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx index 9c633232c..97180476f 100644 --- a/Source/cmDocumentationFormatter.cxx +++ b/Source/cmDocumentationFormatter.cxx @@ -146,6 +146,10 @@ cmDocumentationFormatter::ComputeSectionLinkPrefix(std::string const& name) { return "see"; } + else if(name.find("SingleItem") != name.npos) + { + return "single_item"; + } else { std::cerr diff --git a/Source/cmDocumentationFormatterHTML.cxx b/Source/cmDocumentationFormatterHTML.cxx index a40ce99c6..0f7cc704d 100644 --- a/Source/cmDocumentationFormatterHTML.cxx +++ b/Source/cmDocumentationFormatterHTML.cxx @@ -117,30 +117,37 @@ void cmDocumentationFormatterHTML const cmDocumentationSection §ion, const char* name) { - if(name) - { - os << "

" << name << "

\n"; - } - std::string prefix = this->ComputeSectionLinkPrefix(name); const std::vector &entries = section.GetEntries(); - os << "\n" ; for(std::vector::const_iterator op = entries.begin(); op != entries.end();) @@ -240,6 +247,14 @@ void cmDocumentationFormatterHTML ::PrintIndex(std::ostream& os, std::vector& sections) { + // skip the index if only the help for a single item is printed + if ((sections.size() == 1) + && (sections[0]->GetName(this->GetForm()) != 0 ) + && (std::string(sections[0]->GetName(this->GetForm())) == "SingleItem")) + { + return; + } + os << "

Master Index

\n"; os << "
    \n"; for(unsigned int i=0; i < sections.size(); ++i)