1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDocumentationFormatter.cxx,v $
6 Date: $Date: 2008-07-21 21:52:58 $
7 Version: $Revision: 1.3 $
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 =========================================================================*/
17 #include "cmDocumentationFormatter.h"
19 cmDocumentationFormatter::cmDocumentationFormatter()
23 cmDocumentationFormatter::~cmDocumentationFormatter()
27 void cmDocumentationFormatter::PrintFormatted(std::ostream
& os
,
34 const char* ptr
= text
;
37 // Any ptrs starting in a space are treated as preformatted text.
38 std::string preformatted
;
41 for(char ch
= *ptr
; ch
&& ch
!= '\n'; ++ptr
, ch
= *ptr
)
43 preformatted
.append(1, ch
);
48 preformatted
.append(1, '\n');
51 if(preformatted
.length())
53 this->PrintPreformatted(os
, preformatted
.c_str());
56 // Other ptrs are treated as paragraphs.
57 std::string paragraph
;
58 for(char ch
= *ptr
; ch
&& ch
!= '\n'; ++ptr
, ch
= *ptr
)
60 paragraph
.append(1, ch
);
65 paragraph
.append(1, '\n');
67 if(paragraph
.length())
69 this->PrintParagraph(os
, paragraph
.c_str());
74 //----------------------------------------------------------------------------
76 cmDocumentationFormatter::ComputeSectionLinkPrefix(std::string
const& name
)
78 // Map from section name to a prefix for links pointing within the
79 // section. For example, the commands section should have HTML
80 // links to each command with names like #command:ADD_EXECUTABLE.
81 if(name
.find("Command") != name
.npos
)
85 else if(name
.find("Propert") != name
.npos
)
87 if(name
.find("Global") != name
.npos
)
91 else if(name
.find("Direct") != name
.npos
)
95 else if(name
.find("Target") != name
.npos
)
99 else if(name
.find("Test") != name
.npos
)
103 else if(name
.find("Source") != name
.npos
)
109 else if(name
.find("Variable") != name
.npos
)
113 else if(name
.find("Polic") != name
.npos
)
117 else if(name
.find("Module") != name
.npos
)
121 else if(name
.find("Name") != name
.npos
)
125 else if(name
.find("Usage") != name
.npos
)
129 else if(name
.find("Description") != name
.npos
)
133 else if(name
.find("Generators") != name
.npos
)
137 else if(name
.find("Options") != name
.npos
)
141 else if(name
.find("Copyright") != name
.npos
)
145 else if(name
.find("See Also") != name
.npos
)
149 else if(name
.find("SingleItem") != name
.npos
)
151 return "single_item";
156 << "WARNING: ComputeSectionLinkPrefix failed for \"" << name
<< "\""