summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-02-14 18:28:46 (GMT)
committerBrad King <brad.king@kitware.com>2003-02-14 18:28:46 (GMT)
commit0005e70c054ac55a536ffbc68447b7aa57e909d2 (patch)
tree606ff2bc7599a1a0bdb4436967c6ded38b563581 /Source
parent2c7a05edd21ad6a33c7dffc46e7fec53035d5bb9 (diff)
downloadCMake-0005e70c054ac55a536ffbc68447b7aa57e909d2.zip
CMake-0005e70c054ac55a536ffbc68447b7aa57e909d2.tar.gz
CMake-0005e70c054ac55a536ffbc68447b7aa57e909d2.tar.bz2
ENH: Further improved formatting. HTML/man/help now all have a consistent appearance.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDocumentation.cxx131
-rw-r--r--Source/cmDocumentation.h7
2 files changed, 93 insertions, 45 deletions
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 7971e79..852abed 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -101,7 +101,10 @@ void cmDocumentation::PrintManSection(std::ostream& os,
os << ".TP\n"
<< ".B " << op->name << "\n"
<< op->brief << "\n\n";
- if(op->full) { os << op->full << "\n"; }
+ if(op->full)
+ {
+ this->PrintFull(os, op->full, 0, 0);
+ }
}
else
{
@@ -171,47 +174,11 @@ void cmDocumentation::PrintHTMLEscapes(std::ostream& os, const char* text)
}
//----------------------------------------------------------------------------
-void cmDocumentation::PrintHTMLFull(std::ostream& os, const char* text)
+void cmDocumentation::PrintHTMLPreformatted(std::ostream& os, const char* text)
{
- const char* line = text;
- while(*line)
- {
- // Any lines starting in a space are treated as a preformatted
- // section.
- std::string preformatted;
- while(*line == ' ')
- {
- for(char ch = *line; ch && ch != '\n'; ++line, ch = *line)
- {
- preformatted.append(1, ch);
- }
- if(*line)
- {
- ++line;
- preformatted.append(1, '\n');
- }
- }
- if(preformatted.length())
- {
- os << "<pre>";
- this->PrintHTMLEscapes(os, preformatted.c_str());
- os << "</pre>";
- }
- std::string normal;
- for(char ch = *line; ch && ch != '\n'; ++line, ch = *line)
- {
- normal.append(1, ch);
- }
- if(*line)
- {
- ++line;
- normal.append(1, '\n');
- }
- if(normal.length())
- {
- this->PrintHTMLEscapes(os, normal.c_str());
- }
- }
+ os << "<pre>";
+ cmDocumentation::PrintHTMLEscapes(os, text);
+ os << "</pre>";
}
//----------------------------------------------------------------------------
@@ -239,7 +206,9 @@ void cmDocumentation::PrintHelpHTMLSection(std::ostream& os,
if(op->full)
{
os << "<br>";
- this->PrintHTMLFull(os, op->full);
+ this->PrintFull(os, op->full,
+ &cmDocumentation::PrintHTMLPreformatted,
+ &cmDocumentation::PrintHTMLEscapes);
}
os << "\n";
os << " </li>\n";
@@ -379,7 +348,8 @@ void cmDocumentation::PrintColumn(std::ostream& os, int width,
int column = 0;
bool newSentence = false;
bool firstLine = true;
-
+ bool lastHadBlanks = false;
+
// Count leading blanks in the text.
int blanks = 0;
for(const char* b = l; *b == ' '; ++b) { ++blanks; }
@@ -414,6 +384,22 @@ void cmDocumentation::PrintColumn(std::ostream& os, int width,
}
else
{
+ // If this is the first line not beginning in a blank after
+ // a sequence of lines beginning in blanks, add an extra
+ // newline.
+ if(blanks)
+ {
+ lastHadBlanks = true;
+ }
+ else
+ {
+ if(lastHadBlanks)
+ {
+ os << "\n";
+ }
+ lastHadBlanks = false;
+ }
+
// First word on line. Print indentation unless this is the
// first line.
os << (firstLine?"":indent);
@@ -471,6 +457,65 @@ void cmDocumentation::PrintColumn(std::ostream& os, int width,
}
//----------------------------------------------------------------------------
+void cmDocumentation::PrintFull(std::ostream& os, const char* text,
+ void (*pPreform)(std::ostream&, const char*),
+ void (*pNormal)(std::ostream&, const char*))
+{
+ const char* line = text;
+ while(*line)
+ {
+ // Any lines starting in a space are treated as preformatted text.
+ std::string preformatted;
+ while(*line == ' ')
+ {
+ for(char ch = *line; ch && ch != '\n'; ++line, ch = *line)
+ {
+ preformatted.append(1, ch);
+ }
+ if(*line)
+ {
+ ++line;
+ preformatted.append(1, '\n');
+ }
+ }
+ if(preformatted.length())
+ {
+ if(pPreform)
+ {
+ pPreform(os, preformatted.c_str());
+ }
+ else
+ {
+ os << preformatted << "\n";
+ }
+ }
+
+ // Other lines are treated as normal text.
+ std::string normal;
+ for(char ch = *line; ch && ch != '\n'; ++line, ch = *line)
+ {
+ normal.append(1, ch);
+ }
+ if(*line)
+ {
+ ++line;
+ normal.append(1, '\n');
+ }
+ if(normal.length())
+ {
+ if(pNormal)
+ {
+ pNormal(os, normal.c_str());
+ }
+ else
+ {
+ os << normal << "\n";
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
void cmDocumentation::Print(Type ht, std::ostream& os)
{
switch (ht)
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index 2735143..d32a173 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -48,8 +48,11 @@ private:
void PrintManSection(std::ostream& os, const cmDocumentationEntry* section,
const char* name);
void PrintHelpSection(std::ostream& os, const cmDocumentationEntry* section);
- void PrintHTMLEscapes(std::ostream& os, const char* text);
- void PrintHTMLFull(std::ostream& os, const char* text);
+ static void PrintHTMLEscapes(std::ostream& os, const char* text);
+ static void PrintHTMLPreformatted(std::ostream& os, const char* text);
+ void PrintFull(std::ostream& os, const char* text,
+ void (*pPreform)(std::ostream&, const char*),
+ void (*pNormal)(std::ostream&, const char*));
void PrintHelpHTMLSection(std::ostream& os,
const cmDocumentationEntry* section,
const char* header);