Add label summary times to ctest default output. Also, remove parallel time output...
[cmake.git] / Source / cmDocumentationFormatterText.cxx
blob9575c04c8ed11dc4234ce3d71df59e772fbbd9a0
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmDocumentationFormatterText.cxx,v $
5 Language: C++
6 Date: $Date: 2009-06-28 12:05:22 $
7 Version: $Revision: 1.6 $
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 "cmDocumentationFormatterText.h"
19 #include "cmDocumentationSection.h"
21 cmDocumentationFormatterText::cmDocumentationFormatterText()
22 :cmDocumentationFormatter()
23 ,TextWidth(77)
24 ,TextIndent("")
28 void cmDocumentationFormatterText
29 ::PrintSection(std::ostream& os,
30 const cmDocumentationSection &section,
31 const char* name)
33 if(name && (strcmp(name, "SingleItem")!=0))
35 os <<
36 "---------------------------------------"
37 "---------------------------------------\n";
38 os << name << "\n\n";
41 const std::vector<cmDocumentationEntry> &entries =
42 section.GetEntries();
43 for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
44 op != entries.end(); ++op)
46 if(op->Name.size())
48 os << " " << op->Name << "\n";
49 this->TextIndent = " ";
50 this->PrintFormatted(os, op->Brief.c_str());
51 if(op->Full.size())
53 os << "\n";
54 this->PrintFormatted(os, op->Full.c_str());
57 else
59 this->TextIndent = "";
60 this->PrintFormatted(os, op->Brief.c_str());
62 os << "\n";
66 void cmDocumentationFormatterText::PrintPreformatted(std::ostream& os,
67 const char* text)
69 bool newline = true;
70 for(const char* ptr = text; *ptr; ++ptr)
72 if(newline && *ptr != '\n')
74 os << this->TextIndent;
75 newline = false;
77 os << *ptr;
78 if(*ptr == '\n')
80 newline = true;
83 os << "\n";
86 void cmDocumentationFormatterText::PrintParagraph(std::ostream& os,
87 const char* text)
89 os << this->TextIndent;
90 this->PrintColumn(os, text);
91 os << "\n";
94 void cmDocumentationFormatterText::SetIndent(const char* indent)
96 this->TextIndent = indent;
99 void cmDocumentationFormatterText::PrintColumn(std::ostream& os,
100 const char* text)
102 // Print text arranged in an indented column of fixed witdh.
103 const char* l = text;
104 int column = 0;
105 bool newSentence = false;
106 bool firstLine = true;
107 int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent));
109 // Loop until the end of the text.
110 while(*l)
112 // Parse the next word.
113 const char* r = l;
114 while(*r && (*r != '\n') && (*r != ' ')) { ++r; }
116 // Does it fit on this line?
117 if(r-l < (width-column-(newSentence?1:0)))
119 // Word fits on this line.
120 if(r > l)
122 if(column)
124 // Not first word on line. Separate from the previous word
125 // by a space, or two if this is a new sentence.
126 if(newSentence)
128 os << " ";
129 column += 2;
131 else
133 os << " ";
134 column += 1;
137 else
139 // First word on line. Print indentation unless this is the
140 // first line.
141 os << (firstLine?"":this->TextIndent);
144 // Print the word.
145 os.write(l, static_cast<long>(r-l));
146 newSentence = (*(r-1) == '.');
149 if(*r == '\n')
151 // Text provided a newline. Start a new line.
152 os << "\n";
153 ++r;
154 column = 0;
155 firstLine = false;
157 else
159 // No provided newline. Continue this line.
160 column += static_cast<long>(r-l);
163 else
165 // Word does not fit on this line. Start a new line.
166 os << "\n";
167 firstLine = false;
168 if(r > l)
170 os << this->TextIndent;
171 os.write(l, static_cast<long>(r-l));
172 column = static_cast<long>(r-l);
173 newSentence = (*(r-1) == '.');
175 else
177 column = 0;
181 // Move to beginning of next word. Skip over whitespace.
182 l = r;
183 while(*l && (*l == ' ')) { ++l; }