1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
13 #include "cmDocumentationFormatterMan.h"
14 #include "cmDocumentationSection.h"
16 #include "cmSystemTools.h"
17 #include "cmVersion.h"
20 cmDocumentationFormatterMan::cmDocumentationFormatterMan()
21 :cmDocumentationFormatter()
26 void cmDocumentationFormatterMan::SetManSection(int manSection)
28 this->ManSection = manSection;
31 void cmDocumentationFormatterMan
32 ::PrintSection(std::ostream& os,
33 const cmDocumentationSection §ion,
38 os << ".SH " << name << "\n";
41 const std::vector<cmDocumentationEntry> &entries =
43 for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
44 op != entries.end(); ++op)
49 << ".B " << (op->Name.size()?op->Name.c_str():"*") << "\n";
50 this->PrintFormatted(os, op->Brief.c_str());
51 this->PrintFormatted(os, op->Full.c_str());
56 this->PrintFormatted(os, op->Brief.c_str());
61 void cmDocumentationFormatterMan::EscapeText(std::string& man_text)
63 cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
64 cmSystemTools::ReplaceString(man_text, "-", "\\-");
67 void cmDocumentationFormatterMan::PrintPreformatted(std::ostream& os,
70 std::string man_text = text;
71 this->EscapeText(man_text);
72 os << ".nf\n" << man_text;
73 if (*text && man_text.at(man_text.length()-1) != '\n')
78 void cmDocumentationFormatterMan::PrintParagraph(std::ostream& os,
81 std::string man_text = text;
82 this->EscapeText(man_text);
83 os << man_text << "\n\n";
87 //----------------------------------------------------------------------------
88 void cmDocumentationFormatterMan::PrintHeader(const char* docname,
92 std::string s_docname(docname), s_appname(appname);
94 this->EscapeText(s_docname);
95 this->EscapeText(s_appname);
96 os << ".TH " << s_docname << " " << this->ManSection << " \""
97 << cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
98 << "\" \"" << s_appname
99 << " " << cmVersion::GetCMakeVersion()