Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmDocumentationFormatterMan.cxx
blob45c0f4e08460127daf98ffce79132c936e09cfc5
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDocumentationFormatterMan.cxx,v $
5 Language: C++
6 Date: $Date: 2009-03-06 15:01:14 $
7 Version: $Revision: 1.7 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
18 #include "cmDocumentationFormatterMan.h"
19 #include "cmDocumentationSection.h"
21 #include "cmSystemTools.h"
22 #include "cmVersion.h"
25 cmDocumentationFormatterMan::cmDocumentationFormatterMan()
26 :cmDocumentationFormatter()
30 void cmDocumentationFormatterMan
31 ::PrintSection(std::ostream& os,
32 const cmDocumentationSection &section,
33 const char* name)
35 if(name)
37 os << ".SH " << name << "\n";
40 const std::vector<cmDocumentationEntry> &entries =
41 section.GetEntries();
42 for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
43 op != entries.end(); ++op)
45 if(op->Name.size())
47 os << ".TP\n"
48 << ".B " << (op->Name.size()?op->Name.c_str():"*") << "\n";
49 this->PrintFormatted(os, op->Brief.c_str());
50 this->PrintFormatted(os, op->Full.c_str());
52 else
54 os << ".PP\n";
55 this->PrintFormatted(os, op->Brief.c_str());
60 void cmDocumentationFormatterMan::EscapeText(std::string& man_text)
62 cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
63 cmSystemTools::ReplaceString(man_text, "-", "\\-");
66 void cmDocumentationFormatterMan::PrintPreformatted(std::ostream& os,
67 const char* text)
69 std::string man_text = text;
70 this->EscapeText(man_text);
71 os << ".nf\n" << man_text;
72 if (*text && man_text.at(man_text.length()-1) != '\n')
73 os << "\n";
74 os << ".fi\n\n";
77 void cmDocumentationFormatterMan::PrintParagraph(std::ostream& os,
78 const char* text)
80 std::string man_text = text;
81 this->EscapeText(man_text);
82 os << man_text << "\n\n";
86 //----------------------------------------------------------------------------
87 void cmDocumentationFormatterMan::PrintHeader(const char* docname,
88 const char* appname,
89 std::ostream& os)
91 std::string s_docname(docname), s_appname(appname);
93 this->EscapeText(s_docname);
94 this->EscapeText(s_appname);
95 os << ".TH " << s_docname << " 1 \""
96 << cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
97 << "\" \"" << s_appname
98 << " " << cmVersion::GetCMakeVersion()
99 << "\"\n";