From 44cce51a1a36973344a0bc1bb99f39410fd678e6 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Mon, 22 Oct 2007 15:33:19 -0400 Subject: [PATCH] COMP: fix some warnings and add some doc strings back in --- Source/cmDocumentation.cxx | 145 ++++++++++++++++-------------- Source/cmDocumentation.h | 8 ++ Source/cmDocumentationSection.cxx | 15 ++++ Source/cmDocumentationSection.h | 9 +- Source/cmakemain.cxx | 6 +- 5 files changed, 109 insertions(+), 74 deletions(-) diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 6c50c40a1..1565c592e 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -103,71 +103,6 @@ static const char *cmCompatCommandsDocumentationDescription[][3] = {0,0,0} }; -//---------------------------------------------------------------------------- -static const char *cmDocumentationCommandsHeader[][3] = -{ - {0, - "The following commands are available in CMakeLists.txt code:", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationGlobalPropertiesHeader[][3] = -{ - {0, - "The following global properties are available in CMakeLists.txt code:", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationDirectoryPropertiesHeader[][3] = -{ - {0 - ,"The following directory properties are available in CMakeLists.txt code:" - ,0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationTargetPropertiesHeader[][3] = -{ - {0, - "The following target properties are available in CMakeLists.txt code:", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationTestPropertiesHeader[][3] = -{ - {0 - ,"The following properties for tests are available in CMakeLists.txt code:" - ,0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationSourceFilePropertiesHeader[][3] = -{ - {0 - ,"The following source file properties are available in CMakeLists.txt code:" - , 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationVariablePropertiesHeader[][3] = -{ - {0, "The following variables are available in CMakeLists.txt code:", 0}, - {0,0,0} -}; - -//---------------------------------------------------------------------------- -static const char *cmDocumentationCachedVariablePropertiesHeader[][3] = -{ - {0,"The following cache variables are available in CMakeLists.txt code:", 0}, - {0,0,0} -}; - //---------------------------------------------------------------------------- static const char *cmDocumentationModulesHeader[][3] = { @@ -288,6 +223,18 @@ cmDocumentation::cmDocumentation() sec = new cmDocumentationSection("See Also","SEE ALSO"); sec->Append(cmDocumentationStandardSeeAlso); this->AllSections["Standard See Also"] = sec; + + sec = new cmDocumentationSection("Options","OPTIONS"); + sec->Append(cmDocumentationStandardOptions); + this->AllSections["Options"] = sec; + + sec = new cmDocumentationSection("Properties","PROPERTIES"); + sec->Append(cmPropertiesDocumentationDescription); + this->AllSections["Properties Description"] = sec; + + sec = new cmDocumentationSection("Generators","GENERATORS"); + sec->Append(cmDocumentationGeneratorsHeader); + this->AllSections["Generators"] = sec; } //---------------------------------------------------------------------------- @@ -298,6 +245,12 @@ cmDocumentation::~cmDocumentation() { delete [] *i; } + for(std::map::iterator i = + this->AllSections.begin(); + i != this->AllSections.end(); ++i) + { + delete i->second; + } } //---------------------------------------------------------------------------- @@ -375,6 +328,7 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os) this->PrintDocumentationList(os,"Modules"); return true; case cmDocumentation::PropertyList: + this->PrintDocumentationList(os,"Properties Description"); this->PrintDocumentationList(os,"Properties of Global Scope"); this->PrintDocumentationList(os,"Properties on Directories"); this->PrintDocumentationList(os,"Properties on Targets"); @@ -414,7 +368,8 @@ bool cmDocumentation::CreateModulesSection() dir.Load(cmakeModules.c_str()); if (dir.GetNumberOfFiles() > 0) { - this->AllSections["Modules"]->Append(cmDocumentationModulesHeader[0]); + sec->Append(cmDocumentationModulesHeader[0]); + sec->Append(cmModulesDocumentationDescription); this->CreateModuleDocsForDir(dir, *this->AllSections["Modules"]); } return true; @@ -442,6 +397,7 @@ bool cmDocumentation::CreateCustomModulesSection() new cmDocumentationSection("Custom CMake Modules","CUSTOM MODULES"); this->AllSections["Custom CMake Modules"] = sec; sec->Append(cmDocumentationCustomModulesHeader[0]); + sec->Append(cmCustomModulesDocumentationDescription); sectionHasHeader = true; } this->CreateModuleDocsForDir @@ -855,6 +811,63 @@ void cmDocumentation } } +//---------------------------------------------------------------------------- +void cmDocumentation::PrependSection(const char *name, + const char *docs[][3]) +{ + cmDocumentationSection *sec = 0; + if (this->AllSections.find(name) == this->AllSections.end()) + { + cmDocumentationSection *sec = + new cmDocumentationSection(name, + cmSystemTools::UpperCase(name).c_str()); + this->SetSection(name,sec); + } + else + { + sec = this->AllSections[name]; + } + sec->Prepend(docs); +} + +//---------------------------------------------------------------------------- +void cmDocumentation::AppendSection(const char *name, + const char *docs[][3]) +{ + cmDocumentationSection *sec = 0; + if (this->AllSections.find(name) == this->AllSections.end()) + { + cmDocumentationSection *sec = + new cmDocumentationSection(name, + cmSystemTools::UpperCase(name).c_str()); + this->SetSection(name,sec); + } + else + { + sec = this->AllSections[name]; + } + sec->Append(docs); +} + +//---------------------------------------------------------------------------- +void cmDocumentation::AppendSection(const char *name, + std::vector &docs) +{ + cmDocumentationSection *sec = 0; + if (this->AllSections.find(name) == this->AllSections.end()) + { + cmDocumentationSection *sec = + new cmDocumentationSection(name, + cmSystemTools::UpperCase(name).c_str()); + this->SetSection(name,sec); + } + else + { + sec = this->AllSections[name]; + } + sec->Append(docs); +} + //---------------------------------------------------------------------------- void cmDocumentation::SetSeeAlsoList(const char *data[][3]) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 0de0fa221..99000eed9 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -73,6 +73,14 @@ public: void SetSections(std::map §ions); + /** Add the documentation to the beginning/end of the section */ + void PrependSection(const char *sectionName, + const char *docs[][3]); + void AppendSection(const char *sectionName, + const char *docs[][3]); + void AppendSection(const char *sectionName, + std::vector &docs); + /** * Print documentation in the given form. All previously added * sections will be generated. diff --git a/Source/cmDocumentationSection.cxx b/Source/cmDocumentationSection.cxx index c4a4edf05..88b9eeb7e 100644 --- a/Source/cmDocumentationSection.cxx +++ b/Source/cmDocumentationSection.cxx @@ -30,6 +30,21 @@ void cmDocumentationSection::Append(const char *data[][3]) } } +//---------------------------------------------------------------------------- +void cmDocumentationSection::Prepend(const char *data[][3]) +{ + std::vector tmp; + int i = 0; + while(data[i][1]) + { + tmp.push_back(cmDocumentationEntry(data[i][0], + data[i][1], + data[i][2])); + data += 1; + } + this->Entries.insert(this->Entries.begin(),tmp.begin(),tmp.end()); +} + //---------------------------------------------------------------------------- void cmDocumentationSection::Append(const char *n, const char *b, const char *f) diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h index 60e735bc6..97a15af1a 100644 --- a/Source/cmDocumentationSection.h +++ b/Source/cmDocumentationSection.h @@ -56,11 +56,10 @@ public: /** Append an entry to this section using NULL terminated chars */ void Append(const char *[][3]); void Append(const char *n, const char *b, const char *f); - - /** Set the contents of this section. */ -// void Set(const std::vector header, -// const std::vector section, -// const std::vector footer); + + /** prepend some documentation to this section */ + void Prepend(const char *[][3]); + private: std::string Name; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index e7a850ce6..df5f37bba 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -300,9 +300,9 @@ int do_cmake(int ac, char** av) std::vector commands; std::vector compatCommands; + std::vector generators; std::map propDocs; - std::vector generators; hcm.GetCommandDocumentation(commands, true, false); hcm.GetCommandDocumentation(compatCommands, false, true); hcm.GetPropertiesDocumentation(propDocs); @@ -312,8 +312,8 @@ int do_cmake(int ac, char** av) doc.SetSection("Name",cmDocumentationName); doc.SetSection("Usage",cmDocumentationUsage); doc.SetSection("Description",cmDocumentationDescription); - doc.SetSection("Generators",generators); - doc.SetSection("Options",cmDocumentationOptions); + doc.AppendSection("Generators",generators); + doc.PrependSection("Options",cmDocumentationOptions); doc.SetSection("Commands",commands); doc.SetSection("Compatibility Commands",compatCommands); doc.SetSections(propDocs);