ENH:
-in the full documentation there is now an extra section for compatibility commands, so users see which commands they shouldn't use -cmake -h <command> now also works with lower case commands --help-fullm --help-command, --help-module and --help-property now determine the output format from the extension of the given filename Let me know if there are some things I overlooked. Alex
This commit is contained in:
parent
789f0b26d9
commit
c95dc91237
@ -110,8 +110,10 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
cmake hcm;
|
cmake hcm;
|
||||||
std::vector<cmDocumentationEntry> commands;
|
std::vector<cmDocumentationEntry> commands;
|
||||||
|
std::vector<cmDocumentationEntry> compatCommands;
|
||||||
std::vector<cmDocumentationEntry> generators;
|
std::vector<cmDocumentationEntry> generators;
|
||||||
hcm.GetCommandDocumentation(commands);
|
hcm.GetCommandDocumentation(commands, true, false);
|
||||||
|
hcm.GetCommandDocumentation(compatCommands, false, true);
|
||||||
hcm.GetGeneratorDocumentation(generators);
|
hcm.GetGeneratorDocumentation(generators);
|
||||||
doc.SetName("ccmake");
|
doc.SetName("ccmake");
|
||||||
doc.SetNameSection(cmDocumentationName);
|
doc.SetNameSection(cmDocumentationName);
|
||||||
@ -120,6 +122,7 @@ int main(int argc, char** argv)
|
|||||||
doc.SetGeneratorsSection(&generators[0]);
|
doc.SetGeneratorsSection(&generators[0]);
|
||||||
doc.SetOptionsSection(cmDocumentationOptions);
|
doc.SetOptionsSection(cmDocumentationOptions);
|
||||||
doc.SetCommandsSection(&commands[0]);
|
doc.SetCommandsSection(&commands[0]);
|
||||||
|
doc.SetCompatCommandsSection(&compatCommands[0]);
|
||||||
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
||||||
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
return doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
|
|
||||||
|
|
||||||
|
const cmDocumentationEntry cmDocumentation::cmSection::EmptySection ={0,0,0};
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
static const cmDocumentationEntry cmDocumentationStandardOptions[] =
|
static const cmDocumentationEntry cmDocumentationStandardOptions[] =
|
||||||
{
|
{
|
||||||
@ -35,7 +38,7 @@ static const cmDocumentationEntry cmDocumentationStandardOptions[] =
|
|||||||
{"--help-html [file]", "Print full help in HTML format.",
|
{"--help-html [file]", "Print full help in HTML format.",
|
||||||
"This option is used by CMake authors to help produce web pages. "
|
"This option is used by CMake authors to help produce web pages. "
|
||||||
"If a file is specified, the help is written into it."},
|
"If a file is specified, the help is written into it."},
|
||||||
{"--help-man [file]", "Print a UNIX man page and exit.",
|
{"--help-man [file]", "Print full help as a UNIX man page and exit.",
|
||||||
"This option is used by the cmake build to generate the UNIX man page. "
|
"This option is used by the cmake build to generate the UNIX man page. "
|
||||||
"If a file is specified, the help is written into it."},
|
"If a file is specified, the help is written into it."},
|
||||||
{"--version [file]", "Show program name/version banner and exit.",
|
{"--version [file]", "Show program name/version banner and exit.",
|
||||||
@ -287,35 +290,11 @@ void cmDocumentation::ClearSections()
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
|
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
|
||||||
{
|
{
|
||||||
if(ht != cmDocumentation::HTML && ht != cmDocumentation::Man)
|
if ((this->CurrentForm != HTMLForm) && (this->CurrentForm != ManForm))
|
||||||
{
|
{
|
||||||
this->PrintVersion(os);
|
this->PrintVersion(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ht)
|
|
||||||
{
|
|
||||||
case cmDocumentation::Full:
|
|
||||||
case cmDocumentation::Single:
|
|
||||||
case cmDocumentation::SingleModule:
|
|
||||||
case cmDocumentation::SingleProperty:
|
|
||||||
case cmDocumentation::List:
|
|
||||||
case cmDocumentation::ModuleList:
|
|
||||||
case cmDocumentation::PropertyList:
|
|
||||||
this->CurrentForm = TextForm;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case cmDocumentation::HTML: this->CurrentForm = HTMLForm; break;
|
|
||||||
case cmDocumentation::Man: this->CurrentForm = ManForm; break;
|
|
||||||
|
|
||||||
case cmDocumentation::Usage:
|
|
||||||
case cmDocumentation::Copyright:
|
|
||||||
case cmDocumentation::Version:
|
|
||||||
this->CurrentForm = UsageForm;
|
|
||||||
break;
|
|
||||||
case cmDocumentation::None:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (ht)
|
switch (ht)
|
||||||
{
|
{
|
||||||
case cmDocumentation::Usage:
|
case cmDocumentation::Usage:
|
||||||
@ -330,9 +309,7 @@ bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
|
|||||||
case cmDocumentation::ModuleList: return this->PrintModuleList(os);
|
case cmDocumentation::ModuleList: return this->PrintModuleList(os);
|
||||||
case cmDocumentation::PropertyList: return this->PrintPropertyList(os);
|
case cmDocumentation::PropertyList: return this->PrintPropertyList(os);
|
||||||
|
|
||||||
case cmDocumentation::Full:
|
case cmDocumentation::Full: return this->PrintDocumentationFull(os);
|
||||||
case cmDocumentation::HTML:
|
|
||||||
case cmDocumentation::Man: return this->PrintDocumentationFull(os);
|
|
||||||
|
|
||||||
case cmDocumentation::Copyright: return this->PrintCopyright(os);
|
case cmDocumentation::Copyright: return this->PrintCopyright(os);
|
||||||
case cmDocumentation::Version: return true;
|
case cmDocumentation::Version: return true;
|
||||||
@ -463,38 +440,20 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
|||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
// Loop over requested documentation types.
|
// Loop over requested documentation types.
|
||||||
for(RequestedMapType::const_iterator i = this->RequestedMap.begin();
|
for(std::vector<RequestedHelpItem>::const_iterator
|
||||||
i != this->RequestedMap.end(); ++i)
|
i = this->RequestedHelpItems.begin();
|
||||||
|
i != this->RequestedHelpItems.end();
|
||||||
|
++i)
|
||||||
{
|
{
|
||||||
// Special case for printing help for a single command.
|
this->CurrentForm = i->Form;
|
||||||
if(i->first == cmDocumentation::Usage && i->second.length() > 0 &&
|
this->CurrentArgument = i->Argument;
|
||||||
!this->CommandsSection.IsEmpty())
|
|
||||||
{
|
|
||||||
// Check if the argument to the usage request was a command.
|
|
||||||
for(cmDocumentationEntry* entry = this->CommandsSection.GetEntries();
|
|
||||||
entry->brief; ++entry)
|
|
||||||
{
|
|
||||||
if(entry->name && (strcmp(entry->name, i->second.c_str()) == 0))
|
|
||||||
{
|
|
||||||
this->PrintDocumentationCommand(os, entry);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Argument was not a command. Complain.
|
|
||||||
os << "Help argument \"" << i->second.c_str()
|
|
||||||
<< "\" is not a CMake command. "
|
|
||||||
<< "Use --help-command-list to see all commands.\n";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a file name was given, use it. Otherwise, default to the
|
// If a file name was given, use it. Otherwise, default to the
|
||||||
// given stream.
|
// given stream.
|
||||||
std::ofstream* fout = 0;
|
std::ofstream* fout = 0;
|
||||||
std::ostream* s = &os;
|
std::ostream* s = &os;
|
||||||
if(i->second.length() > 0)
|
if(i->Filename.length() > 0)
|
||||||
{
|
{
|
||||||
fout = new std::ofstream(i->second.c_str(), std::ios::out);
|
fout = new std::ofstream(i->Filename.c_str(), std::ios::out);
|
||||||
if(fout)
|
if(fout)
|
||||||
{
|
{
|
||||||
s = fout;
|
s = fout;
|
||||||
@ -506,7 +465,7 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print this documentation type to the stream.
|
// Print this documentation type to the stream.
|
||||||
if(!this->PrintDocumentation(i->first, *s) || !*s)
|
if(!this->PrintDocumentation(i->Type, *s) || !*s)
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
}
|
}
|
||||||
@ -520,22 +479,60 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GET_OPT_COMMAND(target) \
|
||||||
|
if((i+1 < argc) && !this->IsOption(argv[i+1])) \
|
||||||
|
{ \
|
||||||
|
target = cmSystemTools::UpperCase(argv[i+1]); \
|
||||||
|
i = i+1; \
|
||||||
|
};
|
||||||
|
|
||||||
|
#define GET_OPT_FILENAME(target) \
|
||||||
|
if((i+1 < argc) && !this->IsOption(argv[i+1])) \
|
||||||
|
{ \
|
||||||
|
target = argv[i+1]; \
|
||||||
|
i = i+1; \
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
cmDocumentation::Form cmDocumentation::GetFormFromFilename(
|
||||||
|
const std::string& filename)
|
||||||
|
{
|
||||||
|
std::string ext = cmSystemTools::GetFilenameExtension(filename);
|
||||||
|
ext = cmSystemTools::UpperCase(ext);
|
||||||
|
if ((ext == ".HTM") || (ext == ".HTML"))
|
||||||
|
{
|
||||||
|
return cmDocumentation::HTMLForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ".1" to ".9" should be manpages
|
||||||
|
if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
|
||||||
|
{
|
||||||
|
return cmDocumentation::ManForm;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cmDocumentation::TextForm;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmDocumentation::CheckOptions(int argc, const char* const* argv)
|
bool cmDocumentation::CheckOptions(int argc, const char* const* argv)
|
||||||
{
|
{
|
||||||
// Providing zero arguments gives usage information.
|
// Providing zero arguments gives usage information.
|
||||||
if(argc == 1)
|
if(argc == 1)
|
||||||
{
|
{
|
||||||
this->RequestedMap[cmDocumentation::Usage] = "";
|
RequestedHelpItem help;
|
||||||
|
help.Type = cmDocumentation::Usage;
|
||||||
|
help.Form = cmDocumentation::UsageForm;
|
||||||
|
this->RequestedHelpItems.push_back(help);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for supported help options.
|
// Search for supported help options.
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
for(int i=1; i < argc; ++i)
|
for(int i=1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
|
RequestedHelpItem help;
|
||||||
// Check if this is a supported help option.
|
// Check if this is a supported help option.
|
||||||
Type type = cmDocumentation::None;
|
|
||||||
if((strcmp(argv[i], "-help") == 0) ||
|
if((strcmp(argv[i], "-help") == 0) ||
|
||||||
(strcmp(argv[i], "--help") == 0) ||
|
(strcmp(argv[i], "--help") == 0) ||
|
||||||
(strcmp(argv[i], "/?") == 0) ||
|
(strcmp(argv[i], "/?") == 0) ||
|
||||||
@ -543,83 +540,91 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv)
|
|||||||
(strcmp(argv[i], "-h") == 0) ||
|
(strcmp(argv[i], "-h") == 0) ||
|
||||||
(strcmp(argv[i], "-H") == 0))
|
(strcmp(argv[i], "-H") == 0))
|
||||||
{
|
{
|
||||||
type = cmDocumentation::Usage;
|
help.Type = cmDocumentation::Usage;
|
||||||
|
help.Form = cmDocumentation::UsageForm;
|
||||||
|
GET_OPT_COMMAND(help.Argument);
|
||||||
|
// special case for single command
|
||||||
|
if (!help.Argument.empty())
|
||||||
|
{
|
||||||
|
help.Type = cmDocumentation::Single;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-full") == 0)
|
else if(strcmp(argv[i], "--help-full") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::Full;
|
help.Type = cmDocumentation::Full;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = this->GetFormFromFilename(help.Filename);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-html") == 0)
|
else if(strcmp(argv[i], "--help-html") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::HTML;
|
help.Type = cmDocumentation::Full;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = cmDocumentation::HTMLForm;
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-man") == 0)
|
else if(strcmp(argv[i], "--help-man") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::Man;
|
help.Type = cmDocumentation::Full;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = cmDocumentation::ManForm;
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-command") == 0)
|
else if(strcmp(argv[i], "--help-command") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::Single;
|
help.Type = cmDocumentation::Single;
|
||||||
if((i+1 < argc) && !this->IsOption(argv[i+1]))
|
GET_OPT_COMMAND(help.Argument);
|
||||||
{
|
GET_OPT_FILENAME(help.Filename);
|
||||||
this->SingleCommand = argv[i+1];
|
help.Form = this->GetFormFromFilename(help.Filename);
|
||||||
this->SingleCommand = cmSystemTools::UpperCase(this->SingleCommand);
|
|
||||||
i = i+1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-module") == 0)
|
else if(strcmp(argv[i], "--help-module") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::SingleModule;
|
help.Type = cmDocumentation::SingleModule;
|
||||||
if((i+1 < argc) && !this->IsOption(argv[i+1]))
|
GET_OPT_COMMAND(help.Argument);
|
||||||
{
|
GET_OPT_FILENAME(help.Filename);
|
||||||
this->SingleModuleName = argv[i+1];
|
help.Form = this->GetFormFromFilename(help.Filename);
|
||||||
i = i+1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-property") == 0)
|
else if(strcmp(argv[i], "--help-property") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::SingleProperty;
|
help.Type = cmDocumentation::SingleProperty;
|
||||||
if((i+1 < argc) && !this->IsOption(argv[i+1]))
|
GET_OPT_COMMAND(help.Argument);
|
||||||
{
|
GET_OPT_FILENAME(help.Filename);
|
||||||
this->SinglePropertyName = argv[i+1];
|
help.Form = this->GetFormFromFilename(help.Filename);
|
||||||
i = i+1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-command-list") == 0)
|
else if(strcmp(argv[i], "--help-command-list") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::List;
|
help.Type = cmDocumentation::List;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = cmDocumentation::TextForm;
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-module-list") == 0)
|
else if(strcmp(argv[i], "--help-module-list") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::ModuleList;
|
help.Type = cmDocumentation::ModuleList;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = cmDocumentation::TextForm;
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-property-list") == 0)
|
else if(strcmp(argv[i], "--help-property-list") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::PropertyList;
|
help.Type = cmDocumentation::PropertyList;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = cmDocumentation::TextForm;
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--copyright") == 0)
|
else if(strcmp(argv[i], "--copyright") == 0)
|
||||||
{
|
{
|
||||||
type = cmDocumentation::Copyright;
|
help.Type = cmDocumentation::Copyright;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = cmDocumentation::UsageForm;
|
||||||
}
|
}
|
||||||
else if((strcmp(argv[i], "--version") == 0) ||
|
else if((strcmp(argv[i], "--version") == 0) ||
|
||||||
(strcmp(argv[i], "-version") == 0) ||
|
(strcmp(argv[i], "-version") == 0) ||
|
||||||
(strcmp(argv[i], "/V") == 0))
|
(strcmp(argv[i], "/V") == 0))
|
||||||
{
|
{
|
||||||
type = cmDocumentation::Version;
|
help.Type = cmDocumentation::Version;
|
||||||
|
GET_OPT_FILENAME(help.Filename);
|
||||||
|
help.Form = cmDocumentation::UsageForm;
|
||||||
}
|
}
|
||||||
if(type)
|
if(help.Type != None)
|
||||||
{
|
{
|
||||||
// This is a help option. See if there is a file name given.
|
// This is a help option. See if there is a file name given.
|
||||||
result = true;
|
result = true;
|
||||||
if((i+1 < argc) && !this->IsOption(argv[i+1]))
|
this->RequestedHelpItems.push_back(help);
|
||||||
{
|
|
||||||
this->RequestedMap[type] = argv[i+1];
|
|
||||||
i = i+1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->RequestedMap[type] = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -1206,24 +1211,26 @@ bool cmDocumentation::PrintDocumentationSingle(std::ostream& os)
|
|||||||
os << "Internal error: commands list is empty." << std::endl;
|
os << "Internal error: commands list is empty." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(this->SingleCommand.length() == 0)
|
if(this->CurrentArgument.length() == 0)
|
||||||
{
|
{
|
||||||
os << "Argument --help-command needs a command name.\n";
|
os << "Argument --help-command needs a command name.\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(cmDocumentationEntry* entry = this->CommandsSection.GetEntries();
|
for(const cmDocumentationEntry* entry = this->CommandsSection.GetEntries();
|
||||||
entry->brief; ++entry)
|
entry->brief; ++entry)
|
||||||
{
|
{
|
||||||
if(entry->name && this->SingleCommand == entry->name)
|
if(entry->name && this->CurrentArgument == entry->name)
|
||||||
{
|
{
|
||||||
this->PrintDocumentationCommand(os, entry);
|
this->PrintDocumentationCommand(os, entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(cmDocumentationEntry* entry = this->CompatCommandsSection.GetEntries();
|
for(const cmDocumentationEntry*
|
||||||
entry->brief; ++entry)
|
entry = this->CompatCommandsSection.GetEntries();
|
||||||
|
entry->brief;
|
||||||
|
++entry)
|
||||||
{
|
{
|
||||||
if(entry->name && this->SingleCommand == entry->name)
|
if(entry->name && this->CurrentArgument == entry->name)
|
||||||
{
|
{
|
||||||
this->PrintDocumentationCommand(os, entry);
|
this->PrintDocumentationCommand(os, entry);
|
||||||
return true;
|
return true;
|
||||||
@ -1231,7 +1238,7 @@ bool cmDocumentation::PrintDocumentationSingle(std::ostream& os)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Argument was not a command. Complain.
|
// Argument was not a command. Complain.
|
||||||
os << "Argument \"" << this->SingleCommand.c_str()
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
||||||
<< "\" to --help-command is not a CMake command. "
|
<< "\" to --help-command is not a CMake command. "
|
||||||
<< "Use --help-command-list to see all commands.\n";
|
<< "Use --help-command-list to see all commands.\n";
|
||||||
return false;
|
return false;
|
||||||
@ -1240,18 +1247,18 @@ bool cmDocumentation::PrintDocumentationSingle(std::ostream& os)
|
|||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os)
|
bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os)
|
||||||
{
|
{
|
||||||
if(this->SingleModuleName.length() == 0)
|
if(this->CurrentArgument.length() == 0)
|
||||||
{
|
{
|
||||||
os << "Argument --help-module needs a module name.\n";
|
os << "Argument --help-module needs a module name.\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string cmakeModules = this->CMakeRoot;
|
std::string cmakeModules = this->CMakeRoot;
|
||||||
cmakeModules += "/Modules/";
|
cmakeModules += "/Modules/";
|
||||||
cmakeModules += this->SingleModuleName;
|
cmakeModules += this->CurrentArgument;
|
||||||
cmakeModules += ".cmake";
|
cmakeModules += ".cmake";
|
||||||
if(cmSystemTools::FileExists(cmakeModules.c_str())
|
if(cmSystemTools::FileExists(cmakeModules.c_str())
|
||||||
&& this->CreateSingleModule(cmakeModules.c_str(),
|
&& this->CreateSingleModule(cmakeModules.c_str(),
|
||||||
this->SingleModuleName.c_str()))
|
this->CurrentArgument.c_str()))
|
||||||
{
|
{
|
||||||
this->PrintDocumentationCommand(os, this->ModulesSection.GetEntries());
|
this->PrintDocumentationCommand(os, this->ModulesSection.GetEntries());
|
||||||
os << "\n Defined in: ";
|
os << "\n Defined in: ";
|
||||||
@ -1259,7 +1266,7 @@ bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Argument was not a module. Complain.
|
// Argument was not a module. Complain.
|
||||||
os << "Argument \"" << this->SingleModuleName.c_str()
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
||||||
<< "\" to --help-module is not a CMake module.";
|
<< "\" to --help-module is not a CMake module.";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1272,22 +1279,22 @@ bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os)
|
|||||||
os << "Internal error: properties list is empty." << std::endl;
|
os << "Internal error: properties list is empty." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(this->SinglePropertyName.length() == 0)
|
if(this->CurrentArgument.length() == 0)
|
||||||
{
|
{
|
||||||
os << "Argument --help-property needs a property name.\n";
|
os << "Argument --help-property needs a property name.\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(cmDocumentationEntry* entry = this->PropertiesSection.GetEntries();
|
for(const cmDocumentationEntry* entry = this->PropertiesSection.GetEntries();
|
||||||
entry->brief; ++entry)
|
entry->brief; ++entry)
|
||||||
{
|
{
|
||||||
if(entry->name && this->SinglePropertyName == entry->name)
|
if(entry->name && this->CurrentArgument == entry->name)
|
||||||
{
|
{
|
||||||
this->PrintDocumentationCommand(os, entry);
|
this->PrintDocumentationCommand(os, entry);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Argument was not a command. Complain.
|
// Argument was not a command. Complain.
|
||||||
os << "Argument \"" << this->SinglePropertyName.c_str()
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
||||||
<< "\" to --help-property is not a CMake property. "
|
<< "\" to --help-property is not a CMake property. "
|
||||||
<< "Use --help-property-list to see all properties.\n";
|
<< "Use --help-property-list to see all properties.\n";
|
||||||
return false;
|
return false;
|
||||||
@ -1301,7 +1308,7 @@ bool cmDocumentation::PrintDocumentationList(std::ostream& os)
|
|||||||
os << "Internal error: commands list is empty." << std::endl;
|
os << "Internal error: commands list is empty." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(cmDocumentationEntry* entry = this->CommandsSection.GetEntries();
|
for(const cmDocumentationEntry* entry = this->CommandsSection.GetEntries();
|
||||||
entry->brief; ++entry)
|
entry->brief; ++entry)
|
||||||
{
|
{
|
||||||
if(entry->name)
|
if(entry->name)
|
||||||
@ -1309,6 +1316,17 @@ bool cmDocumentation::PrintDocumentationList(std::ostream& os)
|
|||||||
os << entry->name << std::endl;
|
os << entry->name << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
os << "\nCompatibility commands:" << std::endl;
|
||||||
|
for(const cmDocumentationEntry*
|
||||||
|
entry = this->CompatCommandsSection.GetEntries();
|
||||||
|
entry->brief;
|
||||||
|
++entry)
|
||||||
|
{
|
||||||
|
if(entry->name)
|
||||||
|
{
|
||||||
|
os << entry->name << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1320,7 +1338,7 @@ bool cmDocumentation::PrintPropertyList(std::ostream& os)
|
|||||||
os << "Internal error: properties list is empty." << std::endl;
|
os << "Internal error: properties list is empty." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(cmDocumentationEntry* entry = this->PropertiesSection.GetEntries();
|
for(const cmDocumentationEntry* entry = this->PropertiesSection.GetEntries();
|
||||||
entry->brief; ++entry)
|
entry->brief; ++entry)
|
||||||
{
|
{
|
||||||
if(entry->name)
|
if(entry->name)
|
||||||
@ -1340,7 +1358,7 @@ bool cmDocumentation::PrintModuleList(std::ostream& os)
|
|||||||
os << "Internal error: modules list is empty." << std::endl;
|
os << "Internal error: modules list is empty." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(cmDocumentationEntry* entry = this->ModulesSection.GetEntries();
|
for(const cmDocumentationEntry* entry = this->ModulesSection.GetEntries();
|
||||||
entry->brief; ++entry)
|
entry->brief; ++entry)
|
||||||
{
|
{
|
||||||
if(entry->name)
|
if(entry->name)
|
||||||
@ -1407,7 +1425,7 @@ void cmDocumentation::PrintFooter(std::ostream& os)
|
|||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmDocumentation::PrintDocumentationCommand(std::ostream& os,
|
void cmDocumentation::PrintDocumentationCommand(std::ostream& os,
|
||||||
cmDocumentationEntry* entry)
|
const cmDocumentationEntry* entry)
|
||||||
{
|
{
|
||||||
cmDocumentationEntry singleCommandSection[3] =
|
cmDocumentationEntry singleCommandSection[3] =
|
||||||
{
|
{
|
||||||
@ -1461,39 +1479,51 @@ void cmDocumentation::CreateFullDocumentation()
|
|||||||
void cmDocumentation::CreateCurrentCommandDocumentation()
|
void cmDocumentation::CreateCurrentCommandDocumentation()
|
||||||
{
|
{
|
||||||
this->ClearSections();
|
this->ClearSections();
|
||||||
this->AddSection(this->DescriptionSection.GetName(CurrentForm), cmCompatCommandsDocumentationDescription);
|
this->AddSection(this->DescriptionSection.GetName(CurrentForm),
|
||||||
|
cmCompatCommandsDocumentationDescription);
|
||||||
this->AddSection(this->CompatCommandsSection);
|
this->AddSection(this->CompatCommandsSection);
|
||||||
this->AddSection(this->CopyrightSection.GetName(CurrentForm), cmDocumentationCopyright);
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
||||||
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm), cmDocumentationStandardSeeAlso);
|
cmDocumentationCopyright);
|
||||||
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
||||||
|
cmDocumentationStandardSeeAlso);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmDocumentation::CreateCompatCommandDocumentation()
|
void cmDocumentation::CreateCompatCommandDocumentation()
|
||||||
{
|
{
|
||||||
this->ClearSections();
|
this->ClearSections();
|
||||||
this->AddSection(this->DescriptionSection.GetName(CurrentForm), cmCompatCommandsDocumentationDescription);
|
this->AddSection(this->DescriptionSection.GetName(CurrentForm),
|
||||||
|
cmCompatCommandsDocumentationDescription);
|
||||||
this->AddSection(this->CompatCommandsSection);
|
this->AddSection(this->CompatCommandsSection);
|
||||||
this->AddSection(this->CopyrightSection.GetName(CurrentForm), cmDocumentationCopyright);
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
||||||
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm), cmDocumentationStandardSeeAlso);
|
cmDocumentationCopyright);
|
||||||
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
||||||
|
cmDocumentationStandardSeeAlso);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmDocumentation::CreateModulesDocumentation()
|
void cmDocumentation::CreateModulesDocumentation()
|
||||||
{
|
{
|
||||||
this->ClearSections();
|
this->ClearSections();
|
||||||
this->AddSection(this->DescriptionSection.GetName(CurrentForm), cmModulesDocumentationDescription);
|
this->AddSection(this->DescriptionSection.GetName(CurrentForm),
|
||||||
|
cmModulesDocumentationDescription);
|
||||||
this->AddSection(this->ModulesSection);
|
this->AddSection(this->ModulesSection);
|
||||||
this->AddSection(this->CopyrightSection.GetName(CurrentForm), cmDocumentationCopyright);
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
||||||
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm), cmDocumentationStandardSeeAlso);
|
cmDocumentationCopyright);
|
||||||
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
||||||
|
cmDocumentationStandardSeeAlso);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmDocumentation::CreatePropertiesDocumentation()
|
void cmDocumentation::CreatePropertiesDocumentation()
|
||||||
{
|
{
|
||||||
this->ClearSections();
|
this->ClearSections();
|
||||||
this->AddSection(this->DescriptionSection.GetName(CurrentForm), cmPropertiesDocumentationDescription);
|
this->AddSection(this->DescriptionSection.GetName(CurrentForm),
|
||||||
|
cmPropertiesDocumentationDescription);
|
||||||
this->AddSection(this->PropertiesSection);
|
this->AddSection(this->PropertiesSection);
|
||||||
this->AddSection(this->CopyrightSection.GetName(CurrentForm), cmDocumentationCopyright);
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
||||||
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm), cmDocumentationStandardSeeAlso);
|
cmDocumentationCopyright);
|
||||||
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
||||||
|
cmDocumentationStandardSeeAlso);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
/** Types of help provided. */
|
/** Types of help provided. */
|
||||||
enum Type { None, Usage, Single, SingleModule, SingleProperty,
|
enum Type { None, Usage, Single, SingleModule, SingleProperty,
|
||||||
List, ModuleList, PropertyList,
|
List, ModuleList, PropertyList,
|
||||||
Full, HTML, Man, Copyright, Version };
|
Full, Copyright, Version };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check command line arguments for documentation options. Returns
|
* Check command line arguments for documentation options. Returns
|
||||||
@ -112,13 +112,9 @@ public:
|
|||||||
const char* GetName(Form form) const
|
const char* GetName(Form form) const
|
||||||
{ return (form==ManForm?this->ManName.c_str():this->Name.c_str()); }
|
{ return (form==ManForm?this->ManName.c_str():this->Name.c_str()); }
|
||||||
|
|
||||||
/** Return a pointer to the first entry of this section. */
|
|
||||||
cmDocumentationEntry *GetEntries()
|
|
||||||
{ return &this->Entries[0]; }
|
|
||||||
|
|
||||||
/** Return a pointer to the first entry of this section. */
|
/** Return a pointer to the first entry of this section. */
|
||||||
const cmDocumentationEntry *GetEntries() const
|
const cmDocumentationEntry *GetEntries() const
|
||||||
{ return &this->Entries[0]; }
|
{ return this->Entries.empty()?&this->EmptySection:&this->Entries[0];}
|
||||||
|
|
||||||
/** Append an entry to this section. */
|
/** Append an entry to this section. */
|
||||||
void Append(const cmDocumentationEntry& entry)
|
void Append(const cmDocumentationEntry& entry)
|
||||||
@ -133,6 +129,8 @@ public:
|
|||||||
std::string Name;
|
std::string Name;
|
||||||
std::string ManName;
|
std::string ManName;
|
||||||
std::vector<cmDocumentationEntry> Entries;
|
std::vector<cmDocumentationEntry> Entries;
|
||||||
|
static const cmDocumentationEntry EmptySection;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -162,6 +160,9 @@ public:
|
|||||||
|
|
||||||
/** Set cmake root so we can find installed files */
|
/** Set cmake root so we can find installed files */
|
||||||
void SetCMakeRoot(const char* root) { this->CMakeRoot = root;}
|
void SetCMakeRoot(const char* root) { this->CMakeRoot = root;}
|
||||||
|
|
||||||
|
static Form GetFormFromFilename(const std::string& filename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrintHeader(const char* title, std::ostream& os);
|
void PrintHeader(const char* title, std::ostream& os);
|
||||||
void PrintFooter(std::ostream& os);
|
void PrintFooter(std::ostream& os);
|
||||||
@ -205,7 +206,7 @@ private:
|
|||||||
bool PrintDocumentationUsage(std::ostream& os);
|
bool PrintDocumentationUsage(std::ostream& os);
|
||||||
bool PrintDocumentationFull(std::ostream& os);
|
bool PrintDocumentationFull(std::ostream& os);
|
||||||
void PrintDocumentationCommand(std::ostream& os,
|
void PrintDocumentationCommand(std::ostream& os,
|
||||||
cmDocumentationEntry* entry);
|
const cmDocumentationEntry* entry);
|
||||||
|
|
||||||
void CreateUsageDocumentation();
|
void CreateUsageDocumentation();
|
||||||
void CreateFullDocumentation();
|
void CreateFullDocumentation();
|
||||||
@ -236,19 +237,25 @@ private:
|
|||||||
cmSection AuthorSection;
|
cmSection AuthorSection;
|
||||||
|
|
||||||
std::string SeeAlsoString;
|
std::string SeeAlsoString;
|
||||||
std::string SingleCommand;
|
|
||||||
std::string SingleModuleName;
|
|
||||||
std::string SinglePropertyName;
|
|
||||||
std::string CMakeRoot;
|
std::string CMakeRoot;
|
||||||
std::vector< char* > ModuleStrings;
|
std::vector< char* > ModuleStrings;
|
||||||
std::vector< const char* > Names;
|
std::vector< const char* > Names;
|
||||||
std::vector< const cmDocumentationEntry* > Sections;
|
std::vector< const cmDocumentationEntry* > Sections;
|
||||||
Form CurrentForm;
|
Form CurrentForm;
|
||||||
|
std::string CurrentArgument;
|
||||||
const char* TextIndent;
|
const char* TextIndent;
|
||||||
int TextWidth;
|
int TextWidth;
|
||||||
|
|
||||||
typedef std::map<Type, cmStdString> RequestedMapType;
|
struct RequestedHelpItem
|
||||||
RequestedMapType RequestedMap;
|
{
|
||||||
|
RequestedHelpItem():Form(TextForm), Type(None) {}
|
||||||
|
cmDocumentation::Form Form;
|
||||||
|
cmDocumentation::Type Type;
|
||||||
|
std::string Filename;
|
||||||
|
std::string Argument;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<RequestedHelpItem> RequestedHelpItems;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -96,8 +96,6 @@ int DumpForCoverageToStream(std::ostream& out)
|
|||||||
doc.SetGeneratorsSection(&generators[0]);
|
doc.SetGeneratorsSection(&generators[0]);
|
||||||
doc.PrintDocumentation(cmDocumentation::Usage, out);
|
doc.PrintDocumentation(cmDocumentation::Usage, out);
|
||||||
doc.PrintDocumentation(cmDocumentation::Full, out);
|
doc.PrintDocumentation(cmDocumentation::Full, out);
|
||||||
doc.PrintDocumentation(cmDocumentation::HTML, out);
|
|
||||||
doc.PrintDocumentation(cmDocumentation::Man, out);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,9 +170,11 @@ int do_cmake(int ac, char** av)
|
|||||||
hcm.AddCMakePaths(av[0]);
|
hcm.AddCMakePaths(av[0]);
|
||||||
doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
|
doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
|
||||||
std::vector<cmDocumentationEntry> commands;
|
std::vector<cmDocumentationEntry> commands;
|
||||||
|
std::vector<cmDocumentationEntry> compatCommands;
|
||||||
std::vector<cmDocumentationEntry> properties;
|
std::vector<cmDocumentationEntry> properties;
|
||||||
std::vector<cmDocumentationEntry> generators;
|
std::vector<cmDocumentationEntry> generators;
|
||||||
hcm.GetCommandDocumentation(commands);
|
hcm.GetCommandDocumentation(commands, true, false);
|
||||||
|
hcm.GetCommandDocumentation(compatCommands, false, true);
|
||||||
hcm.GetPropertiesDocumentation(properties);
|
hcm.GetPropertiesDocumentation(properties);
|
||||||
hcm.GetGeneratorDocumentation(generators);
|
hcm.GetGeneratorDocumentation(generators);
|
||||||
doc.SetName("cmake");
|
doc.SetName("cmake");
|
||||||
@ -182,6 +184,7 @@ int do_cmake(int ac, char** av)
|
|||||||
doc.SetGeneratorsSection(&generators[0]);
|
doc.SetGeneratorsSection(&generators[0]);
|
||||||
doc.SetOptionsSection(cmDocumentationOptions);
|
doc.SetOptionsSection(cmDocumentationOptions);
|
||||||
doc.SetCommandsSection(&commands[0]);
|
doc.SetCommandsSection(&commands[0]);
|
||||||
|
doc.SetCompatCommandsSection(&compatCommands[0]);
|
||||||
doc.SetPropertiesSection(&properties[0]);
|
doc.SetPropertiesSection(&properties[0]);
|
||||||
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
doc.SetSeeAlsoList(cmDocumentationSeeAlso);
|
||||||
int result = doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
int result = doc.PrintRequestedDocumentation(std::cout)? 0:1;
|
||||||
|
@ -14,8 +14,8 @@ MACRO(ADD_DOCS target dependency)
|
|||||||
OUTPUT ${CMake_BINARY_DIR}/Docs/${target}.txt
|
OUTPUT ${CMake_BINARY_DIR}/Docs/${target}.txt
|
||||||
COMMAND ${CMD}
|
COMMAND ${CMD}
|
||||||
ARGS --help-full ${CMake_BINARY_DIR}/Docs/${target}.txt
|
ARGS --help-full ${CMake_BINARY_DIR}/Docs/${target}.txt
|
||||||
--help-html ${CMake_BINARY_DIR}/Docs/${target}.html
|
--help-full ${CMake_BINARY_DIR}/Docs/${target}.html
|
||||||
--help-man ${CMake_BINARY_DIR}/Docs/${target}.1
|
--help-full ${CMake_BINARY_DIR}/Docs/${target}.1
|
||||||
DEPENDS ${target}
|
DEPENDS ${target}
|
||||||
MAIN_DEPENDENCY ${dependency}
|
MAIN_DEPENDENCY ${dependency}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user