mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-17 15:32:10 +08:00
cmake: Return generator docs directly
The GetGeneratorDocumentation() function was not accurately named and required the vector to populate to be passed as a function argument. This commit makes the slightly renamed function return by value, making it a true getter as implied by its name. Some minor refactoring of the implementation also makes the steps of populating the vector clearer.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include "cmCursesMainForm.h"
|
||||
#include "cmCursesStandardIncludes.h"
|
||||
#include "cmDocumentation.h"
|
||||
#include "cmDocumentationEntry.h"
|
||||
#include "cmDocumentationEntry.h" // IWYU pragma: keep
|
||||
#include "cmState.h"
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmake.h"
|
||||
@@ -88,8 +88,7 @@ int main(int argc, char const* const* argv)
|
||||
hcm.SetHomeDirectory("");
|
||||
hcm.SetHomeOutputDirectory("");
|
||||
hcm.AddCMakePaths();
|
||||
std::vector<cmDocumentationEntry> generators;
|
||||
hcm.GetGeneratorDocumentation(generators);
|
||||
auto generators = hcm.GetGeneratorsDocumentation();
|
||||
doc.SetName("ccmake");
|
||||
doc.SetSection("Name", cmDocumentationName);
|
||||
doc.SetSection("Usage", cmDocumentationUsage);
|
||||
|
@@ -69,8 +69,7 @@ int main(int argc, char** argv)
|
||||
hcm.SetHomeOutputDirectory("");
|
||||
hcm.AddCMakePaths();
|
||||
|
||||
std::vector<cmDocumentationEntry> generators;
|
||||
hcm.GetGeneratorDocumentation(generators);
|
||||
auto generators = hcm.GetGeneratorsDocumentation();
|
||||
doc.SetName("cmake");
|
||||
doc.SetSection("Name", cmDocumentationName);
|
||||
doc.SetSection("Usage", cmDocumentationUsage);
|
||||
|
@@ -1924,13 +1924,19 @@ void cmake::SetIsInTryCompile(bool b)
|
||||
this->State->SetIsInTryCompile(b);
|
||||
}
|
||||
|
||||
void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
|
||||
void cmake::AppendGlobalGeneratorsDocumentation(
|
||||
std::vector<cmDocumentationEntry>& v)
|
||||
{
|
||||
for (cmGlobalGeneratorFactory* g : this->Generators) {
|
||||
cmDocumentationEntry e;
|
||||
g->GetDocumentation(e);
|
||||
v.push_back(std::move(e));
|
||||
}
|
||||
}
|
||||
|
||||
void cmake::AppendExtraGeneratorsDocumentation(
|
||||
std::vector<cmDocumentationEntry>& v)
|
||||
{
|
||||
for (cmExternalMakefileProjectGeneratorFactory* eg : this->ExtraGenerators) {
|
||||
const std::string doc = eg->GetDocumentation();
|
||||
const std::string name = eg->GetName();
|
||||
@@ -1956,12 +1962,19 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<cmDocumentationEntry> cmake::GetGeneratorsDocumentation()
|
||||
{
|
||||
std::vector<cmDocumentationEntry> v;
|
||||
this->AppendGlobalGeneratorsDocumentation(v);
|
||||
this->AppendExtraGeneratorsDocumentation(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
void cmake::PrintGeneratorList()
|
||||
{
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
cmDocumentation doc;
|
||||
std::vector<cmDocumentationEntry> generators;
|
||||
this->GetGeneratorDocumentation(generators);
|
||||
auto generators = this->GetGeneratorsDocumentation();
|
||||
doc.AppendSection("Generators", generators);
|
||||
std::cerr << "\n";
|
||||
doc.PrintDocumentation(cmDocumentation::ListGenerators, std::cerr);
|
||||
|
@@ -292,7 +292,7 @@ public:
|
||||
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
|
||||
#endif
|
||||
|
||||
void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
|
||||
std::vector<cmDocumentationEntry> GetGeneratorsDocumentation();
|
||||
|
||||
///! Set/Get a property of this target file
|
||||
void SetProperty(const std::string& prop, const char* value);
|
||||
@@ -533,6 +533,9 @@ private:
|
||||
|
||||
void CreateDefaultGlobalGenerator();
|
||||
|
||||
void AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
|
||||
void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
|
||||
|
||||
/**
|
||||
* Convert a message type between a warning and an error, based on the state
|
||||
* of the error output CMake variables, in the cache.
|
||||
|
@@ -2,7 +2,7 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmDocumentationEntry.h"
|
||||
#include "cmDocumentationEntry.h" // IWYU pragma: keep
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
@@ -227,9 +227,7 @@ int do_cmake(int ac, char const* const* av)
|
||||
std::vector<std::string> args(av, av + ac);
|
||||
hcm.SetCacheArgs(args);
|
||||
|
||||
std::vector<cmDocumentationEntry> generators;
|
||||
|
||||
hcm.GetGeneratorDocumentation(generators);
|
||||
auto generators = hcm.GetGeneratorsDocumentation();
|
||||
|
||||
doc.SetName("cmake");
|
||||
doc.SetSection("Name", cmDocumentationName);
|
||||
|
Reference in New Issue
Block a user