1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmDocumentationFormatter.h"
14 cmDocumentationFormatter::cmDocumentationFormatter()
18 cmDocumentationFormatter::~cmDocumentationFormatter()
22 void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
29 const char* ptr = text;
32 // Any ptrs starting in a space are treated as preformatted text.
33 std::string preformatted;
36 for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
38 preformatted.append(1, ch);
43 preformatted.append(1, '\n');
46 if(preformatted.length())
48 this->PrintPreformatted(os, preformatted.c_str());
51 // Other ptrs are treated as paragraphs.
52 std::string paragraph;
53 for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
55 paragraph.append(1, ch);
60 paragraph.append(1, '\n');
62 if(paragraph.length())
64 this->PrintParagraph(os, paragraph.c_str());
69 //----------------------------------------------------------------------------
71 cmDocumentationFormatter::ComputeSectionLinkPrefix(std::string const& name)
73 // Map from section name to a prefix for links pointing within the
74 // section. For example, the commands section should have HTML
75 // links to each command with names like #command:ADD_EXECUTABLE.
76 if(name.find("Command") != name.npos)
80 else if(name.find("Propert") != name.npos)
82 if(name.find("Global") != name.npos)
86 else if(name.find("Direct") != name.npos)
90 else if(name.find("Target") != name.npos)
94 else if(name.find("Test") != name.npos)
98 else if(name.find("Source") != name.npos)
104 else if(name.find("Variable") != name.npos)
108 else if(name.find("Polic") != name.npos)
112 else if(name.find("Module") != name.npos)
116 else if(name.find("Name") != name.npos ||
117 name.find("Introduction") != name.npos)
121 else if(name.find("Usage") != name.npos)
125 else if(name.find("Description") != name.npos)
129 else if(name.find("Generators") != name.npos)
133 else if(name.find("Options") != name.npos)
137 else if(name.find("Copyright") != name.npos)
141 else if(name.find("See Also") != name.npos)
145 else if(name.find("SingleItem") != name.npos)
147 return "single_item";
152 << "WARNING: ComputeSectionLinkPrefix failed for \"" << name << "\""