| 1 |
/*============================================================================ |
|---|
| 2 |
CMake - Cross Platform Makefile Generator |
|---|
| 3 |
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium |
|---|
| 4 |
|
|---|
| 5 |
Distributed under the OSI-approved BSD License (the "License"); |
|---|
| 6 |
see accompanying file Copyright.txt for details. |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
This software is distributed WITHOUT ANY WARRANTY; without even the |
|---|
| 10 |
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 11 |
See the License for more information. |
|---|
| 12 |
============================================================================*/ |
|---|
| 13 |
|
|---|
| 14 |
// //////////////////////////////////////////////////// |
|---|
| 15 |
// Modified by OSRail Project to create a CodeBlocks |
|---|
| 16 |
// generator for gcc projects. sehenley@comcast.net |
|---|
| 17 |
// /////////////////////////////////////////////////// |
|---|
| 18 |
|
|---|
| 19 |
#include "cmDocumentation.h" |
|---|
| 20 |
|
|---|
| 21 |
#include "cmSystemTools.h" |
|---|
| 22 |
#include "cmVersion.h" |
|---|
| 23 |
#include <cmsys/Directory.hxx> |
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
//---------------------------------------------------------------------------- |
|---|
| 27 |
static const char *cmDocumentationStandardOptions[][3] = |
|---|
| 28 |
{ |
|---|
| 29 |
{"--copyright [file]", "Print the CMake copyright and exit.", |
|---|
| 30 |
"If a file is specified, the copyright is written into it."}, |
|---|
| 31 |
{"--help", "Print usage information and exit.", |
|---|
| 32 |
"Usage describes the basic command line interface and its options."}, |
|---|
| 33 |
{"--help-full [file]", "Print full help and exit.", |
|---|
| 34 |
"Full help displays most of the documentation provided by the UNIX " |
|---|
| 35 |
"man page. It is provided for use on non-UNIX platforms, but is " |
|---|
| 36 |
"also convenient if the man page is not installed. If a file is " |
|---|
| 37 |
"specified, the help is written into it."}, |
|---|
| 38 |
{"--help-html [file]", "Print full help in HTML format.", |
|---|
| 39 |
"This option is used by CMake authors to help produce web pages. " |
|---|
| 40 |
"If a file is specified, the help is written into it."}, |
|---|
| 41 |
{"--help-man [file]", "Print full help as a UNIX man page and exit.", |
|---|
| 42 |
"This option is used by the cmake build to generate the UNIX man page. " |
|---|
| 43 |
"If a file is specified, the help is written into it."}, |
|---|
| 44 |
{"--version [file]", "Show program name/version banner and exit.", |
|---|
| 45 |
"If a file is specified, the version is written into it."}, |
|---|
| 46 |
{0,0,0} |
|---|
| 47 |
}; |
|---|
| 48 |
|
|---|
| 49 |
//---------------------------------------------------------------------------- |
|---|
| 50 |
static const char *cmModulesDocumentationDescription[][3] = |
|---|
| 51 |
{ |
|---|
| 52 |
{0, |
|---|
| 53 |
" CMake Modules - Modules coming with CMake, the Cross-Platform Makefile " |
|---|
| 54 |
"Generator.", 0}, |
|---|
| 55 |
// CMAKE_DOCUMENTATION_OVERVIEW, |
|---|
| 56 |
{0, |
|---|
| 57 |
"This is the documentation for the modules and scripts coming with CMake. " |
|---|
| 58 |
"Using these modules you can check the computer system for " |
|---|
| 59 |
"installed software packages, features of the compiler and the " |
|---|
| 60 |
"existance of headers to name just a few.", 0}, |
|---|
| 61 |
{0,0,0} |
|---|
| 62 |
}; |
|---|
| 63 |
|
|---|
| 64 |
//---------------------------------------------------------------------------- |
|---|
| 65 |
static const char *cmCustomModulesDocumentationDescription[][3] = |
|---|
| 66 |
{ |
|---|
| 67 |
{0, |
|---|
| 68 |
" Custom CMake Modules - Additional Modules for CMake.", 0}, |
|---|
| 69 |
// CMAKE_DOCUMENTATION_OVERVIEW, |
|---|
| 70 |
{0, |
|---|
| 71 |
"This is the documentation for additional modules and scripts for CMake. " |
|---|
| 72 |
"Using these modules you can check the computer system for " |
|---|
| 73 |
"installed software packages, features of the compiler and the " |
|---|
| 74 |
"existance of headers to name just a few.", 0}, |
|---|
| 75 |
{0,0,0} |
|---|
| 76 |
}; |
|---|
| 77 |
|
|---|
| 78 |
//---------------------------------------------------------------------------- |
|---|
| 79 |
static const char *cmPropertiesDocumentationDescription[][3] = |
|---|
| 80 |
{ |
|---|
| 81 |
{0, |
|---|
| 82 |
" CMake Properties - Properties supported by CMake, " |
|---|
| 83 |
"the Cross-Platform Makefile Generator.", 0}, |
|---|
| 84 |
// CMAKE_DOCUMENTATION_OVERVIEW, |
|---|
| 85 |
{0, |
|---|
| 86 |
"This is the documentation for the properties supported by CMake. " |
|---|
| 87 |
"Properties can have different scopes. They can either be assigned to a " |
|---|
| 88 |
"source file, a directory, a target or globally to CMake. By modifying the " |
|---|
| 89 |
"values of properties the behaviour of the build system can be customized.", |
|---|
| 90 |
0}, |
|---|
| 91 |
{0,0,0} |
|---|
| 92 |
}; |
|---|
| 93 |
|
|---|
| 94 |
//---------------------------------------------------------------------------- |
|---|
| 95 |
static const char *cmCompatCommandsDocumentationDescription[][3] = |
|---|
| 96 |
{ |
|---|
| 97 |
{0, |
|---|
| 98 |
" CMake Compatibility Listfile Commands - " |
|---|
| 99 |
"Obsolete commands supported by CMake for compatibility.", 0}, |
|---|
| 100 |
// CMAKE_DOCUMENTATION_OVERVIEW, |
|---|
| 101 |
{0, |
|---|
| 102 |
"This is the documentation for now obsolete listfile commands from previous " |
|---|
| 103 |
"CMake versions, which are still supported for compatibility reasons. You " |
|---|
| 104 |
"should instead use the newer, faster and shinier new commands. ;-)", 0}, |
|---|
| 105 |
{0,0,0} |
|---|
| 106 |
}; |
|---|
| 107 |
|
|---|
| 108 |
//---------------------------------------------------------------------------- |
|---|
| 109 |
static const char *cmDocumentationModulesHeader[][3] = |
|---|
| 110 |
{ |
|---|
| 111 |
{0, |
|---|
| 112 |
"The following modules are provided with CMake. " |
|---|
| 113 |
"They can be used with INCLUDE(ModuleName).", 0}, |
|---|
| 114 |
{0,0,0} |
|---|
| 115 |
}; |
|---|
| 116 |
|
|---|
| 117 |
//---------------------------------------------------------------------------- |
|---|
| 118 |
static const char *cmDocumentationCustomModulesHeader[][3] = |
|---|
| 119 |
{ |
|---|
| 120 |
{0, |
|---|
| 121 |
"The following modules are also available for CMake. " |
|---|
| 122 |
"They can be used with INCLUDE(ModuleName).", 0}, |
|---|
| 123 |
{0,0,0} |
|---|
| 124 |
}; |
|---|
| 125 |
|
|---|
| 126 |
//---------------------------------------------------------------------------- |
|---|
| 127 |
static const char *cmDocumentationGeneratorsHeader[][3] = |
|---|
| 128 |
{ |
|---|
| 129 |
{0, |
|---|
| 130 |
"The following generators are available on this platform:", 0}, |
|---|
| 131 |
{0,0,0} |
|---|
| 132 |
}; |
|---|
| 133 |
|
|---|
| 134 |
//---------------------------------------------------------------------------- |
|---|
| 135 |
static const char *cmDocumentationStandardSeeAlso[][3] = |
|---|
| 136 |
{ |
|---|
| 137 |
{0, |
|---|
| 138 |
"The following resources are available to get help using CMake:", 0}, |
|---|
| 139 |
{"Home Page", |
|---|
| 140 |
"http://www.cmake.org", |
|---|
| 141 |
"The primary starting point for learning about CMake."}, |
|---|
| 142 |
{"Frequently Asked Questions", |
|---|
| 143 |
"http://www.cmake.org/Wiki/CMake_FAQ", |
|---|
| 144 |
"A Wiki is provided containing answers to frequently asked questions. "}, |
|---|
| 145 |
{"Online Documentation", |
|---|
| 146 |
"http://www.cmake.org/HTML/Documentation.html", |
|---|
| 147 |
"Links to available documentation may be found on this web page."}, |
|---|
| 148 |
{"Mailing List", |
|---|
| 149 |
"http://www.cmake.org/HTML/MailingLists.html", |
|---|
| 150 |
"For help and discussion about using cmake, a mailing list is provided at " |
|---|
| 151 |
"cmake@cmake.org. " |
|---|
| 152 |
"The list is member-post-only but one may sign up on the CMake web page. " |
|---|
| 153 |
"Please first read the full documentation at " |
|---|
| 154 |
"http://www.cmake.org before posting questions to the list."}, |
|---|
| 155 |
{0, |
|---|
| 156 |
"Summary of helpful links:\n" |
|---|
| 157 |
" Home: http://www.cmake.org\n" |
|---|
| 158 |
" Docs: http://www.cmake.org/HTML/Documentation.html\n" |
|---|
| 159 |
" Mail: http://www.cmake.org/HTML/MailingLists.html\n" |
|---|
| 160 |
" FAQ: http://www.cmake.org/Wiki/CMake_FAQ\n" |
|---|
| 161 |
, 0}, |
|---|
| 162 |
{0,0,0} |
|---|
| 163 |
}; |
|---|
| 164 |
|
|---|
| 165 |
//---------------------------------------------------------------------------- |
|---|
| 166 |
// //////////////////////////////////////////////////// |
|---|
| 167 |
// Modified by OSRail Project to create a CodeBlocks |
|---|
| 168 |
// generator for gcc projects. sehenley@comcast.net |
|---|
| 169 |
// /////////////////////////////////////////////////// |
|---|
| 170 |
|
|---|
| 171 |
static const char *cmDocumentationCopyright[][3] = |
|---|
| 172 |
{ |
|---|
| 173 |
{0, |
|---|
| 174 |
"Copyright 2000-2009 Kitware, Inc., Insight Software Consortium. " |
|---|
| 175 |
"All rights reserved." |
|---|
| 176 |
"This copy of CMake has been modified by OSRail (osrail.net) " //OSRail |
|---|
| 177 |
"to include a CodeBlocks generator. sehenley@comcast.net", 0}, //OSRail |
|---|
| 178 |
{0, |
|---|
| 179 |
"Redistribution and use in source and binary forms, with or without " |
|---|
| 180 |
"modification, are permitted provided that the following conditions are " |
|---|
| 181 |
"met:", 0}, |
|---|
| 182 |
{"", |
|---|
| 183 |
"Redistributions of source code must retain the above copyright notice, " |
|---|
| 184 |
"this list of conditions and the following disclaimer.", 0}, |
|---|
| 185 |
{"", |
|---|
| 186 |
"Redistributions in binary form must reproduce the above copyright " |
|---|
| 187 |
"notice, this list of conditions and the following disclaimer in the " |
|---|
| 188 |
"documentation and/or other materials provided with the distribution.", |
|---|
| 189 |
0}, |
|---|
| 190 |
{"", |
|---|
| 191 |
"Neither the names of Kitware, Inc., the Insight Software Consortium, " |
|---|
| 192 |
"nor the names of their contributors may be used to endorse or promote " |
|---|
| 193 |
"products derived from this software without specific prior written " |
|---|
| 194 |
"permission.", 0}, |
|---|
| 195 |
{0, |
|---|
| 196 |
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS " |
|---|
| 197 |
"\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT " |
|---|
| 198 |
"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR " |
|---|
| 199 |
"A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT " |
|---|
| 200 |
"HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, " |
|---|
| 201 |
"SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT " |
|---|
| 202 |
"LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, " |
|---|
| 203 |
"DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY " |
|---|
| 204 |
"THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT " |
|---|
| 205 |
"(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE " |
|---|
| 206 |
"OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", |
|---|
| 207 |
0}, |
|---|
| 208 |
{0, 0, 0} |
|---|
| 209 |
}; |
|---|
| 210 |
|
|---|
| 211 |
//---------------------------------------------------------------------------- |
|---|
| 212 |
#define DOCUMENT_INTRO(type, default_name, desc) \ |
|---|
| 213 |
static char const *cmDocumentation##type##Intro[2] = { default_name, desc }; |
|---|
| 214 |
#define GET_DOCUMENT_INTRO(type) cmDocumentation##type##Intro |
|---|
| 215 |
|
|---|
| 216 |
DOCUMENT_INTRO(Modules, "cmakemodules", |
|---|
| 217 |
"Reference of available CMake modules."); |
|---|
| 218 |
DOCUMENT_INTRO(CustomModules, "cmakecustommodules", |
|---|
| 219 |
"Reference of available CMake custom modules."); |
|---|
| 220 |
DOCUMENT_INTRO(Policies, "cmakepolicies", |
|---|
| 221 |
"Reference of CMake policies."); |
|---|
| 222 |
DOCUMENT_INTRO(Properties, "cmakeprops", |
|---|
| 223 |
"Reference of CMake properties."); |
|---|
| 224 |
DOCUMENT_INTRO(Variables, "cmakevars", |
|---|
| 225 |
"Reference of CMake variables."); |
|---|
| 226 |
DOCUMENT_INTRO(Commands, "cmakecommands", |
|---|
| 227 |
"Reference of available CMake commands."); |
|---|
| 228 |
DOCUMENT_INTRO(CompatCommands, "cmakecompat", |
|---|
| 229 |
"Reference of CMake compatibility commands."); |
|---|
| 230 |
|
|---|
| 231 |
//---------------------------------------------------------------------------- |
|---|
| 232 |
cmDocumentation::cmDocumentation() |
|---|
| 233 |
:CurrentFormatter(0) |
|---|
| 234 |
{ |
|---|
| 235 |
this->SetForm(TextForm); |
|---|
| 236 |
|
|---|
| 237 |
cmDocumentationSection *sec; |
|---|
| 238 |
|
|---|
| 239 |
sec = new cmDocumentationSection("Author","AUTHOR"); |
|---|
| 240 |
sec->Append(cmDocumentationEntry |
|---|
| 241 |
(0, |
|---|
| 242 |
"This manual page was generated by the \"--help-man\" option.", |
|---|
| 243 |
0)); |
|---|
| 244 |
this->AllSections["Author"] = sec; |
|---|
| 245 |
|
|---|
| 246 |
sec = new cmDocumentationSection("Copyright","COPYRIGHT"); |
|---|
| 247 |
sec->Append(cmDocumentationCopyright); |
|---|
| 248 |
this->AllSections["Copyright"] = sec; |
|---|
| 249 |
|
|---|
| 250 |
sec = new cmDocumentationSection("See Also","SEE ALSO"); |
|---|
| 251 |
sec->Append(cmDocumentationStandardSeeAlso); |
|---|
| 252 |
this->AllSections["Standard See Also"] = sec; |
|---|
| 253 |
|
|---|
| 254 |
sec = new cmDocumentationSection("Options","OPTIONS"); |
|---|
| 255 |
sec->Append(cmDocumentationStandardOptions); |
|---|
| 256 |
this->AllSections["Options"] = sec; |
|---|
| 257 |
|
|---|
| 258 |
sec = new cmDocumentationSection("Properties","PROPERTIES"); |
|---|
| 259 |
sec->Append(cmPropertiesDocumentationDescription); |
|---|
| 260 |
this->AllSections["Properties Description"] = sec; |
|---|
| 261 |
|
|---|
| 262 |
sec = new cmDocumentationSection("Generators","GENERATORS"); |
|---|
| 263 |
sec->Append(cmDocumentationGeneratorsHeader); |
|---|
| 264 |
this->AllSections["Generators"] = sec; |
|---|
| 265 |
|
|---|
| 266 |
sec = new cmDocumentationSection("Compatibility Commands", |
|---|
| 267 |
"COMPATIBILITY COMMANDS"); |
|---|
| 268 |
sec->Append(cmCompatCommandsDocumentationDescription); |
|---|
| 269 |
this->AllSections["Compatibility Commands"] = sec; |
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
this->PropertySections.push_back("Properties of Global Scope"); |
|---|
| 273 |
this->PropertySections.push_back("Properties on Directories"); |
|---|
| 274 |
this->PropertySections.push_back("Properties on Targets"); |
|---|
| 275 |
this->PropertySections.push_back("Properties on Tests"); |
|---|
| 276 |
this->PropertySections.push_back("Properties on Source Files"); |
|---|
| 277 |
this->PropertySections.push_back("Properties on Cache Entries"); |
|---|
| 278 |
|
|---|
| 279 |
this->VariableSections.push_back("Variables that Provide Information"); |
|---|
| 280 |
this->VariableSections.push_back("Variables That Change Behavior"); |
|---|
| 281 |
this->VariableSections.push_back("Variables That Describe the System"); |
|---|
| 282 |
this->VariableSections.push_back("Variables that Control the Build"); |
|---|
| 283 |
this->VariableSections.push_back("Variables for Languages"); |
|---|
| 284 |
|
|---|
| 285 |
this->ShowGenerators = true; |
|---|
| 286 |
} |
|---|
| 287 |
|
|---|
| 288 |
//---------------------------------------------------------------------------- |
|---|
| 289 |
cmDocumentation::~cmDocumentation() |
|---|
| 290 |
{ |
|---|
| 291 |
for(std::vector< char* >::iterator i = this->ModuleStrings.begin(); |
|---|
| 292 |
i != this->ModuleStrings.end(); ++i) |
|---|
| 293 |
{ |
|---|
| 294 |
delete [] *i; |
|---|
| 295 |
} |
|---|
| 296 |
for(std::map<std::string,cmDocumentationSection *>::iterator i = |
|---|
| 297 |
this->AllSections.begin(); |
|---|
| 298 |
i != this->AllSections.end(); ++i) |
|---|
| 299 |
{ |
|---|
| 300 |
delete i->second; |
|---|
| 301 |
} |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
//---------------------------------------------------------------------------- |
|---|
| 305 |
bool cmDocumentation::PrintCopyright(std::ostream& os) |
|---|
| 306 |
{ |
|---|
| 307 |
cmDocumentationSection *sec = this->AllSections["Copyright"]; |
|---|
| 308 |
const std::vector<cmDocumentationEntry> &entries = sec->GetEntries(); |
|---|
| 309 |
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin(); |
|---|
| 310 |
op != entries.end(); ++op) |
|---|
| 311 |
{ |
|---|
| 312 |
if(op->Name.size()) |
|---|
| 313 |
{ |
|---|
| 314 |
os << " * "; |
|---|
| 315 |
this->TextFormatter.SetIndent(" "); |
|---|
| 316 |
this->TextFormatter.PrintColumn(os, op->Brief.c_str()); |
|---|
| 317 |
} |
|---|
| 318 |
else |
|---|
| 319 |
{ |
|---|
| 320 |
this->TextFormatter.SetIndent(""); |
|---|
| 321 |
this->TextFormatter.PrintColumn(os, op->Brief.c_str()); |
|---|
| 322 |
} |
|---|
| 323 |
os << "\n"; |
|---|
| 324 |
} |
|---|
| 325 |
return true; |
|---|
| 326 |
} |
|---|
| 327 |
|
|---|
| 328 |
//---------------------------------------------------------------------------- |
|---|
| 329 |
bool cmDocumentation::PrintVersion(std::ostream& os) |
|---|
| 330 |
{ |
|---|
| 331 |
os << this->GetNameString() << " version " |
|---|
| 332 |
<< cmVersion::GetCMakeVersion() << "\n"; |
|---|
| 333 |
return true; |
|---|
| 334 |
} |
|---|
| 335 |
|
|---|
| 336 |
//---------------------------------------------------------------------------- |
|---|
| 337 |
void cmDocumentation::AddSectionToPrint(const char *section) |
|---|
| 338 |
{ |
|---|
| 339 |
if (this->AllSections.find(section) != this->AllSections.end()) |
|---|
| 340 |
{ |
|---|
| 341 |
this->PrintSections.push_back(this->AllSections[section]); |
|---|
| 342 |
} |
|---|
| 343 |
} |
|---|
| 344 |
|
|---|
| 345 |
//---------------------------------------------------------------------------- |
|---|
| 346 |
void cmDocumentation::ClearSections() |
|---|
| 347 |
{ |
|---|
| 348 |
this->PrintSections.erase(this->PrintSections.begin(), |
|---|
| 349 |
this->PrintSections.end()); |
|---|
| 350 |
this->ModulesFound.clear(); |
|---|
| 351 |
} |
|---|
| 352 |
|
|---|
| 353 |
//---------------------------------------------------------------------------- |
|---|
| 354 |
void cmDocumentation::AddDocumentIntroToPrint(const char* intro[2]) |
|---|
| 355 |
{ |
|---|
| 356 |
const char* docname = this->GetDocName(false); |
|---|
| 357 |
if(intro && docname) |
|---|
| 358 |
{ |
|---|
| 359 |
cmDocumentationSection* section; |
|---|
| 360 |
std::string desc(""); |
|---|
| 361 |
|
|---|
| 362 |
desc += docname; |
|---|
| 363 |
desc += " - "; |
|---|
| 364 |
desc += intro[1]; |
|---|
| 365 |
|
|---|
| 366 |
section = new cmDocumentationSection("Introduction", "NAME"); |
|---|
| 367 |
section->Append(0, desc.c_str(), 0); |
|---|
| 368 |
this->PrintSections.push_back(section); |
|---|
| 369 |
} |
|---|
| 370 |
} |
|---|
| 371 |
|
|---|
| 372 |
//---------------------------------------------------------------------------- |
|---|
| 373 |
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os, |
|---|
| 374 |
const char* docname) |
|---|
| 375 |
{ |
|---|
| 376 |
if ((this->CurrentFormatter->GetForm() != HTMLForm) |
|---|
| 377 |
&& (this->CurrentFormatter->GetForm() != DocbookForm) |
|---|
| 378 |
&& (this->CurrentFormatter->GetForm() != ManForm)) |
|---|
| 379 |
{ |
|---|
| 380 |
this->PrintVersion(os); |
|---|
| 381 |
} |
|---|
| 382 |
|
|---|
| 383 |
// Handle Document Name. docname==0 disables intro. |
|---|
| 384 |
this->SetDocName(""); |
|---|
| 385 |
if (docname) |
|---|
| 386 |
{ |
|---|
| 387 |
if (*docname) |
|---|
| 388 |
this->SetDocName(docname); |
|---|
| 389 |
else // empty string was given. select default if possible |
|---|
| 390 |
this->SetDocName(this->GetDefaultDocName(ht)); |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
switch (ht) |
|---|
| 394 |
{ |
|---|
| 395 |
case cmDocumentation::Usage: |
|---|
| 396 |
return this->PrintDocumentationUsage(os); |
|---|
| 397 |
case cmDocumentation::Single: |
|---|
| 398 |
return this->PrintDocumentationSingle(os); |
|---|
| 399 |
case cmDocumentation::SingleModule: |
|---|
| 400 |
return this->PrintDocumentationSingleModule(os); |
|---|
| 401 |
case cmDocumentation::SinglePolicy: |
|---|
| 402 |
return this->PrintDocumentationSinglePolicy(os); |
|---|
| 403 |
case cmDocumentation::SingleProperty: |
|---|
| 404 |
return this->PrintDocumentationSingleProperty(os); |
|---|
| 405 |
case cmDocumentation::SingleVariable: |
|---|
| 406 |
return this->PrintDocumentationSingleVariable(os); |
|---|
| 407 |
case cmDocumentation::List: |
|---|
| 408 |
this->PrintDocumentationList(os,"Commands"); |
|---|
| 409 |
this->PrintDocumentationList(os,"Compatibility Commands"); |
|---|
| 410 |
return true; |
|---|
| 411 |
case cmDocumentation::ModuleList: |
|---|
| 412 |
// find the modules first, print the custom module docs only if |
|---|
| 413 |
// any custom modules have been found actually, Alex |
|---|
| 414 |
this->CreateCustomModulesSection(); |
|---|
| 415 |
this->CreateModulesSection(); |
|---|
| 416 |
if (this->AllSections.find("Custom CMake Modules") |
|---|
| 417 |
!= this->AllSections.end()) |
|---|
| 418 |
{ |
|---|
| 419 |
this->PrintDocumentationList(os,"Custom CMake Modules"); |
|---|
| 420 |
} |
|---|
| 421 |
this->PrintDocumentationList(os,"Modules"); |
|---|
| 422 |
return true; |
|---|
| 423 |
case cmDocumentation::PropertyList: |
|---|
| 424 |
this->PrintDocumentationList(os,"Properties Description"); |
|---|
| 425 |
for (std::vector<std::string>::iterator i = |
|---|
| 426 |
this->PropertySections.begin(); |
|---|
| 427 |
i != this->PropertySections.end(); ++i) |
|---|
| 428 |
{ |
|---|
| 429 |
this->PrintDocumentationList(os,i->c_str()); |
|---|
| 430 |
} |
|---|
| 431 |
return true; |
|---|
| 432 |
case cmDocumentation::VariableList: |
|---|
| 433 |
for (std::vector<std::string>::iterator i = |
|---|
| 434 |
this->VariableSections.begin(); |
|---|
| 435 |
i != this->VariableSections.end(); ++i) |
|---|
| 436 |
{ |
|---|
| 437 |
this->PrintDocumentationList(os,i->c_str()); |
|---|
| 438 |
} |
|---|
| 439 |
return true; |
|---|
| 440 |
case cmDocumentation::Full: |
|---|
| 441 |
return this->PrintDocumentationFull(os); |
|---|
| 442 |
case cmDocumentation::Modules: |
|---|
| 443 |
return this->PrintDocumentationModules(os); |
|---|
| 444 |
case cmDocumentation::CustomModules: |
|---|
| 445 |
return this->PrintDocumentationCustomModules(os); |
|---|
| 446 |
case cmDocumentation::Policies: |
|---|
| 447 |
return this->PrintDocumentationPolicies(os); |
|---|
| 448 |
case cmDocumentation::Properties: |
|---|
| 449 |
return this->PrintDocumentationProperties(os); |
|---|
| 450 |
case cmDocumentation::Variables: |
|---|
| 451 |
return this->PrintDocumentationVariables(os); |
|---|
| 452 |
case cmDocumentation::Commands: |
|---|
| 453 |
return this->PrintDocumentationCurrentCommands(os); |
|---|
| 454 |
case cmDocumentation::CompatCommands: |
|---|
| 455 |
return this->PrintDocumentationCompatCommands(os); |
|---|
| 456 |
|
|---|
| 457 |
case cmDocumentation::Copyright: |
|---|
| 458 |
return this->PrintCopyright(os); |
|---|
| 459 |
case cmDocumentation::Version: |
|---|
| 460 |
return true; |
|---|
| 461 |
default: return false; |
|---|
| 462 |
} |
|---|
| 463 |
} |
|---|
| 464 |
|
|---|
| 465 |
//---------------------------------------------------------------------------- |
|---|
| 466 |
bool cmDocumentation::CreateModulesSection() |
|---|
| 467 |
{ |
|---|
| 468 |
cmDocumentationSection *sec = |
|---|
| 469 |
new cmDocumentationSection("Standard CMake Modules", "MODULES"); |
|---|
| 470 |
this->AllSections["Modules"] = sec; |
|---|
| 471 |
std::string cmakeModules = this->CMakeRoot; |
|---|
| 472 |
cmakeModules += "/Modules"; |
|---|
| 473 |
cmsys::Directory dir; |
|---|
| 474 |
dir.Load(cmakeModules.c_str()); |
|---|
| 475 |
if (dir.GetNumberOfFiles() > 0) |
|---|
| 476 |
{ |
|---|
| 477 |
sec->Append(cmDocumentationModulesHeader[0]); |
|---|
| 478 |
sec->Append(cmModulesDocumentationDescription); |
|---|
| 479 |
this->CreateModuleDocsForDir(dir, *this->AllSections["Modules"]); |
|---|
| 480 |
} |
|---|
| 481 |
return true; |
|---|
| 482 |
} |
|---|
| 483 |
|
|---|
| 484 |
//---------------------------------------------------------------------------- |
|---|
| 485 |
bool cmDocumentation::CreateCustomModulesSection() |
|---|
| 486 |
{ |
|---|
| 487 |
bool sectionHasHeader = false; |
|---|
| 488 |
|
|---|
| 489 |
std::vector<std::string> dirs; |
|---|
| 490 |
cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs); |
|---|
| 491 |
|
|---|
| 492 |
for(std::vector<std::string>::const_iterator dirIt = dirs.begin(); |
|---|
| 493 |
dirIt != dirs.end(); |
|---|
| 494 |
++dirIt) |
|---|
| 495 |
{ |
|---|
| 496 |
cmsys::Directory dir; |
|---|
| 497 |
dir.Load(dirIt->c_str()); |
|---|
| 498 |
if (dir.GetNumberOfFiles() > 0) |
|---|
| 499 |
{ |
|---|
| 500 |
if (!sectionHasHeader) |
|---|
| 501 |
{ |
|---|
| 502 |
cmDocumentationSection *sec = |
|---|
| 503 |
new cmDocumentationSection("Custom CMake Modules","CUSTOM MODULES"); |
|---|
| 504 |
this->AllSections["Custom CMake Modules"] = sec; |
|---|
| 505 |
sec->Append(cmDocumentationCustomModulesHeader[0]); |
|---|
| 506 |
sec->Append(cmCustomModulesDocumentationDescription); |
|---|
| 507 |
sectionHasHeader = true; |
|---|
| 508 |
} |
|---|
| 509 |
this->CreateModuleDocsForDir |
|---|
| 510 |
(dir, *this->AllSections["Custom CMake Modules"]); |
|---|
| 511 |
} |
|---|
| 512 |
} |
|---|
| 513 |
|
|---|
| 514 |
return true; |
|---|
| 515 |
} |
|---|
| 516 |
|
|---|
| 517 |
//---------------------------------------------------------------------------- |
|---|
| 518 |
void cmDocumentation |
|---|
| 519 |
::CreateModuleDocsForDir(cmsys::Directory& dir, |
|---|
| 520 |
cmDocumentationSection &moduleSection) |
|---|
| 521 |
{ |
|---|
| 522 |
// sort the files alphabetically, so the docs for one module are easier |
|---|
| 523 |
// to find than if they are in random order |
|---|
| 524 |
std::vector<std::string> sortedFiles; |
|---|
| 525 |
for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i) |
|---|
| 526 |
{ |
|---|
| 527 |
sortedFiles.push_back(dir.GetFile(i)); |
|---|
| 528 |
} |
|---|
| 529 |
std::sort(sortedFiles.begin(), sortedFiles.end()); |
|---|
| 530 |
|
|---|
| 531 |
for(std::vector<std::string>::const_iterator fname = sortedFiles.begin(); |
|---|
| 532 |
fname!=sortedFiles.end(); ++fname) |
|---|
| 533 |
{ |
|---|
| 534 |
if(fname->length() > 6) |
|---|
| 535 |
{ |
|---|
| 536 |
if(fname->substr(fname->length()-6, 6) == ".cmake") |
|---|
| 537 |
{ |
|---|
| 538 |
std::string moduleName = fname->substr(0, fname->length()-6); |
|---|
| 539 |
// this check is to avoid creating documentation for the modules with |
|---|
| 540 |
// the same name in multiple directories of CMAKE_MODULE_PATH |
|---|
| 541 |
if (this->ModulesFound.find(moduleName) == this->ModulesFound.end()) |
|---|
| 542 |
{ |
|---|
| 543 |
this->ModulesFound.insert(moduleName); |
|---|
| 544 |
std::string path = dir.GetPath(); |
|---|
| 545 |
path += "/"; |
|---|
| 546 |
path += (*fname); |
|---|
| 547 |
this->CreateSingleModule(path.c_str(), moduleName.c_str(), |
|---|
| 548 |
moduleSection); |
|---|
| 549 |
} |
|---|
| 550 |
} |
|---|
| 551 |
} |
|---|
| 552 |
} |
|---|
| 553 |
} |
|---|
| 554 |
|
|---|
| 555 |
//---------------------------------------------------------------------------- |
|---|
| 556 |
bool cmDocumentation::CreateSingleModule(const char* fname, |
|---|
| 557 |
const char* moduleName, |
|---|
| 558 |
cmDocumentationSection &moduleSection) |
|---|
| 559 |
{ |
|---|
| 560 |
std::ifstream fin(fname); |
|---|
| 561 |
if(!fin) |
|---|
| 562 |
{ |
|---|
| 563 |
std::cerr << "Internal error: can not open module." << fname << std::endl; |
|---|
| 564 |
return false; |
|---|
| 565 |
} |
|---|
| 566 |
std::string line; |
|---|
| 567 |
std::string text; |
|---|
| 568 |
std::string brief; |
|---|
| 569 |
brief = " "; |
|---|
| 570 |
bool newParagraph = true; |
|---|
| 571 |
while ( fin && cmSystemTools::GetLineFromStream(fin, line) ) |
|---|
| 572 |
{ |
|---|
| 573 |
if(line.size() && line[0] == '#') |
|---|
| 574 |
{ |
|---|
| 575 |
// blank line |
|---|
| 576 |
if(line.size() <= 2) |
|---|
| 577 |
{ |
|---|
| 578 |
text += "\n"; |
|---|
| 579 |
newParagraph = true; |
|---|
| 580 |
} |
|---|
| 581 |
else if(line[2] == '-') |
|---|
| 582 |
{ |
|---|
| 583 |
brief = line.c_str()+4; |
|---|
| 584 |
} |
|---|
| 585 |
else |
|---|
| 586 |
{ |
|---|
| 587 |
// two spaces |
|---|
| 588 |
if(line[1] == ' ' && line[2] == ' ') |
|---|
| 589 |
{ |
|---|
| 590 |
if(!newParagraph) |
|---|
| 591 |
{ |
|---|
| 592 |
text += "\n"; |
|---|
| 593 |
newParagraph = true; |
|---|
| 594 |
} |
|---|
| 595 |
// Skip #, and leave space for preformatted |
|---|
| 596 |
text += line.c_str()+1; |
|---|
| 597 |
text += "\n"; |
|---|
| 598 |
} |
|---|
| 599 |
else if(line[1] == ' ') |
|---|
| 600 |
{ |
|---|
| 601 |
if(!newParagraph) |
|---|
| 602 |
{ |
|---|
| 603 |
text += " "; |
|---|
| 604 |
} |
|---|
| 605 |
newParagraph = false; |
|---|
| 606 |
// skip # and space |
|---|
| 607 |
text += line.c_str()+2; |
|---|
| 608 |
} |
|---|
| 609 |
else |
|---|
| 610 |
{ |
|---|
| 611 |
if(!newParagraph) |
|---|
| 612 |
{ |
|---|
| 613 |
text += " "; |
|---|
| 614 |
} |
|---|
| 615 |
newParagraph = false; |
|---|
| 616 |
// skip # |
|---|
| 617 |
text += line.c_str()+1; |
|---|
| 618 |
} |
|---|
| 619 |
} |
|---|
| 620 |
} |
|---|
| 621 |
else |
|---|
| 622 |
{ |
|---|
| 623 |
if(text.length() < 2 && brief.length() == 1) |
|---|
| 624 |
{ |
|---|
| 625 |
return false; |
|---|
| 626 |
} |
|---|
| 627 |
char* pname = strcpy(new char[strlen(moduleName)+1], moduleName); |
|---|
| 628 |
char* ptext = strcpy(new char[text.length()+1], text.c_str()); |
|---|
| 629 |
this->ModuleStrings.push_back(pname); |
|---|
| 630 |
this->ModuleStrings.push_back(ptext); |
|---|
| 631 |
char* pbrief = strcpy(new char[brief.length()+1], brief.c_str()); |
|---|
| 632 |
this->ModuleStrings.push_back(pbrief); |
|---|
| 633 |
moduleSection.Append(pname, pbrief, ptext); |
|---|
| 634 |
return true; |
|---|
| 635 |
} |
|---|
| 636 |
} |
|---|
| 637 |
return true; |
|---|
| 638 |
} |
|---|
| 639 |
|
|---|
| 640 |
|
|---|
| 641 |
//---------------------------------------------------------------------------- |
|---|
| 642 |
bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os) |
|---|
| 643 |
{ |
|---|
| 644 |
bool result = true; |
|---|
| 645 |
|
|---|
| 646 |
// Loop over requested documentation types. |
|---|
| 647 |
for(std::vector<RequestedHelpItem>::const_iterator |
|---|
| 648 |
i = this->RequestedHelpItems.begin(); |
|---|
| 649 |
i != this->RequestedHelpItems.end(); |
|---|
| 650 |
++i) |
|---|
| 651 |
{ |
|---|
| 652 |
this->SetForm(i->HelpForm); |
|---|
| 653 |
this->CurrentArgument = i->Argument; |
|---|
| 654 |
// If a file name was given, use it. Otherwise, default to the |
|---|
| 655 |
// given stream. |
|---|
| 656 |
std::ofstream* fout = 0; |
|---|
| 657 |
std::ostream* s = &os; |
|---|
| 658 |
std::string docname(""); |
|---|
| 659 |
if(i->Filename.length() > 0) |
|---|
| 660 |
{ |
|---|
| 661 |
fout = new std::ofstream(i->Filename.c_str(), std::ios::out); |
|---|
| 662 |
if(fout) |
|---|
| 663 |
{ |
|---|
| 664 |
s = fout; |
|---|
| 665 |
} |
|---|
| 666 |
else |
|---|
| 667 |
{ |
|---|
| 668 |
result = false; |
|---|
| 669 |
} |
|---|
| 670 |
if(i->Filename != "-") |
|---|
| 671 |
{ |
|---|
| 672 |
docname = cmSystemTools::GetFilenameWithoutLastExtension(i->Filename); |
|---|
| 673 |
} |
|---|
| 674 |
} |
|---|
| 675 |
|
|---|
| 676 |
// Print this documentation type to the stream. |
|---|
| 677 |
if(!this->PrintDocumentation(i->HelpType, *s, docname.c_str()) || !*s) |
|---|
| 678 |
{ |
|---|
| 679 |
result = false; |
|---|
| 680 |
} |
|---|
| 681 |
|
|---|
| 682 |
// Close the file if we wrote one. |
|---|
| 683 |
if(fout) |
|---|
| 684 |
{ |
|---|
| 685 |
delete fout; |
|---|
| 686 |
} |
|---|
| 687 |
} |
|---|
| 688 |
return result; |
|---|
| 689 |
} |
|---|
| 690 |
|
|---|
| 691 |
#define GET_OPT_ARGUMENT(target) \ |
|---|
| 692 |
if((i+1 < argc) && !this->IsOption(argv[i+1])) \ |
|---|
| 693 |
{ \ |
|---|
| 694 |
target = argv[i+1]; \ |
|---|
| 695 |
i = i+1; \ |
|---|
| 696 |
}; |
|---|
| 697 |
|
|---|
| 698 |
|
|---|
| 699 |
cmDocumentation::Form cmDocumentation::GetFormFromFilename( |
|---|
| 700 |
const std::string& filename) |
|---|
| 701 |
{ |
|---|
| 702 |
std::string ext = cmSystemTools::GetFilenameLastExtension(filename); |
|---|
| 703 |
ext = cmSystemTools::UpperCase(ext); |
|---|
| 704 |
if ((ext == ".HTM") || (ext == ".HTML")) |
|---|
| 705 |
{ |
|---|
| 706 |
return cmDocumentation::HTMLForm; |
|---|
| 707 |
} |
|---|
| 708 |
|
|---|
| 709 |
if (ext == ".DOCBOOK") |
|---|
| 710 |
{ |
|---|
| 711 |
return cmDocumentation::DocbookForm; |
|---|
| 712 |
} |
|---|
| 713 |
|
|---|
| 714 |
// ".1" to ".9" should be manpages |
|---|
| 715 |
if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9')) |
|---|
| 716 |
{ |
|---|
| 717 |
return cmDocumentation::ManForm; |
|---|
| 718 |
} |
|---|
| 719 |
|
|---|
| 720 |
return cmDocumentation::TextForm; |
|---|
| 721 |
} |
|---|
| 722 |
|
|---|
| 723 |
//---------------------------------------------------------------------------- |
|---|
| 724 |
bool cmDocumentation::CheckOptions(int argc, const char* const* argv, |
|---|
| 725 |
const char* exitOpt) |
|---|
| 726 |
{ |
|---|
| 727 |
// Providing zero arguments gives usage information. |
|---|
| 728 |
if(argc == 1) |
|---|
| 729 |
{ |
|---|
| 730 |
RequestedHelpItem help; |
|---|
| 731 |
help.HelpType = cmDocumentation::Usage; |
|---|
| 732 |
help.HelpForm = cmDocumentation::UsageForm; |
|---|
| 733 |
this->RequestedHelpItems.push_back(help); |
|---|
| 734 |
return true; |
|---|
| 735 |
} |
|---|
| 736 |
|
|---|
| 737 |
// Search for supported help options. |
|---|
| 738 |
|
|---|
| 739 |
bool result = false; |
|---|
| 740 |
for(int i=1; i < argc; ++i) |
|---|
| 741 |
{ |
|---|
| 742 |
if(exitOpt && strcmp(argv[i], exitOpt) == 0) |
|---|
| 743 |
{ |
|---|
| 744 |
return result; |
|---|
| 745 |
} |
|---|
| 746 |
RequestedHelpItem help; |
|---|
| 747 |
// Check if this is a supported help option. |
|---|
| 748 |
if((strcmp(argv[i], "-help") == 0) || |
|---|
| 749 |
(strcmp(argv[i], "--help") == 0) || |
|---|
| 750 |
(strcmp(argv[i], "/?") == 0) || |
|---|
| 751 |
(strcmp(argv[i], "-usage") == 0) || |
|---|
| 752 |
(strcmp(argv[i], "-h") == 0) || |
|---|
| 753 |
(strcmp(argv[i], "-H") == 0)) |
|---|
| 754 |
{ |
|---|
| 755 |
help.HelpType = cmDocumentation::Usage; |
|---|
| 756 |
help.HelpForm = cmDocumentation::UsageForm; |
|---|
| 757 |
GET_OPT_ARGUMENT(help.Argument); |
|---|
| 758 |
help.Argument = cmSystemTools::LowerCase(help.Argument); |
|---|
| 759 |
// special case for single command |
|---|
| 760 |
if (!help.Argument.empty()) |
|---|
| 761 |
{ |
|---|
| 762 |
help.HelpType = cmDocumentation::Single; |
|---|
| 763 |
} |
|---|
| 764 |
} |
|---|
| 765 |
else if(strcmp(argv[i], "--help-properties") == 0) |
|---|
| 766 |
{ |
|---|
| 767 |
help.HelpType = cmDocumentation::Properties; |
|---|
| 768 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 769 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 770 |
} |
|---|
| 771 |
else if(strcmp(argv[i], "--help-policies") == 0) |
|---|
| 772 |
{ |
|---|
| 773 |
help.HelpType = cmDocumentation::Policies; |
|---|
| 774 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 775 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 776 |
} |
|---|
| 777 |
else if(strcmp(argv[i], "--help-variables") == 0) |
|---|
| 778 |
{ |
|---|
| 779 |
help.HelpType = cmDocumentation::Variables; |
|---|
| 780 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 781 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 782 |
} |
|---|
| 783 |
else if(strcmp(argv[i], "--help-modules") == 0) |
|---|
| 784 |
{ |
|---|
| 785 |
help.HelpType = cmDocumentation::Modules; |
|---|
| 786 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 787 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 788 |
} |
|---|
| 789 |
else if(strcmp(argv[i], "--help-custom-modules") == 0) |
|---|
| 790 |
{ |
|---|
| 791 |
help.HelpType = cmDocumentation::CustomModules; |
|---|
| 792 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 793 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 794 |
} |
|---|
| 795 |
else if(strcmp(argv[i], "--help-commands") == 0) |
|---|
| 796 |
{ |
|---|
| 797 |
help.HelpType = cmDocumentation::Commands; |
|---|
| 798 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 799 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 800 |
} |
|---|
| 801 |
else if(strcmp(argv[i], "--help-compatcommands") == 0) |
|---|
| 802 |
{ |
|---|
| 803 |
help.HelpType = cmDocumentation::CompatCommands; |
|---|
| 804 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 805 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 806 |
} |
|---|
| 807 |
else if(strcmp(argv[i], "--help-full") == 0) |
|---|
| 808 |
{ |
|---|
| 809 |
help.HelpType = cmDocumentation::Full; |
|---|
| 810 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 811 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 812 |
} |
|---|
| 813 |
else if(strcmp(argv[i], "--help-html") == 0) |
|---|
| 814 |
{ |
|---|
| 815 |
help.HelpType = cmDocumentation::Full; |
|---|
| 816 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 817 |
help.HelpForm = cmDocumentation::HTMLForm; |
|---|
| 818 |
} |
|---|
| 819 |
else if(strcmp(argv[i], "--help-man") == 0) |
|---|
| 820 |
{ |
|---|
| 821 |
help.HelpType = cmDocumentation::Full; |
|---|
| 822 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 823 |
help.HelpForm = cmDocumentation::ManForm; |
|---|
| 824 |
} |
|---|
| 825 |
else if(strcmp(argv[i], "--help-command") == 0) |
|---|
| 826 |
{ |
|---|
| 827 |
help.HelpType = cmDocumentation::Single; |
|---|
| 828 |
GET_OPT_ARGUMENT(help.Argument); |
|---|
| 829 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 830 |
help.Argument = cmSystemTools::LowerCase(help.Argument); |
|---|
| 831 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 832 |
} |
|---|
| 833 |
else if(strcmp(argv[i], "--help-module") == 0) |
|---|
| 834 |
{ |
|---|
| 835 |
help.HelpType = cmDocumentation::SingleModule; |
|---|
| 836 |
GET_OPT_ARGUMENT(help.Argument); |
|---|
| 837 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 838 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 839 |
} |
|---|
| 840 |
else if(strcmp(argv[i], "--help-property") == 0) |
|---|
| 841 |
{ |
|---|
| 842 |
help.HelpType = cmDocumentation::SingleProperty; |
|---|
| 843 |
GET_OPT_ARGUMENT(help.Argument); |
|---|
| 844 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 845 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 846 |
} |
|---|
| 847 |
else if(strcmp(argv[i], "--help-policy") == 0) |
|---|
| 848 |
{ |
|---|
| 849 |
help.HelpType = cmDocumentation::SinglePolicy; |
|---|
| 850 |
GET_OPT_ARGUMENT(help.Argument); |
|---|
| 851 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 852 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 853 |
} |
|---|
| 854 |
else if(strcmp(argv[i], "--help-variable") == 0) |
|---|
| 855 |
{ |
|---|
| 856 |
help.HelpType = cmDocumentation::SingleVariable; |
|---|
| 857 |
GET_OPT_ARGUMENT(help.Argument); |
|---|
| 858 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 859 |
help.HelpForm = this->GetFormFromFilename(help.Filename); |
|---|
| 860 |
} |
|---|
| 861 |
else if(strcmp(argv[i], "--help-command-list") == 0) |
|---|
| 862 |
{ |
|---|
| 863 |
help.HelpType = cmDocumentation::List; |
|---|
| 864 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 865 |
help.HelpForm = cmDocumentation::TextForm; |
|---|
| 866 |
} |
|---|
| 867 |
else if(strcmp(argv[i], "--help-module-list") == 0) |
|---|
| 868 |
{ |
|---|
| 869 |
help.HelpType = cmDocumentation::ModuleList; |
|---|
| 870 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 871 |
help.HelpForm = cmDocumentation::TextForm; |
|---|
| 872 |
} |
|---|
| 873 |
else if(strcmp(argv[i], "--help-property-list") == 0) |
|---|
| 874 |
{ |
|---|
| 875 |
help.HelpType = cmDocumentation::PropertyList; |
|---|
| 876 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 877 |
help.HelpForm = cmDocumentation::TextForm; |
|---|
| 878 |
} |
|---|
| 879 |
else if(strcmp(argv[i], "--help-variable-list") == 0) |
|---|
| 880 |
{ |
|---|
| 881 |
help.HelpType = cmDocumentation::VariableList; |
|---|
| 882 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 883 |
help.HelpForm = cmDocumentation::TextForm; |
|---|
| 884 |
} |
|---|
| 885 |
else if(strcmp(argv[i], "--copyright") == 0) |
|---|
| 886 |
{ |
|---|
| 887 |
help.HelpType = cmDocumentation::Copyright; |
|---|
| 888 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 889 |
help.HelpForm = cmDocumentation::UsageForm; |
|---|
| 890 |
} |
|---|
| 891 |
else if((strcmp(argv[i], "--version") == 0) || |
|---|
| 892 |
(strcmp(argv[i], "-version") == 0) || |
|---|
| 893 |
(strcmp(argv[i], "/V") == 0)) |
|---|
| 894 |
{ |
|---|
| 895 |
help.HelpType = cmDocumentation::Version; |
|---|
| 896 |
GET_OPT_ARGUMENT(help.Filename); |
|---|
| 897 |
help.HelpForm = cmDocumentation::UsageForm; |
|---|
| 898 |
} |
|---|
| 899 |
if(help.HelpType != None) |
|---|
| 900 |
{ |
|---|
| 901 |
// This is a help option. See if there is a file name given. |
|---|
| 902 |
result = true; |
|---|
| 903 |
this->RequestedHelpItems.push_back(help); |
|---|
| 904 |
} |
|---|
| 905 |
} |
|---|
| 906 |
return result; |
|---|
| 907 |
} |
|---|
| 908 |
|
|---|
| 909 |
//---------------------------------------------------------------------------- |
|---|
| 910 |
void cmDocumentation::Print(Form f, std::ostream& os) |
|---|
| 911 |
{ |
|---|
| 912 |
this->SetForm(f); |
|---|
| 913 |
this->Print(os); |
|---|
| 914 |
} |
|---|
| 915 |
|
|---|
| 916 |
//---------------------------------------------------------------------------- |
|---|
| 917 |
void cmDocumentation::Print(std::ostream& os) |
|---|
| 918 |
{ |
|---|
| 919 |
// if the formatter supports it, print a master index for |
|---|
| 920 |
// all sections |
|---|
| 921 |
this->CurrentFormatter->PrintIndex(os, this->PrintSections); |
|---|
| 922 |
for(unsigned int i=0; i < this->PrintSections.size(); ++i) |
|---|
| 923 |
{ |
|---|
| 924 |
std::string name = this->PrintSections[i]-> |
|---|
| 925 |
GetName((this->CurrentFormatter->GetForm())); |
|---|
| 926 |
this->CurrentFormatter->PrintSection(os,*this->PrintSections[i], |
|---|
| 927 |
name.c_str()); |
|---|
| 928 |
} |
|---|
| 929 |
} |
|---|
| 930 |
|
|---|
| 931 |
//---------------------------------------------------------------------------- |
|---|
| 932 |
void cmDocumentation::SetName(const char* name) |
|---|
| 933 |
{ |
|---|
| 934 |
this->NameString = name?name:""; |
|---|
| 935 |
} |
|---|
| 936 |
|
|---|
| 937 |
//---------------------------------------------------------------------------- |
|---|
| 938 |
void cmDocumentation::SetDocName(const char *docname) |
|---|
| 939 |
{ |
|---|
| 940 |
this->DocName = docname?docname:""; |
|---|
| 941 |
} |
|---|
| 942 |
|
|---|
| 943 |
//---------------------------------------------------------------------------- |
|---|
| 944 |
void cmDocumentation::SetSection(const char *name, |
|---|
| 945 |
cmDocumentationSection *section) |
|---|
| 946 |
{ |
|---|
| 947 |
if (this->AllSections.find(name) != this->AllSections.end()) |
|---|
| 948 |
{ |
|---|
| 949 |
delete this->AllSections[name]; |
|---|
| 950 |
} |
|---|
| 951 |
this->AllSections[name] = section; |
|---|
| 952 |
} |
|---|
| 953 |
|
|---|
| 954 |
//---------------------------------------------------------------------------- |
|---|
| 955 |
void cmDocumentation::SetSection(const char *name, |
|---|
| 956 |
std::vector<cmDocumentationEntry> &docs) |
|---|
| 957 |
{ |
|---|
| 958 |
cmDocumentationSection *sec = |
|---|
| 959 |
new cmDocumentationSection(name, |
|---|
| 960 |
cmSystemTools::UpperCase(name).c_str()); |
|---|
| 961 |
sec->Append(docs); |
|---|
| 962 |
this->SetSection(name,sec); |
|---|
| 963 |
} |
|---|
| 964 |
|
|---|
| 965 |
//---------------------------------------------------------------------------- |
|---|
| 966 |
void cmDocumentation::SetSection(const char *name, |
|---|
| 967 |
const char *docs[][3]) |
|---|
| 968 |
{ |
|---|
| 969 |
cmDocumentationSection *sec = |
|---|
| 970 |
new cmDocumentationSection(name, |
|---|
| 971 |
cmSystemTools::UpperCase(name).c_str()); |
|---|
| 972 |
sec->Append(docs); |
|---|
| 973 |
this->SetSection(name,sec); |
|---|
| 974 |
} |
|---|
| 975 |
|
|---|
| 976 |
//---------------------------------------------------------------------------- |
|---|
| 977 |
void cmDocumentation |
|---|
| 978 |
::SetSections(std::map<std::string,cmDocumentationSection *> §ions) |
|---|
| 979 |
{ |
|---|
| 980 |
for (std::map<std::string,cmDocumentationSection *>::const_iterator |
|---|
| 981 |
it = sections.begin(); it != sections.end(); ++it) |
|---|
| 982 |
{ |
|---|
| 983 |
this->SetSection(it->first.c_str(),it->second); |
|---|
| 984 |
} |
|---|
| 985 |
} |
|---|
| 986 |
|
|---|
| 987 |
//---------------------------------------------------------------------------- |
|---|
| 988 |
void cmDocumentation::PrependSection(const char *name, |
|---|
| 989 |
const char *docs[][3]) |
|---|
| 990 |
{ |
|---|
| 991 |
cmDocumentationSection *sec = 0; |
|---|
| 992 |
if (this->AllSections.find(name) == this->AllSections.end()) |
|---|
| 993 |
{ |
|---|
| 994 |
sec = new cmDocumentationSection |
|---|
| 995 |
(name, cmSystemTools::UpperCase(name).c_str()); |
|---|
| 996 |
this->SetSection(name,sec); |
|---|
| 997 |
} |
|---|
| 998 |
else |
|---|
| 999 |
{ |
|---|
| 1000 |
sec = this->AllSections[name]; |
|---|
| 1001 |
} |
|---|
| 1002 |
sec->Prepend(docs); |
|---|
| 1003 |
} |
|---|
| 1004 |
|
|---|
| 1005 |
//---------------------------------------------------------------------------- |
|---|
| 1006 |
void cmDocumentation::PrependSection(const char *name, |
|---|
| 1007 |
std::vector<cmDocumentationEntry> &docs) |
|---|
| 1008 |
{ |
|---|
| 1009 |
cmDocumentationSection *sec = 0; |
|---|
| 1010 |
if (this->AllSections.find(name) == this->AllSections.end()) |
|---|
| 1011 |
{ |
|---|
| 1012 |
sec = new cmDocumentationSection |
|---|
| 1013 |
(name, cmSystemTools::UpperCase(name).c_str()); |
|---|
| 1014 |
this->SetSection(name,sec); |
|---|
| 1015 |
} |
|---|
| 1016 |
else |
|---|
| 1017 |
{ |
|---|
| 1018 |
sec = this->AllSections[name]; |
|---|
| 1019 |
} |
|---|
| 1020 |
sec->Prepend(docs); |
|---|
| 1021 |
} |
|---|
| 1022 |
|
|---|
| 1023 |
//---------------------------------------------------------------------------- |
|---|
| 1024 |
void cmDocumentation::AppendSection(const char *name, |
|---|
| 1025 |
const char *docs[][3]) |
|---|
| 1026 |
{ |
|---|
| 1027 |
cmDocumentationSection *sec = 0; |
|---|
| 1028 |
if (this->AllSections.find(name) == this->AllSections.end()) |
|---|
| 1029 |
{ |
|---|
| 1030 |
sec = new cmDocumentationSection |
|---|
| 1031 |
(name, cmSystemTools::UpperCase(name).c_str()); |
|---|
| 1032 |
this->SetSection(name,sec); |
|---|
| 1033 |
} |
|---|
| 1034 |
else |
|---|
| 1035 |
{ |
|---|
| 1036 |
sec = this->AllSections[name]; |
|---|
| 1037 |
} |
|---|
| 1038 |
sec->Append(docs); |
|---|
| 1039 |
} |
|---|
| 1040 |
|
|---|
| 1041 |
//---------------------------------------------------------------------------- |
|---|
| 1042 |
void cmDocumentation::AppendSection(const char *name, |
|---|
| 1043 |
std::vector<cmDocumentationEntry> &docs) |
|---|
| 1044 |
{ |
|---|
| 1045 |
cmDocumentationSection *sec = 0; |
|---|
| 1046 |
if (this->AllSections.find(name) == this->AllSections.end()) |
|---|
| 1047 |
{ |
|---|
| 1048 |
sec = new cmDocumentationSection |
|---|
| 1049 |
(name, cmSystemTools::UpperCase(name).c_str()); |
|---|
| 1050 |
this->SetSection(name,sec); |
|---|
| 1051 |
} |
|---|
| 1052 |
else |
|---|
| 1053 |
{ |
|---|
| 1054 |
sec = this->AllSections[name]; |
|---|
| 1055 |
} |
|---|
| 1056 |
sec->Append(docs); |
|---|
| 1057 |
} |
|---|
| 1058 |
|
|---|
| 1059 |
//---------------------------------------------------------------------------- |
|---|
| 1060 |
void cmDocumentation::AppendSection(const char *name, |
|---|
| 1061 |
cmDocumentationEntry &docs) |
|---|
| 1062 |
{ |
|---|
| 1063 |
|
|---|
| 1064 |
std::vector<cmDocumentationEntry> docsVec; |
|---|
| 1065 |
docsVec.push_back(docs); |
|---|
| 1066 |
this->AppendSection(name,docsVec); |
|---|
| 1067 |
} |
|---|
| 1068 |
|
|---|
| 1069 |
//---------------------------------------------------------------------------- |
|---|
| 1070 |
void cmDocumentation::PrependSection(const char *name, |
|---|
| 1071 |
cmDocumentationEntry &docs) |
|---|
| 1072 |
{ |
|---|
| 1073 |
|
|---|
| 1074 |
std::vector<cmDocumentationEntry> docsVec; |
|---|
| 1075 |
docsVec.push_back(docs); |
|---|
| 1076 |
this->PrependSection(name,docsVec); |
|---|
| 1077 |
} |
|---|
| 1078 |
|
|---|
| 1079 |
//---------------------------------------------------------------------------- |
|---|
| 1080 |
void cmDocumentation::SetSeeAlsoList(const char *data[][3]) |
|---|
| 1081 |
{ |
|---|
| 1082 |
cmDocumentationSection *sec = |
|---|
| 1083 |
new cmDocumentationSection("See Also", "SEE ALSO"); |
|---|
| 1084 |
this->AllSections["See Also"] = sec; |
|---|
| 1085 |
this->SeeAlsoString = ".B "; |
|---|
| 1086 |
int i = 0; |
|---|
| 1087 |
while(data[i][1]) |
|---|
| 1088 |
{ |
|---|
| 1089 |
this->SeeAlsoString += data[i][1]; |
|---|
| 1090 |
this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)"; |
|---|
| 1091 |
++i; |
|---|
| 1092 |
} |
|---|
| 1093 |
sec->Append(0,this->SeeAlsoString.c_str(),0); |
|---|
| 1094 |
sec->Append(cmDocumentationStandardSeeAlso); |
|---|
| 1095 |
} |
|---|
| 1096 |
|
|---|
| 1097 |
//---------------------------------------------------------------------------- |
|---|
| 1098 |
bool cmDocumentation::PrintDocumentationGeneric(std::ostream& os, |
|---|
| 1099 |
const char *section) |
|---|
| 1100 |
{ |
|---|
| 1101 |
if(this->AllSections.find(section) == this->AllSections.end()) |
|---|
| 1102 |
{ |
|---|
| 1103 |
os << "Internal error: " << section << " list is empty." << std::endl; |
|---|
| 1104 |
return false; |
|---|
| 1105 |
} |
|---|
| 1106 |
if(this->CurrentArgument.length() == 0) |
|---|
| 1107 |
{ |
|---|
| 1108 |
os << "Required argument missing.\n"; |
|---|
| 1109 |
return false; |
|---|
| 1110 |
} |
|---|
| 1111 |
const std::vector<cmDocumentationEntry> &entries = |
|---|
| 1112 |
this->AllSections[section]->GetEntries(); |
|---|
| 1113 |
for(std::vector<cmDocumentationEntry>::const_iterator ei = |
|---|
| 1114 |
entries.begin(); |
|---|
| 1115 |
ei != entries.end(); ++ei) |
|---|
| 1116 |
{ |
|---|
| 1117 |
if(this->CurrentArgument == ei->Name) |
|---|
| 1118 |
{ |
|---|
| 1119 |
this->PrintDocumentationCommand(os, *ei); |
|---|
| 1120 |
return true; |
|---|
| 1121 |
} |
|---|
| 1122 |
} |
|---|
| 1123 |
return false; |
|---|
| 1124 |
} |
|---|
| 1125 |
|
|---|
| 1126 |
//---------------------------------------------------------------------------- |
|---|
| 1127 |
bool cmDocumentation::PrintDocumentationSingle(std::ostream& os) |
|---|
| 1128 |
{ |
|---|
| 1129 |
if (this->PrintDocumentationGeneric(os,"Commands")) |
|---|
| 1130 |
{ |
|---|
| 1131 |
return true; |
|---|
| 1132 |
} |
|---|
| 1133 |
if (this->PrintDocumentationGeneric(os,"Compatibility Commands")) |
|---|
| 1134 |
{ |
|---|
| 1135 |
return true; |
|---|
| 1136 |
} |
|---|
| 1137 |
|
|---|
| 1138 |
// Argument was not a command. Complain. |
|---|
| 1139 |
os << "Argument \"" << this->CurrentArgument.c_str() |
|---|
| 1140 |
<< "\" to --help-command is not a CMake command. " |
|---|
| 1141 |
<< "Use --help-command-list to see all commands.\n"; |
|---|
| 1142 |
return false; |
|---|
| 1143 |
} |
|---|
| 1144 |
|
|---|
| 1145 |
//---------------------------------------------------------------------------- |
|---|
| 1146 |
bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os) |
|---|
| 1147 |
{ |
|---|
| 1148 |
if(this->CurrentArgument.length() == 0) |
|---|
| 1149 |
{ |
|---|
| 1150 |
os << "Argument --help-module needs a module name.\n"; |
|---|
| 1151 |
return false; |
|---|
| 1152 |
} |
|---|
| 1153 |
|
|---|
| 1154 |
std::string moduleName; |
|---|
| 1155 |
// find the module |
|---|
| 1156 |
std::vector<std::string> dirs; |
|---|
| 1157 |
cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs); |
|---|
| 1158 |
for(std::vector<std::string>::const_iterator dirIt = dirs.begin(); |
|---|
| 1159 |
dirIt != dirs.end(); |
|---|
| 1160 |
++dirIt) |
|---|
| 1161 |
{ |
|---|
| 1162 |
moduleName = *dirIt; |
|---|
| 1163 |
moduleName += "/"; |
|---|
| 1164 |
moduleName += this->CurrentArgument; |
|---|
| 1165 |
moduleName += ".cmake"; |
|---|
| 1166 |
if(cmSystemTools::FileExists(moduleName.c_str())) |
|---|
| 1167 |
{ |
|---|
| 1168 |
break; |
|---|
| 1169 |
} |
|---|
| 1170 |
moduleName = ""; |
|---|
| 1171 |
} |
|---|
| 1172 |
|
|---|
| 1173 |
if (moduleName.empty()) |
|---|
| 1174 |
{ |
|---|
| 1175 |
moduleName = this->CMakeRoot; |
|---|
| 1176 |
moduleName += "/Modules/"; |
|---|
| 1177 |
moduleName += this->CurrentArgument; |
|---|
| 1178 |
moduleName += ".cmake"; |
|---|
| 1179 |
if(!cmSystemTools::FileExists(moduleName.c_str())) |
|---|
| 1180 |
{ |
|---|
| 1181 |
moduleName = ""; |
|---|
| 1182 |
} |
|---|
| 1183 |
} |
|---|
| 1184 |
|
|---|
| 1185 |
if(!moduleName.empty()) |
|---|
| 1186 |
{ |
|---|
| 1187 |
cmDocumentationSection *sec = |
|---|
| 1188 |
new cmDocumentationSection("Standard CMake Modules", "MODULES"); |
|---|
| 1189 |
this->AllSections["Modules"] = sec; |
|---|
| 1190 |
if (this->CreateSingleModule(moduleName.c_str(), |
|---|
| 1191 |
this->CurrentArgument.c_str(), |
|---|
| 1192 |
*this->AllSections["Modules"])) |
|---|
| 1193 |
{ |
|---|
| 1194 |
this->PrintDocumentationCommand |
|---|
| 1195 |
(os, this->AllSections["Modules"]->GetEntries()[0]); |
|---|
| 1196 |
os << "\n Defined in: "; |
|---|
| 1197 |
os << moduleName << "\n"; |
|---|
| 1198 |
return true; |
|---|
| 1199 |
} |
|---|
| 1200 |
} |
|---|
| 1201 |
|
|---|
| 1202 |
// Argument was not a module. Complain. |
|---|
| 1203 |
os << "Argument \"" << this->CurrentArgument.c_str() |
|---|
| 1204 |
<< "\" to --help-module is not a CMake module.\n"; |
|---|
| 1205 |
return false; |
|---|
| 1206 |
} |
|---|
| 1207 |
|
|---|
| 1208 |
//---------------------------------------------------------------------------- |
|---|
| 1209 |
bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os) |
|---|
| 1210 |
{ |
|---|
| 1211 |
bool done = false; |
|---|
| 1212 |
for (std::vector<std::string>::iterator i = |
|---|
| 1213 |
this->PropertySections.begin(); |
|---|
| 1214 |
!done && i != this->PropertySections.end(); ++i) |
|---|
| 1215 |
{ |
|---|
| 1216 |
done = this->PrintDocumentationGeneric(os,i->c_str()); |
|---|
| 1217 |
} |
|---|
| 1218 |
|
|---|
| 1219 |
if (done) |
|---|
| 1220 |
{ |
|---|
| 1221 |
return true; |
|---|
| 1222 |
} |
|---|
| 1223 |
|
|---|
| 1224 |
// Argument was not a command. Complain. |
|---|
| 1225 |
os << "Argument \"" << this->CurrentArgument.c_str() |
|---|
| 1226 |
<< "\" to --help-property is not a CMake property. " |
|---|
| 1227 |
<< "Use --help-property-list to see all properties.\n"; |
|---|
| 1228 |
return false; |
|---|
| 1229 |
} |
|---|
| 1230 |
|
|---|
| 1231 |
//---------------------------------------------------------------------------- |
|---|
| 1232 |
bool cmDocumentation::PrintDocumentationSinglePolicy(std::ostream& os) |
|---|
| 1233 |
{ |
|---|
| 1234 |
if (this->PrintDocumentationGeneric(os,"Policies")) |
|---|
| 1235 |
{ |
|---|
| 1236 |
return true; |
|---|
| 1237 |
} |
|---|
| 1238 |
|
|---|
| 1239 |
// Argument was not a command. Complain. |
|---|
| 1240 |
os << "Argument \"" << this->CurrentArgument.c_str() |
|---|
| 1241 |
<< "\" to --help-policy is not a CMake policy.\n"; |
|---|
| 1242 |
return false; |
|---|
| 1243 |
} |
|---|
| 1244 |
|
|---|
| 1245 |
//---------------------------------------------------------------------------- |
|---|
| 1246 |
bool cmDocumentation::PrintDocumentationSingleVariable(std::ostream& os) |
|---|
| 1247 |
{ |
|---|
| 1248 |
bool done = false; |
|---|
| 1249 |
for (std::vector<std::string>::iterator i = |
|---|
| 1250 |
this->VariableSections.begin(); |
|---|
| 1251 |
!done && i != this->VariableSections.end(); ++i) |
|---|
| 1252 |
{ |
|---|
| 1253 |
done = this->PrintDocumentationGeneric(os,i->c_str()); |
|---|
| 1254 |
} |
|---|
| 1255 |
|
|---|
| 1256 |
if (done) |
|---|
| 1257 |
{ |
|---|
| 1258 |
return true; |
|---|
| 1259 |
} |
|---|
| 1260 |
|
|---|
| 1261 |
// Argument was not a command. Complain. |
|---|
| 1262 |
os << "Argument \"" << this->CurrentArgument.c_str() |
|---|
| 1263 |
<< "\" to --help-variable is not a defined variable. " |
|---|
| 1264 |
<< "Use --help-variable-list to see all defined variables.\n"; |
|---|
| 1265 |
return false; |
|---|
| 1266 |
} |
|---|
| 1267 |
|
|---|
| 1268 |
//---------------------------------------------------------------------------- |
|---|
| 1269 |
bool cmDocumentation::PrintDocumentationList(std::ostream& os, |
|---|
| 1270 |
const char *section) |
|---|
| 1271 |
{ |
|---|
| 1272 |
if(this->AllSections.find(section) == this->AllSections.end()) |
|---|
| 1273 |
{ |
|---|
| 1274 |
os << "Internal error: " << section << " list is empty." << std::endl; |
|---|
| 1275 |
return false; |
|---|
| 1276 |
} |
|---|
| 1277 |
|
|---|
| 1278 |
const std::vector<cmDocumentationEntry> &entries = |
|---|
| 1279 |
this->AllSections[section]->GetEntries(); |
|---|
| 1280 |
for(std::vector<cmDocumentationEntry>::const_iterator ei = |
|---|
| 1281 |
entries.begin(); |
|---|
| 1282 |
ei != entries.end(); ++ei) |
|---|
| 1283 |
{ |
|---|
| 1284 |
if(ei->Name.size()) |
|---|
| 1285 |
{ |
|---|
| 1286 |
os << ei->Name << std::endl; |
|---|
| 1287 |
} |
|---|
| 1288 |
} |
|---|
| 1289 |
return true; |
|---|
| 1290 |
} |
|---|
| 1291 |
|
|---|
| 1292 |
//---------------------------------------------------------------------------- |
|---|
| 1293 |
bool cmDocumentation::PrintDocumentationUsage(std::ostream& os) |
|---|
| 1294 |
{ |
|---|
| 1295 |
this->ClearSections(); |
|---|
| 1296 |
this->AddSectionToPrint("Usage"); |
|---|
| 1297 |
this->AddSectionToPrint("Options"); |
|---|
| 1298 |
if(this->ShowGenerators) |
|---|
| 1299 |
{ |
|---|
| 1300 |
this->AddSectionToPrint("Generators"); |
|---|
| 1301 |
} |
|---|
| 1302 |
this->Print(os); |
|---|
| 1303 |
return true; |
|---|
| 1304 |
} |
|---|
| 1305 |
|
|---|
| 1306 |
//---------------------------------------------------------------------------- |
|---|
| 1307 |
bool cmDocumentation::PrintDocumentationFull(std::ostream& os) |
|---|
| 1308 |
{ |
|---|
| 1309 |
this->CreateFullDocumentation(); |
|---|
| 1310 |
this->CurrentFormatter->PrintHeader(GetNameString(), GetNameString(), os); |
|---|
| 1311 |
this->Print(os); |
|---|
| 1312 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1313 |
return true; |
|---|
| 1314 |
} |
|---|
| 1315 |
|
|---|
| 1316 |
//---------------------------------------------------------------------------- |
|---|
| 1317 |
bool cmDocumentation::PrintDocumentationModules(std::ostream& os) |
|---|
| 1318 |
{ |
|---|
| 1319 |
this->ClearSections(); |
|---|
| 1320 |
this->CreateModulesSection(); |
|---|
| 1321 |
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Modules)); |
|---|
| 1322 |
this->AddSectionToPrint("Description"); |
|---|
| 1323 |
this->AddSectionToPrint("Modules"); |
|---|
| 1324 |
this->AddSectionToPrint("Copyright"); |
|---|
| 1325 |
this->AddSectionToPrint("See Also"); |
|---|
| 1326 |
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); |
|---|
| 1327 |
this->Print(os); |
|---|
| 1328 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1329 |
return true; |
|---|
| 1330 |
} |
|---|
| 1331 |
|
|---|
| 1332 |
//---------------------------------------------------------------------------- |
|---|
| 1333 |
bool cmDocumentation::PrintDocumentationCustomModules(std::ostream& os) |
|---|
| 1334 |
{ |
|---|
| 1335 |
this->ClearSections(); |
|---|
| 1336 |
this->CreateCustomModulesSection(); |
|---|
| 1337 |
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(CustomModules)); |
|---|
| 1338 |
this->AddSectionToPrint("Description"); |
|---|
| 1339 |
this->AddSectionToPrint("Custom CMake Modules"); |
|---|
| 1340 |
// the custom modules are most probably not under Kitware's copyright, Alex |
|---|
| 1341 |
// this->AddSectionToPrint("Copyright"); |
|---|
| 1342 |
this->AddSectionToPrint("See Also"); |
|---|
| 1343 |
|
|---|
| 1344 |
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); |
|---|
| 1345 |
this->Print(os); |
|---|
| 1346 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1347 |
return true; |
|---|
| 1348 |
} |
|---|
| 1349 |
|
|---|
| 1350 |
//---------------------------------------------------------------------------- |
|---|
| 1351 |
bool cmDocumentation::PrintDocumentationPolicies(std::ostream& os) |
|---|
| 1352 |
{ |
|---|
| 1353 |
this->ClearSections(); |
|---|
| 1354 |
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Policies)); |
|---|
| 1355 |
this->AddSectionToPrint("Description"); |
|---|
| 1356 |
this->AddSectionToPrint("Policies"); |
|---|
| 1357 |
this->AddSectionToPrint("Copyright"); |
|---|
| 1358 |
this->AddSectionToPrint("See Also"); |
|---|
| 1359 |
|
|---|
| 1360 |
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); |
|---|
| 1361 |
this->Print(os); |
|---|
| 1362 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1363 |
return true; |
|---|
| 1364 |
} |
|---|
| 1365 |
|
|---|
| 1366 |
//---------------------------------------------------------------------------- |
|---|
| 1367 |
bool cmDocumentation::PrintDocumentationProperties(std::ostream& os) |
|---|
| 1368 |
{ |
|---|
| 1369 |
this->ClearSections(); |
|---|
| 1370 |
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Properties)); |
|---|
| 1371 |
this->AddSectionToPrint("Properties Description"); |
|---|
| 1372 |
for (std::vector<std::string>::iterator i = |
|---|
| 1373 |
this->PropertySections.begin(); |
|---|
| 1374 |
i != this->PropertySections.end(); ++i) |
|---|
| 1375 |
{ |
|---|
| 1376 |
this->AddSectionToPrint(i->c_str()); |
|---|
| 1377 |
} |
|---|
| 1378 |
this->AddSectionToPrint("Copyright"); |
|---|
| 1379 |
this->AddSectionToPrint("Standard See Also"); |
|---|
| 1380 |
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); |
|---|
| 1381 |
this->Print(os); |
|---|
| 1382 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1383 |
return true; |
|---|
| 1384 |
} |
|---|
| 1385 |
|
|---|
| 1386 |
//---------------------------------------------------------------------------- |
|---|
| 1387 |
bool cmDocumentation::PrintDocumentationVariables(std::ostream& os) |
|---|
| 1388 |
{ |
|---|
| 1389 |
this->ClearSections(); |
|---|
| 1390 |
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Variables)); |
|---|
| 1391 |
for (std::vector<std::string>::iterator i = |
|---|
| 1392 |
this->VariableSections.begin(); |
|---|
| 1393 |
i != this->VariableSections.end(); ++i) |
|---|
| 1394 |
{ |
|---|
| 1395 |
this->AddSectionToPrint(i->c_str()); |
|---|
| 1396 |
} |
|---|
| 1397 |
this->AddSectionToPrint("Copyright"); |
|---|
| 1398 |
this->AddSectionToPrint("Standard See Also"); |
|---|
| 1399 |
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); |
|---|
| 1400 |
this->Print(os); |
|---|
| 1401 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1402 |
return true; |
|---|
| 1403 |
} |
|---|
| 1404 |
|
|---|
| 1405 |
//---------------------------------------------------------------------------- |
|---|
| 1406 |
bool cmDocumentation::PrintDocumentationCurrentCommands(std::ostream& os) |
|---|
| 1407 |
{ |
|---|
| 1408 |
this->ClearSections(); |
|---|
| 1409 |
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Commands)); |
|---|
| 1410 |
this->AddSectionToPrint("Commands"); |
|---|
| 1411 |
this->AddSectionToPrint("Copyright"); |
|---|
| 1412 |
this->AddSectionToPrint("Standard See Also"); |
|---|
| 1413 |
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); |
|---|
| 1414 |
this->Print(os); |
|---|
| 1415 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1416 |
return true; |
|---|
| 1417 |
} |
|---|
| 1418 |
|
|---|
| 1419 |
//---------------------------------------------------------------------------- |
|---|
| 1420 |
bool cmDocumentation::PrintDocumentationCompatCommands(std::ostream& os) |
|---|
| 1421 |
{ |
|---|
| 1422 |
this->ClearSections(); |
|---|
| 1423 |
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(CompatCommands)); |
|---|
| 1424 |
this->AddSectionToPrint("Compatibility Commands Description"); |
|---|
| 1425 |
this->AddSectionToPrint("Compatibility Commands"); |
|---|
| 1426 |
this->AddSectionToPrint("Copyright"); |
|---|
| 1427 |
this->AddSectionToPrint("Standard See Also"); |
|---|
| 1428 |
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os); |
|---|
| 1429 |
this->Print(os); |
|---|
| 1430 |
this->CurrentFormatter->PrintFooter(os); |
|---|
| 1431 |
return true; |
|---|
| 1432 |
} |
|---|
| 1433 |
|
|---|
| 1434 |
//---------------------------------------------------------------------------- |
|---|
| 1435 |
void cmDocumentation |
|---|
| 1436 |
::PrintDocumentationCommand(std::ostream& os, |
|---|
| 1437 |
const cmDocumentationEntry &entry) |
|---|
| 1438 |
{ |
|---|
| 1439 |
// the string "SingleItem" will be used in a few places to detect the case |
|---|
| 1440 |
// that only the documentation for a single item is printed |
|---|
| 1441 |
cmDocumentationSection *sec = new cmDocumentationSection("SingleItem",""); |
|---|
| 1442 |
sec->Append(entry); |
|---|
| 1443 |
this->AllSections["temp"] = sec; |
|---|
| 1444 |
this->ClearSections(); |
|---|
| 1445 |
this->AddSectionToPrint("temp"); |
|---|
| 1446 |
this->Print(os); |
|---|
| 1447 |
this->AllSections.erase("temp"); |
|---|
| 1448 |
delete sec; |
|---|
| 1449 |
} |
|---|
| 1450 |
|
|---|
| 1451 |
//---------------------------------------------------------------------------- |
|---|
| 1452 |
void cmDocumentation::CreateFullDocumentation() |
|---|
| 1453 |
{ |
|---|
| 1454 |
this->ClearSections(); |
|---|
| 1455 |
this->CreateCustomModulesSection(); |
|---|
| 1456 |
this->CreateModulesSection(); |
|---|
| 1457 |
|
|---|
| 1458 |
std::set<std::string> emitted; |
|---|
| 1459 |
this->AddSectionToPrint("Name"); |
|---|
| 1460 |
emitted.insert("Name"); |
|---|
| 1461 |
this->AddSectionToPrint("Usage"); |
|---|
| 1462 |
emitted.insert("Usage"); |
|---|
| 1463 |
this->AddSectionToPrint("Description"); |
|---|
| 1464 |
emitted.insert("Description"); |
|---|
| 1465 |
this->AddSectionToPrint("Options"); |
|---|
| 1466 |
emitted.insert("Options"); |
|---|
| 1467 |
this->AddSectionToPrint("Generators"); |
|---|
| 1468 |
emitted.insert("Generators"); |
|---|
| 1469 |
this->AddSectionToPrint("Commands"); |
|---|
| 1470 |
emitted.insert("Commands"); |
|---|
| 1471 |
|
|---|
| 1472 |
|
|---|
| 1473 |
this->AddSectionToPrint("Properties Description"); |
|---|
| 1474 |
emitted.insert("Properties Description"); |
|---|
| 1475 |
for (std::vector<std::string>::iterator i = |
|---|
| 1476 |
this->PropertySections.begin(); |
|---|
| 1477 |
i != this->PropertySections.end(); ++i) |
|---|
| 1478 |
{ |
|---|
| 1479 |
this->AddSectionToPrint(i->c_str()); |
|---|
| 1480 |
emitted.insert(i->c_str()); |
|---|
| 1481 |
} |
|---|
| 1482 |
|
|---|
| 1483 |
emitted.insert("Copyright"); |
|---|
| 1484 |
emitted.insert("See Also"); |
|---|
| 1485 |
emitted.insert("Standard See Also"); |
|---|
| 1486 |
emitted.insert("Author"); |
|---|
| 1487 |
|
|---|
| 1488 |
// add any sections not yet written out, or to be written out |
|---|
| 1489 |
for (std::map<std::string, cmDocumentationSection*>::iterator i = |
|---|
| 1490 |
this->AllSections.begin(); |
|---|
| 1491 |
i != this->AllSections.end(); ++i) |
|---|
| 1492 |
{ |
|---|
| 1493 |
if (emitted.find(i->first) == emitted.end()) |
|---|
| 1494 |
{ |
|---|
| 1495 |
this->AddSectionToPrint(i->first.c_str()); |
|---|
| 1496 |
} |
|---|
| 1497 |
} |
|---|
| 1498 |
|
|---|
| 1499 |
this->AddSectionToPrint("Copyright"); |
|---|
| 1500 |
|
|---|
| 1501 |
if(this->CurrentFormatter->GetForm() == ManForm) |
|---|
| 1502 |
{ |
|---|
| 1503 |
this->AddSectionToPrint("See Also"); |
|---|
| 1504 |
this->AddSectionToPrint("Author"); |
|---|
| 1505 |
} |
|---|
| 1506 |
else |
|---|
| 1507 |
{ |
|---|
| 1508 |
this->AddSectionToPrint("Standard See Also"); |
|---|
| 1509 |
} |
|---|
| 1510 |
} |
|---|
| 1511 |
|
|---|
| 1512 |
//---------------------------------------------------------------------------- |
|---|
| 1513 |
void cmDocumentation::SetForm(Form f) |
|---|
| 1514 |
{ |
|---|
| 1515 |
switch(f) |
|---|
| 1516 |
{ |
|---|
| 1517 |
case HTMLForm: |
|---|
| 1518 |
this->CurrentFormatter = &this->HTMLFormatter; |
|---|
| 1519 |
break; |
|---|
| 1520 |
case DocbookForm: |
|---|
| 1521 |
this->CurrentFormatter = &this->DocbookFormatter; |
|---|
| 1522 |
break; |
|---|
| 1523 |
case ManForm: |
|---|
| 1524 |
this->CurrentFormatter = &this->ManFormatter; |
|---|
| 1525 |
break; |
|---|
| 1526 |
case TextForm: |
|---|
| 1527 |
this->CurrentFormatter = &this->TextFormatter; |
|---|
| 1528 |
break; |
|---|
| 1529 |
case UsageForm: |
|---|
| 1530 |
this->CurrentFormatter = & this->UsageFormatter; |
|---|
| 1531 |
break; |
|---|
| 1532 |
} |
|---|
| 1533 |
} |
|---|
| 1534 |
|
|---|
| 1535 |
|
|---|
| 1536 |
//---------------------------------------------------------------------------- |
|---|
| 1537 |
const char* cmDocumentation::GetNameString() const |
|---|
| 1538 |
{ |
|---|
| 1539 |
if(this->NameString.length() > 0) |
|---|
| 1540 |
{ |
|---|
| 1541 |
return this->NameString.c_str(); |
|---|
| 1542 |
} |
|---|
| 1543 |
else |
|---|
| 1544 |
{ |
|---|
| 1545 |
return "CMake"; |
|---|
| 1546 |
} |
|---|
| 1547 |
} |
|---|
| 1548 |
|
|---|
| 1549 |
//---------------------------------------------------------------------------- |
|---|
| 1550 |
const char* cmDocumentation::GetDocName(bool fallbackToNameString) const |
|---|
| 1551 |
{ |
|---|
| 1552 |
if (this->DocName.length() > 0) |
|---|
| 1553 |
{ |
|---|
| 1554 |
return this->DocName.c_str(); |
|---|
| 1555 |
} |
|---|
| 1556 |
else if (fallbackToNameString) |
|---|
| 1557 |
{ |
|---|
| 1558 |
return this->GetNameString(); |
|---|
| 1559 |
} |
|---|
| 1560 |
else |
|---|
| 1561 |
return 0; |
|---|
| 1562 |
} |
|---|
| 1563 |
|
|---|
| 1564 |
//---------------------------------------------------------------------------- |
|---|
| 1565 |
#define CASE_DEFAULT_DOCNAME(doctype) \ |
|---|
| 1566 |
case cmDocumentation::doctype : \ |
|---|
| 1567 |
return GET_DOCUMENT_INTRO(doctype)[0]; |
|---|
| 1568 |
const char* cmDocumentation::GetDefaultDocName(Type ht) const |
|---|
| 1569 |
{ |
|---|
| 1570 |
switch (ht) |
|---|
| 1571 |
{ |
|---|
| 1572 |
CASE_DEFAULT_DOCNAME(Modules) |
|---|
| 1573 |
CASE_DEFAULT_DOCNAME(CustomModules) |
|---|
| 1574 |
CASE_DEFAULT_DOCNAME(Policies) |
|---|
| 1575 |
CASE_DEFAULT_DOCNAME(Properties) |
|---|
| 1576 |
CASE_DEFAULT_DOCNAME(Variables) |
|---|
| 1577 |
CASE_DEFAULT_DOCNAME(Commands) |
|---|
| 1578 |
CASE_DEFAULT_DOCNAME(CompatCommands) |
|---|
| 1579 |
default: break; |
|---|
| 1580 |
} |
|---|
| 1581 |
return 0; |
|---|
| 1582 |
} |
|---|
| 1583 |
|
|---|
| 1584 |
//---------------------------------------------------------------------------- |
|---|
| 1585 |
bool cmDocumentation::IsOption(const char* arg) const |
|---|
| 1586 |
{ |
|---|
| 1587 |
return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) || |
|---|
| 1588 |
(strcmp(arg, "/?") == 0)); |
|---|
| 1589 |
} |
|---|