diff options
author | Alexander Neundorf <neundorf@kde.org> | 2008-07-21 17:52:59 -0400 |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2008-07-21 17:52:59 -0400 |
commit | 4175b514fc65cd452fbf1f62bd5c0c494568e9fd (patch) | |
tree | 6e726407fc166a557beb0726a315ccedf0d066cb /Source | |
parent | 76878d928e66a1ce850beba7d9d114f46ee1d549 (diff) | |
download | cmake-4175b514fc65cd452fbf1f62bd5c0c494568e9fd.tar.gz |
ENH: handle HTML documentation for single items better: no warning about
ComputeSectionLinkPrefix, don't create an index for only one item
Alex
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDocumentation.cxx | 4 | ||||
-rw-r--r-- | Source/cmDocumentationFormatter.cxx | 4 | ||||
-rw-r--r-- | Source/cmDocumentationFormatterHTML.cxx | 45 |
3 files changed, 37 insertions, 16 deletions
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 3b3dab736c..72a819225f 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 9c633232c0..97180476f9 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 a40ce99c62..0f7cc704d0 100644 --- a/Source/cmDocumentationFormatterHTML.cxx +++ b/Source/cmDocumentationFormatterHTML.cxx @@ -117,30 +117,37 @@ void cmDocumentationFormatterHTML const cmDocumentationSection §ion, const char* name) { - if(name) - { - os << "<h2><a name=\"section_" << name << "\"/>" << name << "</h2>\n"; - } - std::string prefix = this->ComputeSectionLinkPrefix(name); const std::vector<cmDocumentationEntry> &entries = section.GetEntries(); - os << "<ul>\n"; - for(std::vector<cmDocumentationEntry>::const_iterator op - = entries.begin(); op != entries.end(); ++ op ) + // skip the index if the help for only a single item (--help-command, + // --help-policy, --help-property, --help-module) is printed + bool isSingleItemHelp = ((name!=0) && (strcmp(name, "SingleItem")==0)); + + if (!isSingleItemHelp) { - if(op->Name.size()) + if (name) { - os << " <li><a href=\"#" << prefix << ":"; - cmDocumentationPrintHTMLId(os, op->Name.c_str()); - os << "\"><b><code>"; - this->PrintHTMLEscapes(os, op->Name.c_str()); - os << "</code></b></a></li>"; + os << "<h2><a name=\"section_" << name << "\"/>" << name << "</h2>\n"; } + + os << "<ul>\n"; + for(std::vector<cmDocumentationEntry>::const_iterator op + = entries.begin(); op != entries.end(); ++ op ) + { + if(op->Name.size()) + { + os << " <li><a href=\"#" << prefix << ":"; + cmDocumentationPrintHTMLId(os, op->Name.c_str()); + os << "\"><b><code>"; + this->PrintHTMLEscapes(os, op->Name.c_str()); + os << "</code></b></a></li>"; + } + } + os << "</ul>\n" ; } - os << "</ul>\n" ; for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); op != entries.end();) @@ -240,6 +247,14 @@ void cmDocumentationFormatterHTML ::PrintIndex(std::ostream& os, std::vector<const cmDocumentationSection *>& 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 << "<h2><a name=\"section_Index\"/>Master Index</h2>\n"; os << "<ul>\n"; for(unsigned int i=0; i < sections.size(); ++i) |