1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDocumentationFormatterMan.cxx,v $
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
§ion
,
37 os
<< ".SH " << name
<< "\n";
40 const std::vector
<cmDocumentationEntry
> &entries
=
42 for(std::vector
<cmDocumentationEntry
>::const_iterator op
= entries
.begin();
43 op
!= entries
.end(); ++op
)
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());
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
,
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')
77 void cmDocumentationFormatterMan::PrintParagraph(std::ostream
& os
,
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
,
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()