diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx index 58e7455a4..fca5b3e5e 100644 --- a/Source/cmDocumentation.cxx +++ b/Source/cmDocumentation.cxx @@ -338,6 +338,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os) return this->PrintDocumentationSingle(os); case cmDocumentation::SingleModule: return this->PrintDocumentationSingleModule(os); + case cmDocumentation::SinglePolicy: + return this->PrintDocumentationSinglePolicy(os); case cmDocumentation::SingleProperty: return this->PrintDocumentationSingleProperty(os); case cmDocumentation::SingleVariable: @@ -381,6 +383,8 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os) return this->PrintDocumentationModules(os); case cmDocumentation::CustomModules: return this->PrintDocumentationCustomModules(os); + case cmDocumentation::Policies: + return this->PrintDocumentationPolicies(os); case cmDocumentation::Properties: return this->PrintDocumentationProperties(os); case cmDocumentation::Variables: @@ -694,6 +698,12 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv) GET_OPT_ARGUMENT(help.Filename); help.HelpForm = this->GetFormFromFilename(help.Filename); } + else if(strcmp(argv[i], "--help-policies") == 0) + { + help.HelpType = cmDocumentation::Policies; + GET_OPT_ARGUMENT(help.Filename); + help.HelpForm = this->GetFormFromFilename(help.Filename); + } else if(strcmp(argv[i], "--help-variables") == 0) { help.HelpType = cmDocumentation::Variables; @@ -764,6 +774,13 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv) GET_OPT_ARGUMENT(help.Filename); help.HelpForm = this->GetFormFromFilename(help.Filename); } + else if(strcmp(argv[i], "--help-policy") == 0) + { + help.HelpType = cmDocumentation::SinglePolicy; + GET_OPT_ARGUMENT(help.Argument); + GET_OPT_ARGUMENT(help.Filename); + help.HelpForm = this->GetFormFromFilename(help.Filename); + } else if(strcmp(argv[i], "--help-variable") == 0) { help.HelpType = cmDocumentation::SingleVariable; @@ -1132,6 +1149,20 @@ bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os) return false; } +//---------------------------------------------------------------------------- +bool cmDocumentation::PrintDocumentationSinglePolicy(std::ostream& os) +{ + if (this->PrintDocumentationGeneric(os,"Policies")) + { + return true; + } + + // Argument was not a command. Complain. + os << "Argument \"" << this->CurrentArgument.c_str() + << "\" to --help-policy is not a CMake policy.\n"; + return false; +} + //---------------------------------------------------------------------------- bool cmDocumentation::PrintDocumentationSingleVariable(std::ostream& os) { @@ -1232,6 +1263,21 @@ bool cmDocumentation::PrintDocumentationCustomModules(std::ostream& os) return true; } +//---------------------------------------------------------------------------- +bool cmDocumentation::PrintDocumentationPolicies(std::ostream& os) +{ + this->ClearSections(); + this->AddSectionToPrint("Description"); + this->AddSectionToPrint("Policies"); + this->AddSectionToPrint("Copyright"); + this->AddSectionToPrint("See Also"); + + this->CurrentFormatter->PrintHeader(this->GetNameString(), os); + this->Print(os); + this->CurrentFormatter->PrintFooter(os); + return true; +} + //---------------------------------------------------------------------------- bool cmDocumentation::PrintDocumentationProperties(std::ostream& os) { diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h index 869f0c213..526da585b 100644 --- a/Source/cmDocumentation.h +++ b/Source/cmDocumentation.h @@ -138,11 +138,13 @@ private: bool PrintDocumentationSingle(std::ostream& os); bool PrintDocumentationSingleModule(std::ostream& os); bool PrintDocumentationSingleProperty(std::ostream& os); + bool PrintDocumentationSinglePolicy(std::ostream& os); bool PrintDocumentationSingleVariable(std::ostream& os); bool PrintDocumentationUsage(std::ostream& os); bool PrintDocumentationFull(std::ostream& os); bool PrintDocumentationModules(std::ostream& os); bool PrintDocumentationCustomModules(std::ostream& os); + bool PrintDocumentationPolicies(std::ostream& os); bool PrintDocumentationProperties(std::ostream& os); bool PrintDocumentationVariables(std::ostream& os); bool PrintDocumentationCurrentCommands(std::ostream& os); diff --git a/Source/cmDocumentationFormatter.h b/Source/cmDocumentationFormatter.h index 0e50a15a5..451215fc7 100644 --- a/Source/cmDocumentationFormatter.h +++ b/Source/cmDocumentationFormatter.h @@ -33,7 +33,7 @@ public: { None, Usage, Single, SingleModule, SingleProperty, SingleVariable, List, ModuleList, PropertyList, VariableList, Full, Properties, Variables, Modules, CustomModules, Commands, - CompatCommands, Copyright, Version }; + CompatCommands, Copyright, Version, Policies, SinglePolicy }; /** Forms of documentation output. */ enum Form { TextForm, HTMLForm, ManForm, UsageForm, DocbookForm }; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index bbd391363..1f5da4789 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -409,3 +409,23 @@ cmPolicies::GetPolicyStatus(cmPolicies::PolicyID id) return pos->second->Status; } +void cmPolicies::GetDocumentation(std::vector& v) +{ + // now loop over all the policies and set them as appropriate + std::map::iterator i + = this->Policies.begin(); + for (;i != this->Policies.end(); ++i) + { + std::string full; + full += i->second->LongDescription; + // add in some more text here based on status + // switch (i->second->Status) + // { + // case cmPolicies::WARN: + + cmDocumentationEntry e(i->second->IDString.c_str(), + i->second->ShortDescription.c_str(), + full.c_str()); + v.push_back(e); + } +} diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index cf0b4bfbb..fc812d10d 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -77,6 +77,9 @@ public: ///! return an error string for when a required policy is unspecified std::string GetRequiredPolicyError(cmPolicies::PolicyID id); + ///! Get docs for policies + void GetDocumentation(std::vector& v); + private: // might have to make these internal for VS6 not sure yet std::map Policies; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 80b0dfe64..9950d2086 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2444,6 +2444,11 @@ void cmake::GetCommandDocumentation(std::vector& v, } } +void cmake::GetPolicyDocumentation(std::vector& v) +{ + this->Policies->GetDocumentation(v); +} + void cmake::GetPropertiesDocumentation(std::map& v) { diff --git a/Source/cmake.h b/Source/cmake.h index 9ed4ddcfa..c7ed21ca8 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -258,6 +258,7 @@ class cmake void GetPropertiesDocumentation(std::map&); void GetGeneratorDocumentation(std::vector&); + void GetPolicyDocumentation(std::vector& entries); ///! Set/Get a property of this target file void SetProperty(const char *prop, const char *value); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index f635163c6..7f291c550 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -324,10 +324,12 @@ int do_cmake(int ac, char** av) } std::vector commands; + std::vector policies; std::vector compatCommands; std::vector generators; std::map propDocs; + hcm.GetPolicyDocumentation(policies); hcm.GetCommandDocumentation(commands, true, false); hcm.GetCommandDocumentation(compatCommands, false, true); hcm.GetPropertiesDocumentation(propDocs); @@ -340,6 +342,7 @@ int do_cmake(int ac, char** av) doc.AppendSection("Generators",generators); doc.PrependSection("Options",cmDocumentationOptions); doc.SetSection("Commands",commands); + doc.SetSection("Policies",policies); doc.AppendSection("Compatibility Commands",compatCommands); doc.SetSections(propDocs);