Merge topic 'DetectManSection'
20e133e man documentation: detect man section from the given filename 38df155 documentation: preparation for making the man section configurable e6a935f -remove trailing whitespace
This commit is contained in:
commit
e6ce00a4ac
@ -221,7 +221,7 @@ DOCUMENT_INTRO(CompatCommands, "cmakecompat",
|
|||||||
cmDocumentation::cmDocumentation()
|
cmDocumentation::cmDocumentation()
|
||||||
:CurrentFormatter(0)
|
:CurrentFormatter(0)
|
||||||
{
|
{
|
||||||
this->SetForm(TextForm);
|
this->SetForm(TextForm, 0);
|
||||||
this->addCommonStandardDocSections();
|
this->addCommonStandardDocSections();
|
||||||
this->ShowGenerators = true;
|
this->ShowGenerators = true;
|
||||||
}
|
}
|
||||||
@ -594,7 +594,7 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
|||||||
i != this->RequestedHelpItems.end();
|
i != this->RequestedHelpItems.end();
|
||||||
++i)
|
++i)
|
||||||
{
|
{
|
||||||
this->SetForm(i->HelpForm);
|
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.
|
||||||
@ -642,7 +642,8 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
|||||||
|
|
||||||
|
|
||||||
cmDocumentation::Form cmDocumentation::GetFormFromFilename(
|
cmDocumentation::Form cmDocumentation::GetFormFromFilename(
|
||||||
const std::string& filename)
|
const std::string& filename,
|
||||||
|
int* manSection)
|
||||||
{
|
{
|
||||||
std::string ext = cmSystemTools::GetFilenameLastExtension(filename);
|
std::string ext = cmSystemTools::GetFilenameLastExtension(filename);
|
||||||
ext = cmSystemTools::UpperCase(ext);
|
ext = cmSystemTools::UpperCase(ext);
|
||||||
@ -659,6 +660,10 @@ cmDocumentation::Form cmDocumentation::GetFormFromFilename(
|
|||||||
// ".1" to ".9" should be manpages
|
// ".1" to ".9" should be manpages
|
||||||
if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
|
if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
|
||||||
{
|
{
|
||||||
|
if (manSection)
|
||||||
|
{
|
||||||
|
*manSection = ext[1] - '0';
|
||||||
|
}
|
||||||
return cmDocumentation::ManForm;
|
return cmDocumentation::ManForm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1128,49 +1133,57 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
|||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Properties;
|
help.HelpType = cmDocumentation::Properties;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-policies") == 0)
|
else if(strcmp(argv[i], "--help-policies") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Policies;
|
help.HelpType = cmDocumentation::Policies;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-variables") == 0)
|
else if(strcmp(argv[i], "--help-variables") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Variables;
|
help.HelpType = cmDocumentation::Variables;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-modules") == 0)
|
else if(strcmp(argv[i], "--help-modules") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Modules;
|
help.HelpType = cmDocumentation::Modules;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-custom-modules") == 0)
|
else if(strcmp(argv[i], "--help-custom-modules") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::CustomModules;
|
help.HelpType = cmDocumentation::CustomModules;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-commands") == 0)
|
else if(strcmp(argv[i], "--help-commands") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Commands;
|
help.HelpType = cmDocumentation::Commands;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-compatcommands") == 0)
|
else if(strcmp(argv[i], "--help-compatcommands") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::CompatCommands;
|
help.HelpType = cmDocumentation::CompatCommands;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-full") == 0)
|
else if(strcmp(argv[i], "--help-full") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::Full;
|
help.HelpType = cmDocumentation::Full;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-html") == 0)
|
else if(strcmp(argv[i], "--help-html") == 0)
|
||||||
{
|
{
|
||||||
@ -1183,6 +1196,7 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
|||||||
help.HelpType = cmDocumentation::Full;
|
help.HelpType = cmDocumentation::Full;
|
||||||
GET_OPT_ARGUMENT(help.Filename);
|
GET_OPT_ARGUMENT(help.Filename);
|
||||||
help.HelpForm = cmDocumentation::ManForm;
|
help.HelpForm = cmDocumentation::ManForm;
|
||||||
|
help.ManSection = 1;
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-command") == 0)
|
else if(strcmp(argv[i], "--help-command") == 0)
|
||||||
{
|
{
|
||||||
@ -1190,35 +1204,40 @@ 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);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-module") == 0)
|
else if(strcmp(argv[i], "--help-module") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::SingleModule;
|
help.HelpType = cmDocumentation::SingleModule;
|
||||||
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);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-property") == 0)
|
else if(strcmp(argv[i], "--help-property") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::SingleProperty;
|
help.HelpType = cmDocumentation::SingleProperty;
|
||||||
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);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-policy") == 0)
|
else if(strcmp(argv[i], "--help-policy") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::SinglePolicy;
|
help.HelpType = cmDocumentation::SinglePolicy;
|
||||||
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);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-variable") == 0)
|
else if(strcmp(argv[i], "--help-variable") == 0)
|
||||||
{
|
{
|
||||||
help.HelpType = cmDocumentation::SingleVariable;
|
help.HelpType = cmDocumentation::SingleVariable;
|
||||||
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);
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
||||||
|
&help.ManSection);
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[i], "--help-command-list") == 0)
|
else if(strcmp(argv[i], "--help-command-list") == 0)
|
||||||
{
|
{
|
||||||
@ -1269,9 +1288,9 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmDocumentation::Print(Form f, std::ostream& os)
|
void cmDocumentation::Print(Form f, int manSection, std::ostream& os)
|
||||||
{
|
{
|
||||||
this->SetForm(f);
|
this->SetForm(f, manSection);
|
||||||
this->Print(os);
|
this->Print(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1879,7 +1898,7 @@ void cmDocumentation::CreateFullDocumentation()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmDocumentation::SetForm(Form f)
|
void cmDocumentation::SetForm(Form f, int manSection)
|
||||||
{
|
{
|
||||||
switch(f)
|
switch(f)
|
||||||
{
|
{
|
||||||
@ -1890,6 +1909,7 @@ void cmDocumentation::SetForm(Form f)
|
|||||||
this->CurrentFormatter = &this->DocbookFormatter;
|
this->CurrentFormatter = &this->DocbookFormatter;
|
||||||
break;
|
break;
|
||||||
case ManForm:
|
case ManForm:
|
||||||
|
this->ManFormatter.SetManSection(manSection);
|
||||||
this->CurrentFormatter = &this->ManFormatter;
|
this->CurrentFormatter = &this->ManFormatter;
|
||||||
break;
|
break;
|
||||||
case TextForm:
|
case TextForm:
|
||||||
|
@ -108,7 +108,7 @@ public:
|
|||||||
* Print documentation in the given form. All previously added
|
* Print documentation in the given form. All previously added
|
||||||
* sections will be generated.
|
* sections will be generated.
|
||||||
*/
|
*/
|
||||||
void Print(Form f, std::ostream& os);
|
void Print(Form f, int manSection, std::ostream& os);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print documentation in the current form. All previously added
|
* Print documentation in the current form. All previously added
|
||||||
@ -133,7 +133,8 @@ public:
|
|||||||
/** Set CMAKE_MODULE_PATH so we can find additional cmake modules */
|
/** Set CMAKE_MODULE_PATH so we can find additional cmake modules */
|
||||||
void SetCMakeModulePath(const char* path) { this->CMakeModulePath = path;}
|
void SetCMakeModulePath(const char* path) { this->CMakeModulePath = path;}
|
||||||
|
|
||||||
static Form GetFormFromFilename(const std::string& filename);
|
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();
|
||||||
@ -190,7 +191,7 @@ public:
|
|||||||
std::vector<cmDocumentationEntry>& commands,
|
std::vector<cmDocumentationEntry>& commands,
|
||||||
cmake* cm);
|
cmake* cm);
|
||||||
private:
|
private:
|
||||||
void SetForm(Form f);
|
void SetForm(Form f, int manSection);
|
||||||
void SetDocName(const char* docname);
|
void SetDocName(const char* docname);
|
||||||
|
|
||||||
bool CreateSingleModule(const char* fname,
|
bool CreateSingleModule(const char* fname,
|
||||||
@ -247,11 +248,12 @@ private:
|
|||||||
|
|
||||||
struct RequestedHelpItem
|
struct RequestedHelpItem
|
||||||
{
|
{
|
||||||
RequestedHelpItem():HelpForm(TextForm), HelpType(None) {}
|
RequestedHelpItem():HelpForm(TextForm), HelpType(None), ManSection(1) {}
|
||||||
cmDocumentationEnums::Form HelpForm;
|
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;
|
||||||
|
@ -19,9 +19,15 @@
|
|||||||
|
|
||||||
cmDocumentationFormatterMan::cmDocumentationFormatterMan()
|
cmDocumentationFormatterMan::cmDocumentationFormatterMan()
|
||||||
:cmDocumentationFormatter()
|
:cmDocumentationFormatter()
|
||||||
|
,ManSection(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmDocumentationFormatterMan::SetManSection(int manSection)
|
||||||
|
{
|
||||||
|
this->ManSection = manSection;
|
||||||
|
}
|
||||||
|
|
||||||
void cmDocumentationFormatterMan
|
void cmDocumentationFormatterMan
|
||||||
::PrintSection(std::ostream& os,
|
::PrintSection(std::ostream& os,
|
||||||
const cmDocumentationSection §ion,
|
const cmDocumentationSection §ion,
|
||||||
@ -87,7 +93,7 @@ void cmDocumentationFormatterMan::PrintHeader(const char* docname,
|
|||||||
|
|
||||||
this->EscapeText(s_docname);
|
this->EscapeText(s_docname);
|
||||||
this->EscapeText(s_appname);
|
this->EscapeText(s_appname);
|
||||||
os << ".TH " << s_docname << " 1 \""
|
os << ".TH " << s_docname << " " << this->ManSection << " \""
|
||||||
<< cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
|
<< cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
|
||||||
<< "\" \"" << s_appname
|
<< "\" \"" << s_appname
|
||||||
<< " " << cmVersion::GetCMakeVersion()
|
<< " " << cmVersion::GetCMakeVersion()
|
||||||
|
@ -22,6 +22,8 @@ class cmDocumentationFormatterMan : public cmDocumentationFormatter
|
|||||||
public:
|
public:
|
||||||
cmDocumentationFormatterMan();
|
cmDocumentationFormatterMan();
|
||||||
|
|
||||||
|
void SetManSection(int manSection);
|
||||||
|
|
||||||
virtual cmDocumentationEnums::Form GetForm() const
|
virtual cmDocumentationEnums::Form GetForm() const
|
||||||
{ return cmDocumentationEnums::ManForm;}
|
{ return cmDocumentationEnums::ManForm;}
|
||||||
|
|
||||||
@ -35,6 +37,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void EscapeText(std::string& man_text);
|
void EscapeText(std::string& man_text);
|
||||||
|
int ManSection;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -418,7 +418,7 @@ int do_cmake(int ac, char** av)
|
|||||||
{
|
{
|
||||||
doc.ClearSections();
|
doc.ClearSections();
|
||||||
doc.SetSection("NOTE", cmDocumentationNOTE);
|
doc.SetSection("NOTE", cmDocumentationNOTE);
|
||||||
doc.Print(cmDocumentation::UsageForm, std::cerr);
|
doc.Print(cmDocumentation::UsageForm, 0, std::cerr);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user