Drop all documentation formatters except Usage
We now need only the Usage formatter to support command-line options that print basic usage, and the supporting indented=>preformatted markup processor to support CMake message formatting. Drop all other documentation formatters and move the remaining code up into the top cmDocumentationFormatter class.
This commit is contained in:
parent
b336a1ebe4
commit
80a3273b5e
|
@ -159,12 +159,6 @@ set(SRCS
|
||||||
cmDependsJavaParserHelper.h
|
cmDependsJavaParserHelper.h
|
||||||
cmDocumentation.cxx
|
cmDocumentation.cxx
|
||||||
cmDocumentationFormatter.cxx
|
cmDocumentationFormatter.cxx
|
||||||
cmDocumentationFormatterHTML.cxx
|
|
||||||
cmDocumentationFormatterDocbook.cxx
|
|
||||||
cmDocumentationFormatterMan.cxx
|
|
||||||
cmDocumentationFormatterRST.cxx
|
|
||||||
cmDocumentationFormatterText.cxx
|
|
||||||
cmDocumentationFormatterUsage.cxx
|
|
||||||
cmDocumentationSection.cxx
|
cmDocumentationSection.cxx
|
||||||
cmDocumentCompileDefinitions.h
|
cmDocumentCompileDefinitions.h
|
||||||
cmDocumentGeneratorExpressions.h
|
cmDocumentGeneratorExpressions.h
|
||||||
|
|
|
@ -56,9 +56,7 @@ static const char *cmDocumentationGeneratorsHeader[][3] =
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
cmDocumentation::cmDocumentation()
|
cmDocumentation::cmDocumentation()
|
||||||
:CurrentFormatter(0)
|
|
||||||
{
|
{
|
||||||
this->SetForm(TextForm, 0);
|
|
||||||
this->addCommonStandardDocSections();
|
this->addCommonStandardDocSections();
|
||||||
this->ShowGenerators = true;
|
this->ShowGenerators = true;
|
||||||
}
|
}
|
||||||
|
@ -82,22 +80,6 @@ bool cmDocumentation::PrintVersion(std::ostream& os)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentation::AddSectionToPrint(const char *section)
|
|
||||||
{
|
|
||||||
if (this->AllSections.find(section) != this->AllSections.end())
|
|
||||||
{
|
|
||||||
this->PrintSections.push_back(this->AllSections[section]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentation::ClearSections()
|
|
||||||
{
|
|
||||||
this->PrintSections.erase(this->PrintSections.begin(),
|
|
||||||
this->PrintSections.end());
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
|
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
|
||||||
{
|
{
|
||||||
|
@ -147,7 +129,6 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
||||||
i != this->RequestedHelpItems.end();
|
i != this->RequestedHelpItems.end();
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
this->SetForm(i->HelpForm, i->ManSection);
|
|
||||||
this->CurrentArgument = i->Argument;
|
this->CurrentArgument = i->Argument;
|
||||||
// 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.
|
||||||
|
@ -193,38 +174,27 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
cmDocumentation::Form cmDocumentation::GetFormFromFilename(
|
void cmDocumentation::WarnFormFromFilename(
|
||||||
const std::string& filename,
|
cmDocumentation::RequestedHelpItem& request)
|
||||||
int* manSection)
|
|
||||||
{
|
{
|
||||||
std::string ext = cmSystemTools::GetFilenameLastExtension(filename);
|
std::string ext = cmSystemTools::GetFilenameLastExtension(request.Filename);
|
||||||
ext = cmSystemTools::UpperCase(ext);
|
ext = cmSystemTools::UpperCase(ext);
|
||||||
if ((ext == ".HTM") || (ext == ".HTML"))
|
if ((ext == ".HTM") || (ext == ".HTML"))
|
||||||
{
|
{
|
||||||
return cmDocumentation::HTMLForm;
|
request.HelpType = cmDocumentation::None;
|
||||||
|
cmSystemTools::Message("Warning: HTML help format no longer supported");
|
||||||
}
|
}
|
||||||
|
else if (ext == ".DOCBOOK")
|
||||||
if (ext == ".DOCBOOK")
|
|
||||||
{
|
{
|
||||||
return cmDocumentation::DocbookForm;
|
request.HelpType = cmDocumentation::None;
|
||||||
|
cmSystemTools::Message("Warning: Docbook help format no longer supported");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ".1" to ".9" should be manpages
|
// ".1" to ".9" should be manpages
|
||||||
if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
|
else if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
|
||||||
{
|
{
|
||||||
if (manSection)
|
request.HelpType = cmDocumentation::None;
|
||||||
{
|
cmSystemTools::Message("Warning: Man help format no longer supported");
|
||||||
*manSection = ext[1] - '0';
|
|
||||||
}
|
}
|
||||||
return cmDocumentation::ManForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ext == ".RST")
|
|
||||||
{
|
|
||||||
return cmDocumentation::RSTForm;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cmDocumentation::TextForm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -274,7 +244,6 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
{
|
{
|
||||||
RequestedHelpItem help;
|
RequestedHelpItem help;
|
||||||
help.HelpType = cmDocumentation::Usage;
|
help.HelpType = cmDocumentation::Usage;
|
||||||
help.HelpForm = cmDocumentation::UsageForm;
|
|
||||||
this->RequestedHelpItems.push_back(help);
|
this->RequestedHelpItems.push_back(help);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -298,7 +267,6 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
(strcmp(argv[i], "-H") == 0))
|
(strcmp(argv[i], "-H") == 0))
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Usage;
|
help.HelpType = cmDocumentation::Usage;
|
||||||
help.HelpForm = cmDocumentation::UsageForm;
|
|
||||||
GET_OPT_ARGUMENT(help.Argument);
|
GET_OPT_ARGUMENT(help.Argument);
|
||||||
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
||||||
// special case for single command
|
// special case for single command
|
||||||
|
@ -312,32 +280,28 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
help.HelpType = cmDocumentation::OneManual;
|
help.HelpType = cmDocumentation::OneManual;
|
||||||
help.Argument = "cmake-properties.7";
|
help.Argument = "cmake-properties.7";
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-policies") == 0)
|
else if(strcmp(argv[i], "--help-policies") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::OneManual;
|
help.HelpType = cmDocumentation::OneManual;
|
||||||
help.Argument = "cmake-policies.7";
|
help.Argument = "cmake-policies.7";
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-variables") == 0)
|
else if(strcmp(argv[i], "--help-variables") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::OneManual;
|
help.HelpType = cmDocumentation::OneManual;
|
||||||
help.Argument = "cmake-variables.7";
|
help.Argument = "cmake-variables.7";
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-modules") == 0)
|
else if(strcmp(argv[i], "--help-modules") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::OneManual;
|
help.HelpType = cmDocumentation::OneManual;
|
||||||
help.Argument = "cmake-modules.7";
|
help.Argument = "cmake-modules.7";
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-custom-modules") == 0)
|
else if(strcmp(argv[i], "--help-custom-modules") == 0)
|
||||||
{
|
{
|
||||||
|
@ -351,8 +315,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
help.HelpType = cmDocumentation::OneManual;
|
help.HelpType = cmDocumentation::OneManual;
|
||||||
help.Argument = "cmake-commands.7";
|
help.Argument = "cmake-commands.7";
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-compatcommands") == 0)
|
else if(strcmp(argv[i], "--help-compatcommands") == 0)
|
||||||
{
|
{
|
||||||
|
@ -385,40 +348,35 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
GET_OPT_ARGUMENT(help.Argument);
|
GET_OPT_ARGUMENT(help.Argument);
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-module") == 0)
|
else if(strcmp(argv[i], "--help-module") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::OneModule;
|
help.HelpType = cmDocumentation::OneModule;
|
||||||
GET_OPT_ARGUMENT(help.Argument);
|
GET_OPT_ARGUMENT(help.Argument);
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-property") == 0)
|
else if(strcmp(argv[i], "--help-property") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::OneProperty;
|
help.HelpType = cmDocumentation::OneProperty;
|
||||||
GET_OPT_ARGUMENT(help.Argument);
|
GET_OPT_ARGUMENT(help.Argument);
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-policy") == 0)
|
else if(strcmp(argv[i], "--help-policy") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::OnePolicy;
|
help.HelpType = cmDocumentation::OnePolicy;
|
||||||
GET_OPT_ARGUMENT(help.Argument);
|
GET_OPT_ARGUMENT(help.Argument);
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-variable") == 0)
|
else if(strcmp(argv[i], "--help-variable") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::OneVariable;
|
help.HelpType = cmDocumentation::OneVariable;
|
||||||
GET_OPT_ARGUMENT(help.Argument);
|
GET_OPT_ARGUMENT(help.Argument);
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
this->WarnFormFromFilename(help);
|
||||||
&help.ManSection);
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-manual") == 0)
|
else if(strcmp(argv[i], "--help-manual") == 0)
|
||||||
{
|
{
|
||||||
|
@ -431,31 +389,26 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::ListCommands;
|
help.HelpType = cmDocumentation::ListCommands;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = cmDocumentation::TextForm;
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-module-list") == 0)
|
else if(strcmp(argv[i], "--help-module-list") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::ListModules;
|
help.HelpType = cmDocumentation::ListModules;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = cmDocumentation::TextForm;
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-property-list") == 0)
|
else if(strcmp(argv[i], "--help-property-list") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::ListProperties;
|
help.HelpType = cmDocumentation::ListProperties;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = cmDocumentation::TextForm;
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-variable-list") == 0)
|
else if(strcmp(argv[i], "--help-variable-list") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::ListVariables;
|
help.HelpType = cmDocumentation::ListVariables;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = cmDocumentation::TextForm;
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-policy-list") == 0)
|
else if(strcmp(argv[i], "--help-policy-list") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::ListPolicies;
|
help.HelpType = cmDocumentation::ListPolicies;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = cmDocumentation::TextForm;
|
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-manual-list") == 0)
|
else if(strcmp(argv[i], "--help-manual-list") == 0)
|
||||||
{
|
{
|
||||||
|
@ -474,7 +427,6 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Version;
|
help.HelpType = cmDocumentation::Version;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = cmDocumentation::UsageForm;
|
|
||||||
}
|
}
|
||||||
if(help.HelpType != None)
|
if(help.HelpType != None)
|
||||||
{
|
{
|
||||||
|
@ -486,28 +438,6 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentation::Print(Form f, int manSection, std::ostream& os)
|
|
||||||
{
|
|
||||||
this->SetForm(f, manSection);
|
|
||||||
this->Print(os);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentation::Print(std::ostream& os)
|
|
||||||
{
|
|
||||||
// if the formatter supports it, print a master index for
|
|
||||||
// all sections
|
|
||||||
this->CurrentFormatter->PrintIndex(os, this->PrintSections);
|
|
||||||
for(unsigned int i=0; i < this->PrintSections.size(); ++i)
|
|
||||||
{
|
|
||||||
std::string name = this->PrintSections[i]->
|
|
||||||
GetName((this->CurrentFormatter->GetForm()));
|
|
||||||
this->CurrentFormatter->PrintSection(os,*this->PrintSections[i],
|
|
||||||
name.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmDocumentation::SetName(const char* name)
|
void cmDocumentation::SetName(const char* name)
|
||||||
{
|
{
|
||||||
|
@ -864,45 +794,28 @@ bool cmDocumentation::PrintHelpListVariables(std::ostream& os)
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmDocumentation::PrintDocumentationUsage(std::ostream& os)
|
bool cmDocumentation::PrintDocumentationUsage(std::ostream& os)
|
||||||
{
|
{
|
||||||
this->ClearSections();
|
std::map<std::string,cmDocumentationSection*>::iterator si;
|
||||||
this->AddSectionToPrint("Usage");
|
si = this->AllSections.find("Usage");
|
||||||
this->AddSectionToPrint("Options");
|
if(si != this->AllSections.end())
|
||||||
|
{
|
||||||
|
this->Formatter.PrintSection(os, *si->second);
|
||||||
|
}
|
||||||
|
si = this->AllSections.find("Options");
|
||||||
|
if(si != this->AllSections.end())
|
||||||
|
{
|
||||||
|
this->Formatter.PrintSection(os, *si->second);
|
||||||
|
}
|
||||||
if(this->ShowGenerators)
|
if(this->ShowGenerators)
|
||||||
{
|
{
|
||||||
this->AddSectionToPrint("Generators");
|
si = this->AllSections.find("Generators");
|
||||||
|
if(si != this->AllSections.end())
|
||||||
|
{
|
||||||
|
this->Formatter.PrintSection(os, *si->second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->Print(os);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentation::SetForm(Form f, int manSection)
|
|
||||||
{
|
|
||||||
switch(f)
|
|
||||||
{
|
|
||||||
case HTMLForm:
|
|
||||||
this->CurrentFormatter = &this->HTMLFormatter;
|
|
||||||
break;
|
|
||||||
case DocbookForm:
|
|
||||||
this->CurrentFormatter = &this->DocbookFormatter;
|
|
||||||
break;
|
|
||||||
case ManForm:
|
|
||||||
this->ManFormatter.SetManSection(manSection);
|
|
||||||
this->CurrentFormatter = &this->ManFormatter;
|
|
||||||
break;
|
|
||||||
case RSTForm:
|
|
||||||
this->CurrentFormatter = &this->RSTFormatter;
|
|
||||||
break;
|
|
||||||
case TextForm:
|
|
||||||
this->CurrentFormatter = &this->TextFormatter;
|
|
||||||
break;
|
|
||||||
case UsageForm:
|
|
||||||
this->CurrentFormatter = & this->UsageFormatter;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmDocumentation::GetNameString() const
|
const char* cmDocumentation::GetNameString() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,12 +15,6 @@
|
||||||
#include "cmStandardIncludes.h"
|
#include "cmStandardIncludes.h"
|
||||||
#include "cmProperty.h"
|
#include "cmProperty.h"
|
||||||
#include "cmDocumentationFormatter.h"
|
#include "cmDocumentationFormatter.h"
|
||||||
#include "cmDocumentationFormatterHTML.h"
|
|
||||||
#include "cmDocumentationFormatterDocbook.h"
|
|
||||||
#include "cmDocumentationFormatterMan.h"
|
|
||||||
#include "cmDocumentationFormatterRST.h"
|
|
||||||
#include "cmDocumentationFormatterText.h"
|
|
||||||
#include "cmDocumentationFormatterUsage.h"
|
|
||||||
#include "cmDocumentationSection.h"
|
#include "cmDocumentationSection.h"
|
||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
|
||||||
|
@ -89,33 +83,9 @@ public:
|
||||||
void AppendSection(const char *sectionName,
|
void AppendSection(const char *sectionName,
|
||||||
cmDocumentationEntry &docs);
|
cmDocumentationEntry &docs);
|
||||||
|
|
||||||
/**
|
|
||||||
* Print documentation in the given form. All previously added
|
|
||||||
* sections will be generated.
|
|
||||||
*/
|
|
||||||
void Print(Form f, int manSection, std::ostream& os);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print documentation in the current form. All previously added
|
|
||||||
* sections will be generated.
|
|
||||||
*/
|
|
||||||
void Print(std::ostream& os);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a section of documentation. This can be used to generate custom help
|
|
||||||
* documents.
|
|
||||||
*/
|
|
||||||
void AddSectionToPrint(const char *section);
|
|
||||||
|
|
||||||
/** Clear all previously added sections of help. */
|
|
||||||
void ClearSections();
|
|
||||||
|
|
||||||
/** 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,
|
|
||||||
int* ManSection);
|
|
||||||
|
|
||||||
/** Add common (to all tools) documentation section(s) */
|
/** Add common (to all tools) documentation section(s) */
|
||||||
void addCommonStandardDocSections();
|
void addCommonStandardDocSections();
|
||||||
|
|
||||||
|
@ -129,7 +99,6 @@ public:
|
||||||
void addCPackStandardDocSections();
|
void addCPackStandardDocSections();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetForm(Form f, int manSection);
|
|
||||||
|
|
||||||
void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
|
void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
|
||||||
void PrintNames(std::ostream& os, std::string const& pattern);
|
void PrintNames(std::ostream& os, std::string const& pattern);
|
||||||
|
@ -159,27 +128,20 @@ private:
|
||||||
std::map<std::string,cmDocumentationSection*> AllSections;
|
std::map<std::string,cmDocumentationSection*> AllSections;
|
||||||
|
|
||||||
std::string CMakeRoot;
|
std::string CMakeRoot;
|
||||||
std::vector<const cmDocumentationSection *> PrintSections;
|
|
||||||
std::string CurrentArgument;
|
std::string CurrentArgument;
|
||||||
|
|
||||||
struct RequestedHelpItem
|
struct RequestedHelpItem
|
||||||
{
|
{
|
||||||
RequestedHelpItem():HelpForm(TextForm), HelpType(None), ManSection(1) {}
|
RequestedHelpItem(): HelpType(None) {}
|
||||||
cmDocumentationEnums::Form HelpForm;
|
|
||||||
cmDocumentationEnums::Type HelpType;
|
cmDocumentationEnums::Type HelpType;
|
||||||
std::string Filename;
|
std::string Filename;
|
||||||
std::string Argument;
|
std::string Argument;
|
||||||
int ManSection;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<RequestedHelpItem> RequestedHelpItems;
|
std::vector<RequestedHelpItem> RequestedHelpItems;
|
||||||
cmDocumentationFormatter* CurrentFormatter;
|
cmDocumentationFormatter Formatter;
|
||||||
cmDocumentationFormatterHTML HTMLFormatter;
|
|
||||||
cmDocumentationFormatterDocbook DocbookFormatter;
|
static void WarnFormFromFilename(RequestedHelpItem& request);
|
||||||
cmDocumentationFormatterMan ManFormatter;
|
|
||||||
cmDocumentationFormatterRST RSTFormatter;
|
|
||||||
cmDocumentationFormatterText TextFormatter;
|
|
||||||
cmDocumentationFormatterUsage UsageFormatter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -11,7 +11,10 @@
|
||||||
============================================================================*/
|
============================================================================*/
|
||||||
#include "cmDocumentationFormatter.h"
|
#include "cmDocumentationFormatter.h"
|
||||||
|
|
||||||
cmDocumentationFormatter::cmDocumentationFormatter()
|
#include "cmDocumentationSection.h"
|
||||||
|
|
||||||
|
cmDocumentationFormatter::cmDocumentationFormatter():
|
||||||
|
TextWidth(77), TextIndent("")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,115 +69,162 @@ void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
void cmDocumentationFormatter::PrintPreformatted(std::ostream& os,
|
||||||
std::string
|
const char* text)
|
||||||
cmDocumentationFormatter::ComputeSectionLinkPrefix(std::string const& name)
|
|
||||||
{
|
{
|
||||||
// Map from section name to a prefix for links pointing within the
|
bool newline = true;
|
||||||
// section. For example, the commands section should have HTML
|
for(const char* ptr = text; *ptr; ++ptr)
|
||||||
// links to each command with names like #command:ADD_EXECUTABLE.
|
|
||||||
if(name.find("Command") != name.npos)
|
|
||||||
{
|
{
|
||||||
return "command";
|
if(newline && *ptr != '\n')
|
||||||
|
{
|
||||||
|
os << this->TextIndent;
|
||||||
|
newline = false;
|
||||||
}
|
}
|
||||||
else if(name.find("Propert") != name.npos)
|
os << *ptr;
|
||||||
|
if(*ptr == '\n')
|
||||||
{
|
{
|
||||||
if(name.find("Global") != name.npos)
|
newline = true;
|
||||||
{
|
|
||||||
return "prop_gbl";
|
|
||||||
}
|
}
|
||||||
else if(name.find("Direct") != name.npos)
|
|
||||||
{
|
|
||||||
return "prop_dir";
|
|
||||||
}
|
}
|
||||||
else if(name.find("Target") != name.npos)
|
os << "\n";
|
||||||
{
|
|
||||||
return "prop_tgt";
|
|
||||||
}
|
}
|
||||||
else if(name.find("Test") != name.npos)
|
|
||||||
|
void cmDocumentationFormatter::PrintParagraph(std::ostream& os,
|
||||||
|
const char* text)
|
||||||
{
|
{
|
||||||
return "prop_test";
|
os << this->TextIndent;
|
||||||
|
this->PrintColumn(os, text);
|
||||||
|
os << "\n";
|
||||||
}
|
}
|
||||||
else if(name.find("Source") != name.npos)
|
|
||||||
|
void cmDocumentationFormatter::SetIndent(const char* indent)
|
||||||
{
|
{
|
||||||
return "prop_sf";
|
this->TextIndent = indent;
|
||||||
}
|
}
|
||||||
else if(name.find("Cache") != name.npos)
|
|
||||||
|
void cmDocumentationFormatter::PrintColumn(std::ostream& os,
|
||||||
|
const char* text)
|
||||||
{
|
{
|
||||||
return "prop_cache";
|
// Print text arranged in an indented column of fixed witdh.
|
||||||
}
|
const char* l = text;
|
||||||
return "property";
|
long column = 0;
|
||||||
}
|
bool newSentence = false;
|
||||||
else if(name.find("Variable") != name.npos)
|
bool firstLine = true;
|
||||||
|
int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent));
|
||||||
|
|
||||||
|
// Loop until the end of the text.
|
||||||
|
while(*l)
|
||||||
{
|
{
|
||||||
if(name.find("Information") != name.npos)
|
// Parse the next word.
|
||||||
|
const char* r = l;
|
||||||
|
while(*r && (*r != '\n') && (*r != ' ')) { ++r; }
|
||||||
|
|
||||||
|
// Does it fit on this line?
|
||||||
|
if(r-l < (width-column-(newSentence?1:0)))
|
||||||
{
|
{
|
||||||
return "var_info";
|
// Word fits on this line.
|
||||||
}
|
if(r > l)
|
||||||
else if(name.find("Behavior") != name.npos)
|
|
||||||
{
|
{
|
||||||
return "var_cmake";
|
if(column)
|
||||||
}
|
|
||||||
else if(name.find("Describe") != name.npos)
|
|
||||||
{
|
{
|
||||||
return "var_sys";
|
// Not first word on line. Separate from the previous word
|
||||||
}
|
// by a space, or two if this is a new sentence.
|
||||||
else if(name.find("Control") != name.npos)
|
if(newSentence)
|
||||||
{
|
{
|
||||||
return "var_build";
|
os << " ";
|
||||||
}
|
column += 2;
|
||||||
else if(name.find("Languages") != name.npos)
|
|
||||||
{
|
|
||||||
return "var_lang";
|
|
||||||
}
|
|
||||||
return "variable";
|
|
||||||
}
|
|
||||||
else if(name.find("Polic") != name.npos)
|
|
||||||
{
|
|
||||||
return "policy";
|
|
||||||
}
|
|
||||||
else if(name.find("Module") != name.npos)
|
|
||||||
{
|
|
||||||
return "module";
|
|
||||||
}
|
|
||||||
else if(name.find("Name") != name.npos ||
|
|
||||||
name.find("Introduction") != name.npos)
|
|
||||||
{
|
|
||||||
return "name";
|
|
||||||
}
|
|
||||||
else if(name.find("Usage") != name.npos)
|
|
||||||
{
|
|
||||||
return "usage";
|
|
||||||
}
|
|
||||||
else if(name.find("Description") != name.npos)
|
|
||||||
{
|
|
||||||
return "desc";
|
|
||||||
}
|
|
||||||
else if(name.find("Generators") != name.npos)
|
|
||||||
{
|
|
||||||
return "generator";
|
|
||||||
}
|
|
||||||
else if(name.find("Options") != name.npos)
|
|
||||||
{
|
|
||||||
return "opt";
|
|
||||||
}
|
|
||||||
else if(name.find("Copyright") != name.npos)
|
|
||||||
{
|
|
||||||
return "copy";
|
|
||||||
}
|
|
||||||
else if(name.find("See Also") != name.npos)
|
|
||||||
{
|
|
||||||
return "see";
|
|
||||||
}
|
|
||||||
else if(name.find("SingleItem") != name.npos)
|
|
||||||
{
|
|
||||||
return "single_item";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr
|
os << " ";
|
||||||
<< "WARNING: ComputeSectionLinkPrefix failed for \"" << name << "\""
|
column += 1;
|
||||||
<< std::endl;
|
|
||||||
return "other";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// First word on line. Print indentation unless this is the
|
||||||
|
// first line.
|
||||||
|
os << (firstLine?"":this->TextIndent);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print the word.
|
||||||
|
os.write(l, static_cast<long>(r-l));
|
||||||
|
newSentence = (*(r-1) == '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(*r == '\n')
|
||||||
|
{
|
||||||
|
// Text provided a newline. Start a new line.
|
||||||
|
os << "\n";
|
||||||
|
++r;
|
||||||
|
column = 0;
|
||||||
|
firstLine = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// No provided newline. Continue this line.
|
||||||
|
column += static_cast<long>(r-l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Word does not fit on this line. Start a new line.
|
||||||
|
os << "\n";
|
||||||
|
firstLine = false;
|
||||||
|
if(r > l)
|
||||||
|
{
|
||||||
|
os << this->TextIndent;
|
||||||
|
os.write(l, static_cast<long>(r-l));
|
||||||
|
column = static_cast<long>(r-l);
|
||||||
|
newSentence = (*(r-1) == '.');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
column = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move to beginning of next word. Skip over whitespace.
|
||||||
|
l = r;
|
||||||
|
while(*l && (*l == ' ')) { ++l; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cmDocumentationFormatter
|
||||||
|
::PrintSection(std::ostream& os,
|
||||||
|
cmDocumentationSection const& section)
|
||||||
|
{
|
||||||
|
os << section.GetName() << "\n";
|
||||||
|
|
||||||
|
const std::vector<cmDocumentationEntry> &entries =
|
||||||
|
section.GetEntries();
|
||||||
|
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
||||||
|
op != entries.end(); ++op)
|
||||||
|
{
|
||||||
|
if(op->Name.size())
|
||||||
|
{
|
||||||
|
os << " " << op->Name;
|
||||||
|
this->TextIndent = " ";
|
||||||
|
int align = static_cast<int>(strlen(this->TextIndent))-4;
|
||||||
|
for(int i = static_cast<int>(op->Name.size()); i < align; ++i)
|
||||||
|
{
|
||||||
|
os << " ";
|
||||||
|
}
|
||||||
|
if (op->Name.size() > strlen(this->TextIndent)-4 )
|
||||||
|
{
|
||||||
|
os << "\n";
|
||||||
|
os.write(this->TextIndent, strlen(this->TextIndent)-2);
|
||||||
|
}
|
||||||
|
os << "= ";
|
||||||
|
this->PrintColumn(os, op->Brief.c_str());
|
||||||
|
os << "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
os << "\n";
|
||||||
|
this->TextIndent = "";
|
||||||
|
this->PrintFormatted(os, op->Brief.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os << "\n";
|
||||||
|
}
|
||||||
|
|
|
@ -30,15 +30,11 @@ public:
|
||||||
ListCommands, ListModules, ListProperties, ListVariables, ListPolicies,
|
ListCommands, ListModules, ListProperties, ListVariables, ListPolicies,
|
||||||
OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy
|
OneManual, OneCommand, OneModule, OneProperty, OneVariable, OnePolicy
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Forms of documentation output. */
|
|
||||||
enum Form { TextForm, HTMLForm, RSTForm, ManForm, UsageForm, DocbookForm };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class cmDocumentationSection;
|
class cmDocumentationSection;
|
||||||
|
|
||||||
/** Base class for printing the documentation in the various supported
|
/** Print documentation in a simple text format. */
|
||||||
formats. */
|
|
||||||
class cmDocumentationFormatter
|
class cmDocumentationFormatter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -46,23 +42,15 @@ public:
|
||||||
virtual ~cmDocumentationFormatter();
|
virtual ~cmDocumentationFormatter();
|
||||||
void PrintFormatted(std::ostream& os, const char* text);
|
void PrintFormatted(std::ostream& os, const char* text);
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const = 0;
|
|
||||||
|
|
||||||
virtual void PrintHeader(const char* /*docname*/,
|
|
||||||
const char* /*appname*/,
|
|
||||||
std::ostream& /*os*/) {}
|
|
||||||
virtual void PrintFooter(std::ostream& /*os*/) {}
|
|
||||||
virtual void PrintSection(std::ostream& os,
|
virtual void PrintSection(std::ostream& os,
|
||||||
const cmDocumentationSection& section,
|
cmDocumentationSection const& section);
|
||||||
const char* name) = 0;
|
virtual void PrintPreformatted(std::ostream& os, const char* text);
|
||||||
virtual void PrintPreformatted(std::ostream& os, const char* text) = 0;
|
virtual void PrintParagraph(std::ostream& os, const char* text);
|
||||||
virtual void PrintParagraph(std::ostream& os, const char* text) = 0;
|
void PrintColumn(std::ostream& os, const char* text);
|
||||||
virtual void PrintIndex(std::ostream& ,
|
void SetIndent(const char* indent);
|
||||||
std::vector<const cmDocumentationSection *>&)
|
private:
|
||||||
{}
|
int TextWidth;
|
||||||
|
const char* TextIndent;
|
||||||
/** Compute a prefix for links into a section (#\<prefix\>_SOMETHING). */
|
|
||||||
std::string ComputeSectionLinkPrefix(std::string const& name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,254 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#include "cmDocumentationFormatterDocbook.h"
|
|
||||||
#include "cmDocumentationSection.h"
|
|
||||||
#include <algorithm>
|
|
||||||
#include <ctype.h> // for isalnum
|
|
||||||
|
|
||||||
static int cmIsAlnum(int c)
|
|
||||||
{
|
|
||||||
return isalnum(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// this function is a copy of the one in the HTML formatter
|
|
||||||
// the three functions below are slightly modified copies
|
|
||||||
static bool cmDocumentationIsHyperlinkCharDocbook(char c)
|
|
||||||
{
|
|
||||||
// This is not a complete list but works for CMake documentation.
|
|
||||||
return ((c >= 'A' && c <= 'Z') ||
|
|
||||||
(c >= 'a' && c <= 'z') ||
|
|
||||||
(c >= '0' && c <= '9') ||
|
|
||||||
c == '-' || c == '.' || c == '/' || c == '~' || c == '@' ||
|
|
||||||
c == ':' || c == '_' || c == '&' || c == '?' || c == '=');
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static void cmDocumentationPrintDocbookChar(std::ostream& os, char c)
|
|
||||||
{
|
|
||||||
// Use an escape sequence if necessary.
|
|
||||||
switch(c)
|
|
||||||
{
|
|
||||||
case '<':
|
|
||||||
os << "<";
|
|
||||||
break;
|
|
||||||
case '>':
|
|
||||||
os << ">";
|
|
||||||
break;
|
|
||||||
case '&':
|
|
||||||
os << "&";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
os << c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* cmDocumentationPrintDocbookLink(std::ostream& os,const char* begin)
|
|
||||||
{
|
|
||||||
// Look for the end of the link.
|
|
||||||
const char* end = begin;
|
|
||||||
while(cmDocumentationIsHyperlinkCharDocbook(*end))
|
|
||||||
{
|
|
||||||
++end;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print the hyperlink itself.
|
|
||||||
os << "<ulink url=\"";
|
|
||||||
for(const char* c = begin; c != end; ++c)
|
|
||||||
{
|
|
||||||
cmDocumentationPrintDocbookChar(os, *c);
|
|
||||||
}
|
|
||||||
os << "\" />";
|
|
||||||
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationPrintDocbookEscapes(std::ostream& os, const char* text)
|
|
||||||
{
|
|
||||||
// Hyperlink prefixes.
|
|
||||||
static const char* hyperlinks[] = {"http://", "ftp://", "mailto:", 0};
|
|
||||||
|
|
||||||
// Print each character.
|
|
||||||
for(const char* p = text; *p;)
|
|
||||||
{
|
|
||||||
// Handle hyperlinks specially to make them active.
|
|
||||||
bool found_hyperlink = false;
|
|
||||||
for(const char** h = hyperlinks; !found_hyperlink && *h; ++h)
|
|
||||||
{
|
|
||||||
if(strncmp(p, *h, strlen(*h)) == 0)
|
|
||||||
{
|
|
||||||
p = cmDocumentationPrintDocbookLink(os, p);
|
|
||||||
found_hyperlink = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print other characters normally.
|
|
||||||
if(!found_hyperlink)
|
|
||||||
{
|
|
||||||
cmDocumentationPrintDocbookChar(os, *p++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
cmDocumentationFormatterDocbook::cmDocumentationFormatterDocbook()
|
|
||||||
:cmDocumentationFormatter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterDocbook
|
|
||||||
::PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection §ion,
|
|
||||||
const char* name)
|
|
||||||
{
|
|
||||||
os << "<sect1 id=\"";
|
|
||||||
this->PrintId(os, 0, name);
|
|
||||||
os << "\">\n<title>" << name << "</title>\n";
|
|
||||||
|
|
||||||
std::string prefix = this->ComputeSectionLinkPrefix(name);
|
|
||||||
const std::vector<cmDocumentationEntry> &entries = section.GetEntries();
|
|
||||||
|
|
||||||
bool hasSubSections = false;
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
||||||
op != entries.end(); ++op)
|
|
||||||
{
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
hasSubSections = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool inAbstract = false;
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
||||||
op != entries.end(); ++op)
|
|
||||||
{
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
if(inAbstract)
|
|
||||||
{
|
|
||||||
os << "</abstract>\n";
|
|
||||||
inAbstract = false;
|
|
||||||
}
|
|
||||||
os << "<sect2 id=\"";
|
|
||||||
this->PrintId(os, prefix.c_str(), op->Name);
|
|
||||||
os << "\">\n<title>";
|
|
||||||
cmDocumentationPrintDocbookEscapes(os, op->Name.c_str());
|
|
||||||
os << "</title>\n";
|
|
||||||
if(op->Full.size())
|
|
||||||
{
|
|
||||||
os << "<abstract>\n<para>";
|
|
||||||
cmDocumentationPrintDocbookEscapes(os, op->Brief.c_str());
|
|
||||||
os << "</para>\n</abstract>\n";
|
|
||||||
this->PrintFormatted(os, op->Full.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
}
|
|
||||||
os << "</sect2>\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(hasSubSections && op == entries.begin())
|
|
||||||
{
|
|
||||||
os << "<abstract>\n";
|
|
||||||
inAbstract = true;
|
|
||||||
}
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// empty sections are not allowed in docbook.
|
|
||||||
if(entries.empty())
|
|
||||||
{
|
|
||||||
os << "<para/>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
os << "</sect1>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterDocbook
|
|
||||||
::PrintPreformatted(std::ostream& os, const char* text)
|
|
||||||
{
|
|
||||||
os << "<para>\n<programlisting>";
|
|
||||||
cmDocumentationPrintDocbookEscapes(os, text);
|
|
||||||
os << "</programlisting>\n</para>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterDocbook
|
|
||||||
::PrintParagraph(std::ostream& os, const char* text)
|
|
||||||
{
|
|
||||||
os << "<para>";
|
|
||||||
cmDocumentationPrintDocbookEscapes(os, text);
|
|
||||||
os << "</para>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterDocbook
|
|
||||||
::PrintHeader(const char* docname, const char* appname, std::ostream& os)
|
|
||||||
{
|
|
||||||
this->Docname = docname;
|
|
||||||
|
|
||||||
// this one is used to ensure that we don't create multiple link targets
|
|
||||||
// with the same name. We can clear it here since we are at the
|
|
||||||
// start of a document here.
|
|
||||||
this->EmittedLinkIds.clear();
|
|
||||||
|
|
||||||
os << "<?xml version=\"1.0\" ?>\n"
|
|
||||||
"<!DOCTYPE article PUBLIC \"-//OASIS//DTD DocBook V4.5//EN\" "
|
|
||||||
"\"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd\" [\n"
|
|
||||||
"<!ENTITY % addindex \"IGNORE\">\n"
|
|
||||||
"<!ENTITY % English \"INCLUDE\"> ]>\n"
|
|
||||||
"<article>\n"
|
|
||||||
"<articleinfo>\n"
|
|
||||||
"<title>" << docname << " - " << appname << "</title>\n"
|
|
||||||
"</articleinfo>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterDocbook::PrintFooter(std::ostream& os)
|
|
||||||
{
|
|
||||||
os << "</article>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterDocbook
|
|
||||||
::PrintId(std::ostream& os, const char* prefix, std::string id)
|
|
||||||
{
|
|
||||||
std::replace_if(id.begin(), id.end(),
|
|
||||||
std::not1(std::ptr_fun(cmIsAlnum)), '_');
|
|
||||||
if(prefix)
|
|
||||||
{
|
|
||||||
id = std::string(prefix) + "." + id;
|
|
||||||
}
|
|
||||||
os << this->Docname << '.' << id;
|
|
||||||
|
|
||||||
// make sure that each id exists only once. Since it seems
|
|
||||||
// not easily possible to determine which link refers to which id,
|
|
||||||
// we have at least to make sure that the duplicated id's get a
|
|
||||||
// different name (by appending an increasing number), Alex
|
|
||||||
if (this->EmittedLinkIds.find(id) == this->EmittedLinkIds.end())
|
|
||||||
{
|
|
||||||
this->EmittedLinkIds.insert(id);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static unsigned int i=0;
|
|
||||||
os << i++;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#ifndef _cmDocumentationFormatterDocbook_h
|
|
||||||
#define _cmDocumentationFormatterDocbook_h
|
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatter.h"
|
|
||||||
|
|
||||||
/** Class to print the documentation as Docbook.
|
|
||||||
http://www.oasis-open.org/docbook/xml/4.2/ */
|
|
||||||
class cmDocumentationFormatterDocbook : public cmDocumentationFormatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cmDocumentationFormatterDocbook();
|
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const
|
|
||||||
{ return cmDocumentationEnums::DocbookForm;}
|
|
||||||
|
|
||||||
virtual void PrintHeader(const char* docname, const char* appname,
|
|
||||||
std::ostream& os);
|
|
||||||
virtual void PrintFooter(std::ostream& os);
|
|
||||||
virtual void PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection& section,
|
|
||||||
const char* name);
|
|
||||||
virtual void PrintPreformatted(std::ostream& os, const char* text);
|
|
||||||
virtual void PrintParagraph(std::ostream& os, const char* text);
|
|
||||||
private:
|
|
||||||
void PrintId(std::ostream& os, const char* prefix, std::string id);
|
|
||||||
std::set<std::string> EmittedLinkIds;
|
|
||||||
std::string Docname;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,288 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#include "cmDocumentationFormatterHTML.h"
|
|
||||||
#include "cmDocumentationSection.h"
|
|
||||||
#include "cmVersion.h"
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static bool cmDocumentationIsHyperlinkChar(char c)
|
|
||||||
{
|
|
||||||
// This is not a complete list but works for CMake documentation.
|
|
||||||
return ((c >= 'A' && c <= 'Z') ||
|
|
||||||
(c >= 'a' && c <= 'z') ||
|
|
||||||
(c >= '0' && c <= '9') ||
|
|
||||||
c == '-' || c == '.' || c == '/' || c == '~' || c == '@' ||
|
|
||||||
c == ':' || c == '_' || c == '&' || c == '?' || c == '=');
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
static void cmDocumentationPrintHTMLChar(std::ostream& os, char c)
|
|
||||||
{
|
|
||||||
// Use an escape sequence if necessary.
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '<':
|
|
||||||
os << "<";
|
|
||||||
break;
|
|
||||||
case '>':
|
|
||||||
os << ">";
|
|
||||||
break;
|
|
||||||
case '&':
|
|
||||||
os << "&";
|
|
||||||
break;
|
|
||||||
case '\n':
|
|
||||||
os << "<br />";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
os << c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
bool cmDocumentationHTMLIsIdChar(char c)
|
|
||||||
{
|
|
||||||
// From the HTML specification:
|
|
||||||
// ID and NAME tokens must begin with a letter ([A-Za-z]) and may
|
|
||||||
// be followed by any number of letters, digits ([0-9]), hyphens
|
|
||||||
// ("-"), underscores ("_"), colons (":"), and periods (".").
|
|
||||||
return ((c >= 'A' && c <= 'Z') ||
|
|
||||||
(c >= 'a' && c <= 'z') ||
|
|
||||||
(c >= '0' && c <= '9') ||
|
|
||||||
c == '-' || c == '_' || c == ':' || c == '.');
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationPrintHTMLId(std::ostream& os, const char* begin)
|
|
||||||
{
|
|
||||||
for(const char* c = begin; *c; ++c)
|
|
||||||
{
|
|
||||||
if(cmDocumentationHTMLIsIdChar(*c))
|
|
||||||
{
|
|
||||||
os << *c;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
const char* cmDocumentationPrintHTMLLink(std::ostream& os, const char* begin)
|
|
||||||
{
|
|
||||||
// Look for the end of the link.
|
|
||||||
const char* end = begin;
|
|
||||||
while(cmDocumentationIsHyperlinkChar(*end))
|
|
||||||
{
|
|
||||||
++end;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print the hyperlink itself.
|
|
||||||
os << "<a href=\"";
|
|
||||||
for(const char* c = begin; c != end; ++c)
|
|
||||||
{
|
|
||||||
cmDocumentationPrintHTMLChar(os, *c);
|
|
||||||
}
|
|
||||||
os << "\">";
|
|
||||||
|
|
||||||
// The name of the hyperlink is the text itself.
|
|
||||||
for(const char* c = begin; c != end; ++c)
|
|
||||||
{
|
|
||||||
cmDocumentationPrintHTMLChar(os, *c);
|
|
||||||
}
|
|
||||||
os << "</a>";
|
|
||||||
|
|
||||||
// Return the position at which to continue scanning the input
|
|
||||||
// string.
|
|
||||||
return end;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
cmDocumentationFormatterHTML::cmDocumentationFormatterHTML()
|
|
||||||
:cmDocumentationFormatter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterHTML
|
|
||||||
::PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection §ion,
|
|
||||||
const char* name)
|
|
||||||
{
|
|
||||||
std::string prefix = this->ComputeSectionLinkPrefix(name);
|
|
||||||
|
|
||||||
const std::vector<cmDocumentationEntry> &entries =
|
|
||||||
section.GetEntries();
|
|
||||||
|
|
||||||
// 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 (name)
|
|
||||||
{
|
|
||||||
os << "<h2><a name=\"section_";
|
|
||||||
cmDocumentationPrintHTMLId(os, name);
|
|
||||||
os << "\"></a>" << name << "</h2>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is a list needed?
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op
|
|
||||||
= entries.begin(); op != entries.end(); ++ op )
|
|
||||||
{
|
|
||||||
if (op->Name.size())
|
|
||||||
{
|
|
||||||
os << "<ul>\n";
|
|
||||||
for(;op != entries.end() && op->Name.size(); ++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>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << "</ul>\n" ;
|
|
||||||
break; // Skip outer loop termination test
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
||||||
op != entries.end();)
|
|
||||||
{
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
os << "<ul>\n";
|
|
||||||
for(;op != entries.end() && op->Name.size(); ++op)
|
|
||||||
{
|
|
||||||
os << " <li>\n";
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
os << " <a name=\"" << prefix << ":";
|
|
||||||
cmDocumentationPrintHTMLId(os, op->Name.c_str());
|
|
||||||
os << "\"></a><b><code>";
|
|
||||||
this->PrintHTMLEscapes(os, op->Name.c_str());
|
|
||||||
os << "</code></b>: ";
|
|
||||||
}
|
|
||||||
this->PrintHTMLEscapes(os, op->Brief.c_str());
|
|
||||||
if(op->Full.size())
|
|
||||||
{
|
|
||||||
os << "<br />\n ";
|
|
||||||
this->PrintFormatted(os, op->Full.c_str());
|
|
||||||
}
|
|
||||||
os << "\n";
|
|
||||||
os << " </li>\n";
|
|
||||||
}
|
|
||||||
os << "</ul>\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
os << "\n";
|
|
||||||
++op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterHTML::PrintPreformatted(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
os << "<pre>";
|
|
||||||
this->PrintHTMLEscapes(os, text);
|
|
||||||
os << "</pre>\n ";
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterHTML::PrintParagraph(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
os << "<p>";
|
|
||||||
this->PrintHTMLEscapes(os, text);
|
|
||||||
os << "</p>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterHTML::PrintHeader(const char* docname,
|
|
||||||
const char* appname,
|
|
||||||
std::ostream& os)
|
|
||||||
{
|
|
||||||
os << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
|
|
||||||
<< " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
|
|
||||||
os << "<html xmlns=\"http://www.w3.org/1999/xhtml\""
|
|
||||||
<< " xml:lang=\"en\" lang=\"en\">\n";
|
|
||||||
os << "<head><meta http-equiv=\"Content-Type\" "
|
|
||||||
<< "content=\"text/html;charset=utf-8\" /><title>";
|
|
||||||
os << docname << " - " << appname;
|
|
||||||
os << "</title></head><body>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterHTML::PrintFooter(std::ostream& os)
|
|
||||||
{
|
|
||||||
os << "</body></html>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterHTML::PrintHTMLEscapes(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
// Hyperlink prefixes.
|
|
||||||
static const char* hyperlinks[] = {"http://", "ftp://", "mailto:", 0};
|
|
||||||
|
|
||||||
// Print each character.
|
|
||||||
for(const char* p = text; *p;)
|
|
||||||
{
|
|
||||||
// Handle hyperlinks specially to make them active.
|
|
||||||
bool found_hyperlink = false;
|
|
||||||
for(const char** h = hyperlinks; !found_hyperlink && *h; ++h)
|
|
||||||
{
|
|
||||||
if(strncmp(p, *h, strlen(*h)) == 0)
|
|
||||||
{
|
|
||||||
p = cmDocumentationPrintHTMLLink(os, p);
|
|
||||||
found_hyperlink = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print other characters normally.
|
|
||||||
if(!found_hyperlink)
|
|
||||||
{
|
|
||||||
cmDocumentationPrintHTMLChar(os, *p++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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\"></a>Master Index "
|
|
||||||
<< "CMake " << cmVersion::GetCMakeVersion()
|
|
||||||
<< "</h2>\n";
|
|
||||||
|
|
||||||
if (!sections.empty())
|
|
||||||
{
|
|
||||||
os << "<ul>\n";
|
|
||||||
for(unsigned int i=0; i < sections.size(); ++i)
|
|
||||||
{
|
|
||||||
std::string name = sections[i]->GetName((this->GetForm()));
|
|
||||||
os << " <li><a href=\"#section_";
|
|
||||||
cmDocumentationPrintHTMLId(os, name.c_str());
|
|
||||||
os << "\"><b>" << name << "</b></a></li>\n";
|
|
||||||
}
|
|
||||||
os << "</ul>\n";
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,42 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#ifndef _cmDocumentationFormatterHTML_h
|
|
||||||
#define _cmDocumentationFormatterHTML_h
|
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatter.h"
|
|
||||||
|
|
||||||
/** Class to print the documentation as HTML. */
|
|
||||||
class cmDocumentationFormatterHTML : public cmDocumentationFormatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cmDocumentationFormatterHTML();
|
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const
|
|
||||||
{ return cmDocumentationEnums::HTMLForm;}
|
|
||||||
|
|
||||||
virtual void PrintHeader(const char* docname, const char* appname,
|
|
||||||
std::ostream& os);
|
|
||||||
virtual void PrintFooter(std::ostream& os);
|
|
||||||
virtual void PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection& section,
|
|
||||||
const char* name);
|
|
||||||
virtual void PrintPreformatted(std::ostream& os, const char* text);
|
|
||||||
virtual void PrintParagraph(std::ostream& os, const char* text);
|
|
||||||
virtual void PrintIndex(std::ostream& ,
|
|
||||||
std::vector<const cmDocumentationSection *>&);
|
|
||||||
private:
|
|
||||||
void PrintHTMLEscapes(std::ostream& os, const char* text);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,102 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatterMan.h"
|
|
||||||
#include "cmDocumentationSection.h"
|
|
||||||
|
|
||||||
#include "cmSystemTools.h"
|
|
||||||
#include "cmVersion.h"
|
|
||||||
|
|
||||||
|
|
||||||
cmDocumentationFormatterMan::cmDocumentationFormatterMan()
|
|
||||||
:cmDocumentationFormatter()
|
|
||||||
,ManSection(1)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterMan::SetManSection(int manSection)
|
|
||||||
{
|
|
||||||
this->ManSection = manSection;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterMan
|
|
||||||
::PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection §ion,
|
|
||||||
const char* name)
|
|
||||||
{
|
|
||||||
if(name)
|
|
||||||
{
|
|
||||||
os << ".SH " << name << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<cmDocumentationEntry> &entries =
|
|
||||||
section.GetEntries();
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
||||||
op != entries.end(); ++op)
|
|
||||||
{
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
os << ".TP\n"
|
|
||||||
<< ".B " << (op->Name.size()?op->Name.c_str():"*") << "\n";
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
this->PrintFormatted(os, op->Full.c_str());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << ".PP\n";
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterMan::EscapeText(std::string& man_text)
|
|
||||||
{
|
|
||||||
cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
|
|
||||||
cmSystemTools::ReplaceString(man_text, "-", "\\-");
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterMan::PrintPreformatted(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
std::string man_text = text;
|
|
||||||
this->EscapeText(man_text);
|
|
||||||
os << ".nf\n" << man_text;
|
|
||||||
if (*text && man_text.at(man_text.length()-1) != '\n')
|
|
||||||
os << "\n";
|
|
||||||
os << ".fi\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterMan::PrintParagraph(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
std::string man_text = text;
|
|
||||||
this->EscapeText(man_text);
|
|
||||||
os << man_text << "\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void cmDocumentationFormatterMan::PrintHeader(const char* docname,
|
|
||||||
const char* appname,
|
|
||||||
std::ostream& os)
|
|
||||||
{
|
|
||||||
std::string s_docname(docname), s_appname(appname);
|
|
||||||
|
|
||||||
this->EscapeText(s_docname);
|
|
||||||
this->EscapeText(s_appname);
|
|
||||||
os << ".TH " << s_docname << " " << this->ManSection << " \""
|
|
||||||
<< cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
|
|
||||||
<< "\" \"" << s_appname
|
|
||||||
<< " " << cmVersion::GetCMakeVersion()
|
|
||||||
<< "\"\n";
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#ifndef _cmDocumentationFormatterMan_h
|
|
||||||
#define _cmDocumentationFormatterMan_h
|
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatter.h"
|
|
||||||
|
|
||||||
/** Class to print the documentation as man page. */
|
|
||||||
class cmDocumentationFormatterMan : public cmDocumentationFormatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cmDocumentationFormatterMan();
|
|
||||||
|
|
||||||
void SetManSection(int manSection);
|
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const
|
|
||||||
{ return cmDocumentationEnums::ManForm;}
|
|
||||||
|
|
||||||
virtual void PrintHeader(const char* docname, const char* appname,
|
|
||||||
std::ostream& os);
|
|
||||||
virtual void PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection& section,
|
|
||||||
const char* name);
|
|
||||||
virtual void PrintPreformatted(std::ostream& os, const char* text);
|
|
||||||
virtual void PrintParagraph(std::ostream& os, const char* text);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void EscapeText(std::string& man_text);
|
|
||||||
int ManSection;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,107 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#include "cmDocumentationFormatterRST.h"
|
|
||||||
#include "cmDocumentationSection.h"
|
|
||||||
#include "cmVersion.h"
|
|
||||||
|
|
||||||
#include "cmSystemTools.h"
|
|
||||||
|
|
||||||
cmDocumentationFormatterRST::cmDocumentationFormatterRST()
|
|
||||||
:cmDocumentationFormatterText()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string rstFileName(std::string fn)
|
|
||||||
{
|
|
||||||
cmSystemTools::ReplaceString(fn, "<", "");
|
|
||||||
cmSystemTools::ReplaceString(fn, ">", "");
|
|
||||||
return fn;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterRST
|
|
||||||
::PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection §ion,
|
|
||||||
const char* name)
|
|
||||||
{
|
|
||||||
std::string prefix = this->ComputeSectionLinkPrefix(name);
|
|
||||||
std::vector<cmDocumentationEntry> const& entries = section.GetEntries();
|
|
||||||
this->TextWidth = 70;
|
|
||||||
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
||||||
op != entries.end();)
|
|
||||||
{
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
for(;op != entries.end() && op->Name.size(); ++op)
|
|
||||||
{
|
|
||||||
if(prefix == "opt" || prefix == "see")
|
|
||||||
{
|
|
||||||
os << "\n";
|
|
||||||
os << "* ``" << op->Name << "``: " << op->Brief << "\n";
|
|
||||||
this->TextIndent = " ";
|
|
||||||
if(op->Full.size())
|
|
||||||
{
|
|
||||||
os << "\n";
|
|
||||||
this->PrintFormatted(os, op->Full.c_str());
|
|
||||||
}
|
|
||||||
this->TextIndent = "";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cmSystemTools::MakeDirectory(prefix.c_str());
|
|
||||||
std::string fname = prefix + "/" + rstFileName(op->Name) + ".rst";
|
|
||||||
if(cmSystemTools::FileExists(fname.c_str()))
|
|
||||||
{
|
|
||||||
cmSystemTools::Error("Duplicate file name: ", fname.c_str());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::ofstream of(fname.c_str());
|
|
||||||
of << op->Name << "\n";
|
|
||||||
for(size_t i = 0; i < op->Name.size(); ++i)
|
|
||||||
{
|
|
||||||
of << "-";
|
|
||||||
}
|
|
||||||
of << "\n\n" << op->Brief << "\n";
|
|
||||||
if(op->Full.size())
|
|
||||||
{
|
|
||||||
of << "\n";
|
|
||||||
this->PrintFormatted(of, op->Full.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
os << "\n";
|
|
||||||
++op;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterRST::PrintPreformatted(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
os << this->TextIndent << "::\n\n";
|
|
||||||
bool newline = true;
|
|
||||||
for(const char* c = text; *c; ++c)
|
|
||||||
{
|
|
||||||
if (newline)
|
|
||||||
{
|
|
||||||
os << this->TextIndent;
|
|
||||||
newline = false;
|
|
||||||
}
|
|
||||||
os << *c;
|
|
||||||
newline = (*c == '\n');
|
|
||||||
}
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#ifndef _cmDocumentationFormatterRST_h
|
|
||||||
#define _cmDocumentationFormatterRST_h
|
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatterText.h"
|
|
||||||
|
|
||||||
/** Class to print the documentation as reStructuredText. */
|
|
||||||
class cmDocumentationFormatterRST : public cmDocumentationFormatterText
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cmDocumentationFormatterRST();
|
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const
|
|
||||||
{ return cmDocumentationEnums::RSTForm;}
|
|
||||||
|
|
||||||
virtual void PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection& section,
|
|
||||||
const char* name);
|
|
||||||
virtual void PrintPreformatted(std::ostream& os, const char* text);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,180 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatterText.h"
|
|
||||||
#include "cmDocumentationSection.h"
|
|
||||||
|
|
||||||
cmDocumentationFormatterText::cmDocumentationFormatterText()
|
|
||||||
:cmDocumentationFormatter()
|
|
||||||
,TextWidth(77)
|
|
||||||
,TextIndent("")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterText
|
|
||||||
::PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection §ion,
|
|
||||||
const char* name)
|
|
||||||
{
|
|
||||||
if(name && (strcmp(name, "SingleItem")!=0))
|
|
||||||
{
|
|
||||||
os <<
|
|
||||||
"---------------------------------------"
|
|
||||||
"---------------------------------------\n";
|
|
||||||
os << name << "\n\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<cmDocumentationEntry> &entries =
|
|
||||||
section.GetEntries();
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
||||||
op != entries.end(); ++op)
|
|
||||||
{
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
os << " " << op->Name << "\n";
|
|
||||||
this->TextIndent = " ";
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
if(op->Full.size())
|
|
||||||
{
|
|
||||||
os << "\n";
|
|
||||||
this->PrintFormatted(os, op->Full.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this->TextIndent = "";
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
}
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterText::PrintPreformatted(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
bool newline = true;
|
|
||||||
for(const char* ptr = text; *ptr; ++ptr)
|
|
||||||
{
|
|
||||||
if(newline && *ptr != '\n')
|
|
||||||
{
|
|
||||||
os << this->TextIndent;
|
|
||||||
newline = false;
|
|
||||||
}
|
|
||||||
os << *ptr;
|
|
||||||
if(*ptr == '\n')
|
|
||||||
{
|
|
||||||
newline = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterText::PrintParagraph(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
os << this->TextIndent;
|
|
||||||
this->PrintColumn(os, text);
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterText::SetIndent(const char* indent)
|
|
||||||
{
|
|
||||||
this->TextIndent = indent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterText::PrintColumn(std::ostream& os,
|
|
||||||
const char* text)
|
|
||||||
{
|
|
||||||
// Print text arranged in an indented column of fixed witdh.
|
|
||||||
const char* l = text;
|
|
||||||
long column = 0;
|
|
||||||
bool newSentence = false;
|
|
||||||
bool firstLine = true;
|
|
||||||
int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent));
|
|
||||||
|
|
||||||
// Loop until the end of the text.
|
|
||||||
while(*l)
|
|
||||||
{
|
|
||||||
// Parse the next word.
|
|
||||||
const char* r = l;
|
|
||||||
while(*r && (*r != '\n') && (*r != ' ')) { ++r; }
|
|
||||||
|
|
||||||
// Does it fit on this line?
|
|
||||||
if(r-l < (width-column-(newSentence?1:0)))
|
|
||||||
{
|
|
||||||
// Word fits on this line.
|
|
||||||
if(r > l)
|
|
||||||
{
|
|
||||||
if(column)
|
|
||||||
{
|
|
||||||
// Not first word on line. Separate from the previous word
|
|
||||||
// by a space, or two if this is a new sentence.
|
|
||||||
if(newSentence)
|
|
||||||
{
|
|
||||||
os << " ";
|
|
||||||
column += 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << " ";
|
|
||||||
column += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// First word on line. Print indentation unless this is the
|
|
||||||
// first line.
|
|
||||||
os << (firstLine?"":this->TextIndent);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print the word.
|
|
||||||
os.write(l, static_cast<long>(r-l));
|
|
||||||
newSentence = (*(r-1) == '.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if(*r == '\n')
|
|
||||||
{
|
|
||||||
// Text provided a newline. Start a new line.
|
|
||||||
os << "\n";
|
|
||||||
++r;
|
|
||||||
column = 0;
|
|
||||||
firstLine = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// No provided newline. Continue this line.
|
|
||||||
column += static_cast<long>(r-l);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Word does not fit on this line. Start a new line.
|
|
||||||
os << "\n";
|
|
||||||
firstLine = false;
|
|
||||||
if(r > l)
|
|
||||||
{
|
|
||||||
os << this->TextIndent;
|
|
||||||
os.write(l, static_cast<long>(r-l));
|
|
||||||
column = static_cast<long>(r-l);
|
|
||||||
newSentence = (*(r-1) == '.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
column = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move to beginning of next word. Skip over whitespace.
|
|
||||||
l = r;
|
|
||||||
while(*l && (*l == ' ')) { ++l; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#ifndef _cmDocumentationFormatterText_h
|
|
||||||
#define _cmDocumentationFormatterText_h
|
|
||||||
|
|
||||||
#include "cmStandardIncludes.h"
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatter.h"
|
|
||||||
|
|
||||||
/** Class to print the documentation as plain text. */
|
|
||||||
class cmDocumentationFormatterText : public cmDocumentationFormatter
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cmDocumentationFormatterText();
|
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const
|
|
||||||
{ return cmDocumentationEnums::TextForm;}
|
|
||||||
|
|
||||||
virtual void PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection& section,
|
|
||||||
const char* name);
|
|
||||||
virtual void PrintPreformatted(std::ostream& os, const char* text);
|
|
||||||
virtual void PrintParagraph(std::ostream& os, const char* text);
|
|
||||||
void PrintColumn(std::ostream& os, const char* text);
|
|
||||||
void SetIndent(const char* indent);
|
|
||||||
protected:
|
|
||||||
int TextWidth;
|
|
||||||
const char* TextIndent;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatterUsage.h"
|
|
||||||
#include "cmDocumentationSection.h"
|
|
||||||
|
|
||||||
cmDocumentationFormatterUsage::cmDocumentationFormatterUsage()
|
|
||||||
:cmDocumentationFormatterText()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmDocumentationFormatterUsage
|
|
||||||
::PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection §ion,
|
|
||||||
const char* name)
|
|
||||||
{
|
|
||||||
if(name)
|
|
||||||
{
|
|
||||||
os << name << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::vector<cmDocumentationEntry> &entries =
|
|
||||||
section.GetEntries();
|
|
||||||
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
||||||
op != entries.end(); ++op)
|
|
||||||
{
|
|
||||||
if(op->Name.size())
|
|
||||||
{
|
|
||||||
os << " " << op->Name;
|
|
||||||
this->TextIndent = " ";
|
|
||||||
int align = static_cast<int>(strlen(this->TextIndent))-4;
|
|
||||||
for(int i = static_cast<int>(op->Name.size()); i < align; ++i)
|
|
||||||
{
|
|
||||||
os << " ";
|
|
||||||
}
|
|
||||||
if (op->Name.size() > strlen(this->TextIndent)-4 )
|
|
||||||
{
|
|
||||||
os << "\n";
|
|
||||||
os.write(this->TextIndent, strlen(this->TextIndent)-2);
|
|
||||||
}
|
|
||||||
os << "= ";
|
|
||||||
this->PrintColumn(os, op->Brief.c_str());
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
os << "\n";
|
|
||||||
this->TextIndent = "";
|
|
||||||
this->PrintFormatted(os, op->Brief.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
os << "\n";
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
/*============================================================================
|
|
||||||
CMake - Cross Platform Makefile Generator
|
|
||||||
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
||||||
|
|
||||||
Distributed under the OSI-approved BSD License (the "License");
|
|
||||||
see accompanying file Copyright.txt for details.
|
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
See the License for more information.
|
|
||||||
============================================================================*/
|
|
||||||
#ifndef _cmDocumentationFormatterUsage_h
|
|
||||||
#define _cmDocumentationFormatterUsage_h
|
|
||||||
|
|
||||||
#include "cmDocumentationFormatterText.h"
|
|
||||||
|
|
||||||
/** Class to print the documentation as usage on the command line. */
|
|
||||||
class cmDocumentationFormatterUsage : public cmDocumentationFormatterText
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
cmDocumentationFormatterUsage();
|
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const
|
|
||||||
{ return cmDocumentationEnums::UsageForm;}
|
|
||||||
|
|
||||||
virtual void PrintSection(std::ostream& os,
|
|
||||||
const cmDocumentationSection& section,
|
|
||||||
const char* name);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -24,8 +24,8 @@ class cmDocumentationSection
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Create a cmSection, with a special name for man-output mode. */
|
/** Create a cmSection, with a special name for man-output mode. */
|
||||||
cmDocumentationSection(const char* name, const char* manName)
|
cmDocumentationSection(const char* name, const char*)
|
||||||
:Name(name), ManName(manName) {}
|
:Name(name) {}
|
||||||
|
|
||||||
/** Has any content been added to this section or is it empty ? */
|
/** Has any content been added to this section or is it empty ? */
|
||||||
bool IsEmpty() const { return this->Entries.empty(); }
|
bool IsEmpty() const { return this->Entries.empty(); }
|
||||||
|
@ -33,10 +33,9 @@ public:
|
||||||
/** Clear contents. */
|
/** Clear contents. */
|
||||||
void Clear() { this->Entries.clear(); }
|
void Clear() { this->Entries.clear(); }
|
||||||
|
|
||||||
/** Return the name of this section for the given output form. */
|
/** Return the name of this section. */
|
||||||
const char* GetName(cmDocumentationEnums::Form form) const
|
const char* GetName() const
|
||||||
{ return (form==cmDocumentationEnums::ManForm ?
|
{ return this->Name.c_str(); }
|
||||||
this->ManName.c_str() : this->Name.c_str()); }
|
|
||||||
|
|
||||||
/** Return a pointer to the first entry of this section. */
|
/** Return a pointer to the first entry of this section. */
|
||||||
const std::vector<cmDocumentationEntry> &GetEntries() const
|
const std::vector<cmDocumentationEntry> &GetEntries() const
|
||||||
|
@ -61,7 +60,6 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string Name;
|
std::string Name;
|
||||||
std::string ManName;
|
|
||||||
std::vector<cmDocumentationEntry> Entries;
|
std::vector<cmDocumentationEntry> Entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "cmFileTimeComparison.h"
|
#include "cmFileTimeComparison.h"
|
||||||
#include "cmSourceFile.h"
|
#include "cmSourceFile.h"
|
||||||
#include "cmTest.h"
|
#include "cmTest.h"
|
||||||
#include "cmDocumentationFormatterText.h"
|
#include "cmDocumentationFormatter.h"
|
||||||
|
|
||||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||||
# include "cmGraphVizWriter.h"
|
# include "cmGraphVizWriter.h"
|
||||||
|
@ -3009,7 +3009,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
|
||||||
// Add the message text.
|
// Add the message text.
|
||||||
{
|
{
|
||||||
msg << ":\n";
|
msg << ":\n";
|
||||||
cmDocumentationFormatterText formatter;
|
cmDocumentationFormatter formatter;
|
||||||
formatter.SetIndent(" ");
|
formatter.SetIndent(" ");
|
||||||
formatter.PrintFormatted(msg, text.c_str());
|
formatter.PrintFormatted(msg, text.c_str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue