2009-10-02 01:21:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2007-09-19 17:05:28 +04:00
|
|
|
|
2009-10-02 01:21:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2007-09-19 17:05:28 +04:00
|
|
|
|
2009-10-02 01:21:28 +04:00
|
|
|
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.
|
|
|
|
============================================================================*/
|
2007-09-19 17:05:28 +04:00
|
|
|
|
|
|
|
#include "cmDocumentationFormatterMan.h"
|
2007-10-22 20:49:09 +04:00
|
|
|
#include "cmDocumentationSection.h"
|
2007-09-19 17:05:28 +04:00
|
|
|
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmVersion.h"
|
|
|
|
|
|
|
|
|
|
|
|
cmDocumentationFormatterMan::cmDocumentationFormatterMan()
|
|
|
|
:cmDocumentationFormatter()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-22 20:49:09 +04:00
|
|
|
void cmDocumentationFormatterMan
|
|
|
|
::PrintSection(std::ostream& os,
|
|
|
|
const cmDocumentationSection §ion,
|
|
|
|
const char* name)
|
2007-09-19 17:05:28 +04:00
|
|
|
{
|
|
|
|
if(name)
|
|
|
|
{
|
|
|
|
os << ".SH " << name << "\n";
|
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
|
|
|
|
const std::vector<cmDocumentationEntry> &entries =
|
|
|
|
section.GetEntries();
|
|
|
|
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
|
|
op != entries.end(); ++op)
|
2007-09-19 17:05:28 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if(op->Name.size())
|
2007-09-19 17:05:28 +04:00
|
|
|
{
|
|
|
|
os << ".TP\n"
|
2007-10-22 20:49:09 +04:00
|
|
|
<< ".B " << (op->Name.size()?op->Name.c_str():"*") << "\n";
|
|
|
|
this->PrintFormatted(os, op->Brief.c_str());
|
|
|
|
this->PrintFormatted(os, op->Full.c_str());
|
2007-09-19 17:05:28 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os << ".PP\n";
|
2007-10-22 20:49:09 +04:00
|
|
|
this->PrintFormatted(os, op->Brief.c_str());
|
2007-09-19 17:05:28 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
void cmDocumentationFormatterMan::EscapeText(std::string& man_text)
|
|
|
|
{
|
|
|
|
cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
|
|
|
|
cmSystemTools::ReplaceString(man_text, "-", "\\-");
|
|
|
|
}
|
|
|
|
|
2007-09-19 17:05:28 +04:00
|
|
|
void cmDocumentationFormatterMan::PrintPreformatted(std::ostream& os,
|
|
|
|
const char* text)
|
|
|
|
{
|
|
|
|
std::string man_text = text;
|
2008-10-10 19:23:35 +04:00
|
|
|
this->EscapeText(man_text);
|
|
|
|
os << ".nf\n" << man_text;
|
|
|
|
if (*text && man_text.at(man_text.length()-1) != '\n')
|
|
|
|
os << "\n";
|
2009-03-06 18:01:14 +03:00
|
|
|
os << ".fi\n\n";
|
2007-09-19 17:05:28 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmDocumentationFormatterMan::PrintParagraph(std::ostream& os,
|
|
|
|
const char* text)
|
|
|
|
{
|
|
|
|
std::string man_text = text;
|
2008-10-10 19:23:35 +04:00
|
|
|
this->EscapeText(man_text);
|
2007-09-19 17:05:28 +04:00
|
|
|
os << man_text << "\n\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-10-10 19:23:35 +04:00
|
|
|
void cmDocumentationFormatterMan::PrintHeader(const char* docname,
|
|
|
|
const char* appname,
|
2007-09-19 17:05:28 +04:00
|
|
|
std::ostream& os)
|
|
|
|
{
|
2008-10-10 19:23:35 +04:00
|
|
|
std::string s_docname(docname), s_appname(appname);
|
|
|
|
|
|
|
|
this->EscapeText(s_docname);
|
|
|
|
this->EscapeText(s_appname);
|
|
|
|
os << ".TH " << s_docname << " 1 \""
|
2007-09-19 17:05:28 +04:00
|
|
|
<< cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
|
2008-10-10 19:23:35 +04:00
|
|
|
<< "\" \"" << s_appname
|
2007-09-19 17:05:28 +04:00
|
|
|
<< " " << cmVersion::GetCMakeVersion()
|
|
|
|
<< "\"\n";
|
|
|
|
}
|
|
|
|
|