2003-02-14 18:53:37 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#include "cmDocumentation.h"
|
|
|
|
|
|
|
|
#include "cmSystemTools.h"
|
2004-10-22 23:44:54 +04:00
|
|
|
#include "cmVersion.h"
|
2005-12-14 21:51:08 +03:00
|
|
|
#include <cmsys/Directory.hxx>
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2007-06-28 19:00:57 +04:00
|
|
|
|
|
|
|
const cmDocumentationEntry cmDocumentation::cmSection::EmptySection ={0,0,0};
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationStandardOptions[] =
|
|
|
|
{
|
2003-08-06 02:10:45 +04:00
|
|
|
{"--copyright [file]", "Print the CMake copyright and exit.",
|
|
|
|
"If a file is specified, the copyright is written into it."},
|
2004-04-14 22:25:43 +04:00
|
|
|
{"--help", "Print usage information and exit.",
|
|
|
|
"Usage describes the basic command line interface and its options."},
|
2003-08-06 02:10:45 +04:00
|
|
|
{"--help-full [file]", "Print full help and exit.",
|
2003-02-14 18:53:37 +03:00
|
|
|
"Full help displays most of the documentation provided by the UNIX "
|
|
|
|
"man page. It is provided for use on non-UNIX platforms, but is "
|
2003-08-06 02:10:45 +04:00
|
|
|
"also convenient if the man page is not installed. If a file is "
|
|
|
|
"specified, the help is written into it."},
|
|
|
|
{"--help-html [file]", "Print full help in HTML format.",
|
|
|
|
"This option is used by CMake authors to help produce web pages. "
|
|
|
|
"If a file is specified, the help is written into it."},
|
2007-06-28 19:00:57 +04:00
|
|
|
{"--help-man [file]", "Print full help as a UNIX man page and exit.",
|
2003-08-06 02:10:45 +04:00
|
|
|
"This option is used by the cmake build to generate the UNIX man page. "
|
|
|
|
"If a file is specified, the help is written into it."},
|
|
|
|
{"--version [file]", "Show program name/version banner and exit.",
|
|
|
|
"If a file is specified, the version is written into it."},
|
2003-02-14 18:53:37 +03:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2007-06-22 16:44:51 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmModulesDocumentationDescription[] =
|
|
|
|
{
|
|
|
|
{0,
|
2007-07-20 16:36:16 +04:00
|
|
|
" CMake Modules - Modules coming with CMake, the Cross-Platform Makefile "
|
|
|
|
"Generator.", 0},
|
2007-06-22 16:44:51 +04:00
|
|
|
// CMAKE_DOCUMENTATION_OVERVIEW,
|
|
|
|
{0,
|
|
|
|
"This is the documentation for the modules and scripts coming with CMake. "
|
|
|
|
"Using these modules you can check the computer system for "
|
|
|
|
"installed software packages, features of the compiler and the "
|
|
|
|
"existance of headers to name just a few.", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmPropertiesDocumentationDescription[] =
|
|
|
|
{
|
|
|
|
{0,
|
2007-07-11 23:53:58 +04:00
|
|
|
" CMake Properties - Properties supported by CMake, "
|
|
|
|
"the Cross-Platform Makefile Generator.", 0},
|
2007-06-22 16:44:51 +04:00
|
|
|
// CMAKE_DOCUMENTATION_OVERVIEW,
|
|
|
|
{0,
|
|
|
|
"This is the documentation for the properties supported by CMake. "
|
2007-07-20 16:36:16 +04:00
|
|
|
"Properties can have different scopes. They can either be assigned to a "
|
|
|
|
"source file, a directory, a target or globally to CMake. By modifying the "
|
|
|
|
"values of properties the behaviour of the buildsystem can be customized.",
|
|
|
|
0},
|
2007-06-22 16:44:51 +04:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmCompatCommandsDocumentationDescription[] =
|
|
|
|
{
|
|
|
|
{0,
|
2007-07-11 23:53:58 +04:00
|
|
|
" CMake Compatibility Listfile Commands - "
|
|
|
|
"Obsolete commands supported by CMake for compatibility.", 0},
|
2007-06-22 16:44:51 +04:00
|
|
|
// CMAKE_DOCUMENTATION_OVERVIEW,
|
|
|
|
{0,
|
2007-07-20 16:36:16 +04:00
|
|
|
"This is the documentation for now obsolete listfile commands from previous "
|
|
|
|
"CMake versions, which are still supported for compatibility reasons. You "
|
|
|
|
"should instead use the newer, faster and shinier new commands. ;-)", 0},
|
2007-06-22 16:44:51 +04:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2003-02-17 17:42:13 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationCommandsHeader[] =
|
|
|
|
{
|
|
|
|
{0,
|
|
|
|
"The following commands are available in CMakeLists.txt code:", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-07-11 23:53:58 +04:00
|
|
|
static const cmDocumentationEntry cmDocumentationGlobalPropertiesHeader[] =
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
|
|
|
{0,
|
2007-07-11 23:53:58 +04:00
|
|
|
"The following global properties are available in CMakeLists.txt code:", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationDirectoryPropertiesHeader[] =
|
|
|
|
{
|
|
|
|
{0
|
|
|
|
,"The following directory properties are available in CMakeLists.txt code:"
|
|
|
|
,0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationTargetPropertiesHeader[] =
|
|
|
|
{
|
|
|
|
{0,
|
|
|
|
"The following target properties are available in CMakeLists.txt code:", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationTestPropertiesHeader[] =
|
|
|
|
{
|
|
|
|
{0
|
|
|
|
,"The following properties for tests are available in CMakeLists.txt code:"
|
|
|
|
,0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationSourceFilePropertiesHeader[] =
|
|
|
|
{
|
|
|
|
{0
|
|
|
|
,"The following source file properties are available in CMakeLists.txt code:"
|
|
|
|
, 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationVariablePropertiesHeader[] =
|
|
|
|
{
|
|
|
|
{0, "The following variables are available in CMakeLists.txt code:", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry
|
|
|
|
cmDocumentationCachedVariablePropertiesHeader[] =
|
|
|
|
{
|
|
|
|
{0,"The following cache variables are available in CMakeLists.txt code:", 0},
|
2006-12-07 17:45:32 +03:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationModulesHeader[] =
|
|
|
|
{
|
|
|
|
{0,
|
|
|
|
"The following modules are provided with CMake. "
|
|
|
|
"They can be used with INCLUDE(ModuleName).", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const cmDocumentationEntry cmDocumentationGeneratorsHeader[] =
|
|
|
|
{
|
|
|
|
{0,
|
|
|
|
"The following generators are available on this platform:", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2003-02-17 17:56:41 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2006-10-05 18:55:37 +04:00
|
|
|
static const cmDocumentationEntry cmDocumentationStandardSeeAlso[] =
|
2003-02-17 17:56:41 +03:00
|
|
|
{
|
|
|
|
{0,
|
2006-10-05 18:55:37 +04:00
|
|
|
"The following resources are available to get help using CMake:", 0},
|
|
|
|
{"Home Page",
|
|
|
|
"http://www.cmake.org",
|
|
|
|
"The primary starting point for learning about CMake."},
|
|
|
|
{"Frequently Asked Questions",
|
|
|
|
"http://www.cmake.org/Wiki/CMake_FAQ",
|
|
|
|
"A Wiki is provided containing answers to frequently asked questions. "},
|
|
|
|
{"Online Documentation",
|
|
|
|
"http://www.cmake.org/HTML/Documentation.html",
|
|
|
|
"Links to available documentation may be found on this web page."},
|
|
|
|
{"Mailing List",
|
|
|
|
"http://www.cmake.org/HTML/MailingLists.html",
|
|
|
|
"For help and discussion about using cmake, a mailing list is provided at "
|
|
|
|
"cmake@cmake.org. "
|
|
|
|
"The list is member-post-only but one may sign up on the CMake web page. "
|
|
|
|
"Please first read the full documentation at "
|
|
|
|
"http://www.cmake.org before posting questions to the list."},
|
|
|
|
{0,
|
|
|
|
"Summary of helpful links:\n"
|
|
|
|
" Home: http://www.cmake.org\n"
|
|
|
|
" Docs: http://www.cmake.org/HTML/Documentation.html\n"
|
|
|
|
" Mail: http://www.cmake.org/HTML/MailingLists.html\n"
|
|
|
|
" FAQ: http://www.cmake.org/Wiki/CMake_FAQ\n"
|
|
|
|
, 0},
|
2003-02-17 17:56:41 +03:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const cmDocumentationEntry cmDocumentationAuthor[] =
|
|
|
|
{
|
|
|
|
{0,
|
2003-08-06 22:49:52 +04:00
|
|
|
"This manual page was generated by the \"--help-man\" option.", 0},
|
2003-02-19 04:42:02 +03:00
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const cmDocumentationEntry cmDocumentationCopyright[] =
|
|
|
|
{
|
|
|
|
{0,
|
2003-02-19 04:42:02 +03:00
|
|
|
"Copyright (c) 2002 Kitware, Inc., Insight Consortium. "
|
|
|
|
"All rights reserved.", 0},
|
2003-02-14 18:53:37 +03:00
|
|
|
{0,
|
|
|
|
"Redistribution and use in source and binary forms, with or without "
|
|
|
|
"modification, are permitted provided that the following conditions are "
|
2003-02-19 04:42:02 +03:00
|
|
|
"met:", 0},
|
|
|
|
{"",
|
2003-02-14 18:53:37 +03:00
|
|
|
"Redistributions of source code must retain the above copyright notice, "
|
2003-02-19 04:42:02 +03:00
|
|
|
"this list of conditions and the following disclaimer.", 0},
|
|
|
|
{"",
|
2003-02-14 18:53:37 +03:00
|
|
|
"Redistributions in binary form must reproduce the above copyright "
|
|
|
|
"notice, this list of conditions and the following disclaimer in the "
|
2003-02-19 04:42:02 +03:00
|
|
|
"documentation and/or other materials provided with the distribution.",
|
2003-02-14 18:53:37 +03:00
|
|
|
0},
|
2003-02-19 04:42:02 +03:00
|
|
|
{"",
|
2003-02-14 18:53:37 +03:00
|
|
|
"The names of Kitware, Inc., the Insight Consortium, or the names of "
|
|
|
|
"any consortium members, or of any contributors, may not be used to "
|
|
|
|
"endorse or promote products derived from this software without "
|
2003-02-19 04:42:02 +03:00
|
|
|
"specific prior written permission.", 0},
|
|
|
|
{"",
|
2003-02-14 18:53:37 +03:00
|
|
|
"Modified source versions must be plainly marked as such, and must "
|
2003-02-19 04:42:02 +03:00
|
|
|
"not be misrepresented as being the original software.", 0},
|
2003-02-14 18:53:37 +03:00
|
|
|
{0,
|
|
|
|
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "
|
|
|
|
"``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "
|
|
|
|
"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR "
|
|
|
|
"A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR "
|
|
|
|
"CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, "
|
|
|
|
"EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, "
|
|
|
|
"PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR "
|
|
|
|
"PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF "
|
|
|
|
"LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING "
|
|
|
|
"NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS "
|
2003-02-19 04:42:02 +03:00
|
|
|
"SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.", 0},
|
2003-02-14 18:53:37 +03:00
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmDocumentation::cmDocumentation()
|
2007-02-01 18:38:42 +03:00
|
|
|
:NameSection ("Name", "NAME")
|
|
|
|
,UsageSection ("Usage", "SYNOPSIS")
|
|
|
|
,DescriptionSection ("", "DESCRIPTION")
|
|
|
|
,OptionsSection ("Command-Line Options", "OPTIONS")
|
|
|
|
,CommandsSection ("Listfile Commands", "COMMANDS")
|
|
|
|
,CompatCommandsSection("Compatibility Listfile Commands",
|
|
|
|
"COMPATIBILITY COMMANDS")
|
|
|
|
,ModulesSection ("Standard CMake Modules", "MODULES")
|
|
|
|
,GeneratorsSection ("Generators", "GENERATORS")
|
|
|
|
,SeeAlsoSection ("See Also", "SEE ALSO")
|
|
|
|
,CopyrightSection ("Copyright", "COPYRIGHT")
|
|
|
|
,AuthorSection ("Author", "AUTHOR")
|
2007-07-11 23:53:58 +04:00
|
|
|
,GlobalPropertiesSection ("Standard Properties", "GLOBAL PROPERTIES")
|
|
|
|
,DirectoryPropertiesSection ("Directory Properties",
|
|
|
|
"DIRECTORY PROPERTIES")
|
|
|
|
,TargetPropertiesSection ("Target Properties", "TARGET PROPERTIES")
|
|
|
|
,TestPropertiesSection ("Test Properties", "TEST PROPERTIES")
|
|
|
|
,SourceFilePropertiesSection ("Sourcefile Properties",
|
|
|
|
"SOURCEFILE PROPERTIES")
|
|
|
|
,VariablePropertiesSection ("Variables", "VARIABLES")
|
|
|
|
,CachedVariablePropertiesSection("Cached Variables", "CACHE VARIABLES")
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
this->CurrentForm = TextForm;
|
|
|
|
this->TextIndent = "";
|
|
|
|
this->TextWidth = 77;
|
2007-07-11 23:53:58 +04:00
|
|
|
|
|
|
|
this->PropertySections[cmProperty::GLOBAL] = &this->GlobalPropertiesSection;
|
|
|
|
this->PropertySections[cmProperty::DIRECTORY] =
|
|
|
|
&this->DirectoryPropertiesSection;
|
|
|
|
this->PropertySections[cmProperty::TARGET] = &this->TargetPropertiesSection;
|
|
|
|
this->PropertySections[cmProperty::TEST] = &this->TestPropertiesSection;
|
|
|
|
this->PropertySections[cmProperty::SOURCE_FILE] =
|
|
|
|
&this->SourceFilePropertiesSection;
|
|
|
|
this->PropertySections[cmProperty::VARIABLE] =
|
|
|
|
&this->VariablePropertiesSection;
|
|
|
|
this->PropertySections[cmProperty::CACHED_VARIABLE] =
|
|
|
|
&this->CachedVariablePropertiesSection;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmDocumentation::~cmDocumentation()
|
|
|
|
{
|
|
|
|
for(std::vector< char* >::iterator i = this->ModuleStrings.begin();
|
|
|
|
i != this->ModuleStrings.end(); ++i)
|
|
|
|
{
|
|
|
|
delete [] *i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintCopyright(std::ostream& os)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
for(const cmDocumentationEntry* op = cmDocumentationCopyright;
|
|
|
|
op->brief; ++op)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
|
|
|
if(op->name)
|
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
os << " * ";
|
|
|
|
this->TextIndent = " ";
|
|
|
|
this->PrintColumn(os, op->brief);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
this->TextIndent = "";
|
|
|
|
this->PrintColumn(os, op->brief);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
os << "\n";
|
|
|
|
}
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintVersion(std::ostream& os)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2006-05-10 23:01:22 +04:00
|
|
|
os << this->GetNameString() << " version "
|
|
|
|
<< cmVersion::GetCMakeVersion() << "\n";
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::AddSection(const char* name,
|
|
|
|
const cmDocumentationEntry* d)
|
|
|
|
{
|
|
|
|
this->Names.push_back(name);
|
|
|
|
this->Sections.push_back(d);
|
|
|
|
}
|
|
|
|
|
2007-02-01 18:38:42 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::AddSection(const cmSection& section)
|
|
|
|
{
|
|
|
|
if (!section.IsEmpty())
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
|
|
|
this->Names.push_back(section.GetName(this->CurrentForm));
|
|
|
|
this->Sections.push_back(section.GetEntries());
|
|
|
|
}
|
2007-02-01 18:38:42 +03:00
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::ClearSections()
|
|
|
|
{
|
|
|
|
this->Names.erase(this->Names.begin(), this->Names.end());
|
|
|
|
this->Sections.erase(this->Sections.begin(), this->Sections.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-06-28 19:00:57 +04:00
|
|
|
if ((this->CurrentForm != HTMLForm) && (this->CurrentForm != ManForm))
|
2004-10-22 23:44:54 +04:00
|
|
|
{
|
|
|
|
this->PrintVersion(os);
|
|
|
|
}
|
2007-02-01 18:38:42 +03:00
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
switch (ht)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
case cmDocumentation::Usage:
|
|
|
|
return this->PrintDocumentationUsage(os);
|
|
|
|
case cmDocumentation::Single:
|
2006-05-10 23:01:22 +04:00
|
|
|
return this->PrintDocumentationSingle(os);
|
2007-02-01 18:38:42 +03:00
|
|
|
case cmDocumentation::SingleModule:
|
2006-05-10 23:01:22 +04:00
|
|
|
return this->PrintDocumentationSingleModule(os);
|
2007-02-01 18:38:42 +03:00
|
|
|
case cmDocumentation::SingleProperty:
|
2006-12-07 17:45:32 +03:00
|
|
|
return this->PrintDocumentationSingleProperty(os);
|
2007-06-28 23:04:28 +04:00
|
|
|
case cmDocumentation::List:
|
|
|
|
return this->PrintDocumentationList(os);
|
|
|
|
case cmDocumentation::ModuleList:
|
|
|
|
return this->PrintModuleList(os);
|
|
|
|
case cmDocumentation::PropertyList:
|
|
|
|
return this->PrintPropertyList(os);
|
|
|
|
|
|
|
|
case cmDocumentation::Full:
|
|
|
|
return this->PrintDocumentationFull(os);
|
|
|
|
case cmDocumentation::Modules:
|
|
|
|
return this->PrintDocumentationModules(os);
|
|
|
|
case cmDocumentation::Properties:
|
|
|
|
return this->PrintDocumentationProperties(os);
|
|
|
|
case cmDocumentation::Commands:
|
|
|
|
return this->PrintDocumentationCurrentCommands(os);
|
|
|
|
case cmDocumentation::CompatCommands:
|
|
|
|
return this->PrintDocumentationCompatCommands(os);
|
|
|
|
|
|
|
|
case cmDocumentation::Copyright:
|
|
|
|
return this->PrintCopyright(os);
|
|
|
|
case cmDocumentation::Version:
|
|
|
|
return true;
|
2004-04-14 22:25:43 +04:00
|
|
|
default: return false;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::CreateModulesSection()
|
|
|
|
{
|
2006-04-14 07:15:48 +04:00
|
|
|
std::string cmakeModules = this->CMakeRoot;
|
2005-12-14 21:51:08 +03:00
|
|
|
cmakeModules += "/Modules";
|
|
|
|
cmsys::Directory dir;
|
|
|
|
dir.Load(cmakeModules.c_str());
|
2007-06-09 00:06:33 +04:00
|
|
|
if (dir.GetNumberOfFiles() > 0)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-06-09 00:06:33 +04:00
|
|
|
this->ModulesSection.Append(cmDocumentationModulesHeader[0]);
|
|
|
|
for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-06-09 00:06:33 +04:00
|
|
|
std::string fname = dir.GetFile(i);
|
|
|
|
if(fname.length() > 6)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-06-09 00:06:33 +04:00
|
|
|
if(fname.substr(fname.length()-6, 6) == ".cmake")
|
|
|
|
{
|
|
|
|
std::string moduleName = fname.substr(0, fname.length()-6);
|
|
|
|
std::string path = cmakeModules;
|
|
|
|
path += "/";
|
|
|
|
path += fname;
|
|
|
|
this->CreateSingleModule(path.c_str(), moduleName.c_str());
|
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
2007-06-09 00:06:33 +04:00
|
|
|
}
|
|
|
|
cmDocumentationEntry e = { 0, 0, 0 };
|
|
|
|
this->ModulesSection.Append(e);
|
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-05-10 23:01:22 +04:00
|
|
|
bool cmDocumentation::CreateSingleModule(const char* fname,
|
|
|
|
const char* moduleName)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
|
|
|
std::ifstream fin(fname);
|
|
|
|
if(!fin)
|
|
|
|
{
|
|
|
|
std::cerr << "Internal error: can not open module." << fname << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
std::string line;
|
|
|
|
std::string text;
|
|
|
|
std::string brief;
|
|
|
|
brief = " ";
|
|
|
|
bool newParagraph = true;
|
|
|
|
while ( fin && cmSystemTools::GetLineFromStream(fin, line) )
|
|
|
|
{
|
|
|
|
if(line.size() && line[0] == '#')
|
|
|
|
{
|
|
|
|
// blank line
|
|
|
|
if(line.size() <= 2)
|
|
|
|
{
|
|
|
|
text += "\n";
|
|
|
|
newParagraph = true;
|
|
|
|
}
|
|
|
|
else if(line[2] == '-')
|
|
|
|
{
|
|
|
|
brief = line.c_str()+4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// two spaces
|
|
|
|
if(line[1] == ' ' && line[2] == ' ')
|
|
|
|
{
|
|
|
|
if(!newParagraph)
|
|
|
|
{
|
|
|
|
text += "\n";
|
|
|
|
newParagraph = true;
|
|
|
|
}
|
|
|
|
// Skip #, and leave space for preformatted
|
|
|
|
text += line.c_str()+1;
|
|
|
|
text += "\n";
|
|
|
|
}
|
|
|
|
else if(line[1] == ' ')
|
|
|
|
{
|
|
|
|
if(!newParagraph)
|
|
|
|
{
|
|
|
|
text += " ";
|
|
|
|
}
|
|
|
|
newParagraph = false;
|
|
|
|
// skip # and space
|
|
|
|
text += line.c_str()+2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(!newParagraph)
|
|
|
|
{
|
|
|
|
text += " ";
|
|
|
|
}
|
|
|
|
newParagraph = false;
|
|
|
|
// skip #
|
|
|
|
text += line.c_str()+1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-12-17 00:49:01 +03:00
|
|
|
if(text.length() < 2 && brief.length() == 1)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
char* pname = strcpy(new char[strlen(moduleName)+1], moduleName);
|
|
|
|
char* ptext = strcpy(new char[text.length()+1], text.c_str());
|
|
|
|
this->ModuleStrings.push_back(pname);
|
|
|
|
this->ModuleStrings.push_back(ptext);
|
|
|
|
char* pbrief = strcpy(new char[brief.length()+1], brief.c_str());
|
|
|
|
this->ModuleStrings.push_back(pbrief);
|
|
|
|
cmDocumentationEntry e = { pname, pbrief, ptext };
|
2007-02-01 18:38:42 +03:00
|
|
|
this->ModulesSection.Append(e);
|
2005-12-15 17:19:23 +03:00
|
|
|
return true;
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2003-07-08 06:44:18 +04:00
|
|
|
bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
|
|
|
|
{
|
|
|
|
bool result = true;
|
|
|
|
|
|
|
|
// Loop over requested documentation types.
|
2007-06-28 19:00:57 +04:00
|
|
|
for(std::vector<RequestedHelpItem>::const_iterator
|
|
|
|
i = this->RequestedHelpItems.begin();
|
|
|
|
i != this->RequestedHelpItems.end();
|
|
|
|
++i)
|
2003-07-08 06:44:18 +04:00
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
this->CurrentForm = i->HelpForm;
|
2007-06-28 19:00:57 +04:00
|
|
|
this->CurrentArgument = i->Argument;
|
2003-07-08 06:44:18 +04:00
|
|
|
// If a file name was given, use it. Otherwise, default to the
|
|
|
|
// given stream.
|
|
|
|
std::ofstream* fout = 0;
|
|
|
|
std::ostream* s = &os;
|
2007-06-28 19:00:57 +04:00
|
|
|
if(i->Filename.length() > 0)
|
2003-07-08 06:44:18 +04:00
|
|
|
{
|
2007-06-28 19:00:57 +04:00
|
|
|
fout = new std::ofstream(i->Filename.c_str(), std::ios::out);
|
2003-07-08 06:44:18 +04:00
|
|
|
if(fout)
|
|
|
|
{
|
|
|
|
s = fout;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print this documentation type to the stream.
|
2007-07-03 16:26:32 +04:00
|
|
|
if(!this->PrintDocumentation(i->HelpType, *s) || !*s)
|
2003-07-08 06:44:18 +04:00
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close the file if we wrote one.
|
|
|
|
if(fout)
|
|
|
|
{
|
|
|
|
delete fout;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-06-28 19:00:57 +04:00
|
|
|
#define GET_OPT_COMMAND(target) \
|
|
|
|
if((i+1 < argc) && !this->IsOption(argv[i+1])) \
|
|
|
|
{ \
|
|
|
|
target = cmSystemTools::UpperCase(argv[i+1]); \
|
|
|
|
i = i+1; \
|
|
|
|
};
|
|
|
|
|
|
|
|
#define GET_OPT_FILENAME(target) \
|
|
|
|
if((i+1 < argc) && !this->IsOption(argv[i+1])) \
|
|
|
|
{ \
|
|
|
|
target = argv[i+1]; \
|
|
|
|
i = i+1; \
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
cmDocumentation::Form cmDocumentation::GetFormFromFilename(
|
|
|
|
const std::string& filename)
|
|
|
|
{
|
|
|
|
std::string ext = cmSystemTools::GetFilenameExtension(filename);
|
|
|
|
ext = cmSystemTools::UpperCase(ext);
|
|
|
|
if ((ext == ".HTM") || (ext == ".HTML"))
|
|
|
|
{
|
|
|
|
return cmDocumentation::HTMLForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ".1" to ".9" should be manpages
|
|
|
|
if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
|
|
|
|
{
|
|
|
|
return cmDocumentation::ManForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmDocumentation::TextForm;
|
|
|
|
}
|
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2003-07-24 01:27:34 +04:00
|
|
|
bool cmDocumentation::CheckOptions(int argc, const char* const* argv)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-04-03 07:44:42 +04:00
|
|
|
// Providing zero arguments gives usage information.
|
|
|
|
if(argc == 1)
|
|
|
|
{
|
2007-06-28 19:00:57 +04:00
|
|
|
RequestedHelpItem help;
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Usage;
|
|
|
|
help.HelpForm = cmDocumentation::UsageForm;
|
2007-06-28 19:00:57 +04:00
|
|
|
this->RequestedHelpItems.push_back(help);
|
2003-07-08 06:44:18 +04:00
|
|
|
return true;
|
2003-04-03 07:44:42 +04:00
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
|
2003-04-03 07:44:42 +04:00
|
|
|
// Search for supported help options.
|
2007-06-28 19:00:57 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
bool result = false;
|
2003-02-19 04:42:02 +03:00
|
|
|
for(int i=1; i < argc; ++i)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-06-28 19:00:57 +04:00
|
|
|
RequestedHelpItem help;
|
2003-07-08 06:44:18 +04:00
|
|
|
// Check if this is a supported help option.
|
2003-02-19 04:42:02 +03:00
|
|
|
if((strcmp(argv[i], "-help") == 0) ||
|
|
|
|
(strcmp(argv[i], "--help") == 0) ||
|
|
|
|
(strcmp(argv[i], "/?") == 0) ||
|
|
|
|
(strcmp(argv[i], "-usage") == 0) ||
|
|
|
|
(strcmp(argv[i], "-h") == 0) ||
|
|
|
|
(strcmp(argv[i], "-H") == 0))
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Usage;
|
|
|
|
help.HelpForm = cmDocumentation::UsageForm;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_COMMAND(help.Argument);
|
|
|
|
// special case for single command
|
|
|
|
if (!help.Argument.empty())
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Single;
|
2007-06-28 19:00:57 +04:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
}
|
2007-06-28 23:04:28 +04:00
|
|
|
else if(strcmp(argv[i], "--help-properties") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Properties;
|
2007-06-28 23:04:28 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2007-06-28 23:04:28 +04:00
|
|
|
}
|
|
|
|
else if(strcmp(argv[i], "--help-modules") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Modules;
|
2007-06-28 23:04:28 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2007-06-28 23:04:28 +04:00
|
|
|
}
|
|
|
|
else if(strcmp(argv[i], "--help-commands") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Commands;
|
2007-06-28 23:04:28 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2007-06-28 23:04:28 +04:00
|
|
|
}
|
|
|
|
else if(strcmp(argv[i], "--help-compatcommands") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::CompatCommands;
|
2007-06-28 23:04:28 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2007-06-28 23:04:28 +04:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
else if(strcmp(argv[i], "--help-full") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Full;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
else if(strcmp(argv[i], "--help-html") == 0)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Full;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::HTMLForm;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
else if(strcmp(argv[i], "--help-man") == 0)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Full;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::ManForm;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2004-04-14 22:25:43 +04:00
|
|
|
else if(strcmp(argv[i], "--help-command") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Single;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_COMMAND(help.Argument);
|
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2004-04-14 22:25:43 +04:00
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
else if(strcmp(argv[i], "--help-module") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::SingleModule;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_COMMAND(help.Argument);
|
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
else if(strcmp(argv[i], "--help-property") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::SingleProperty;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_COMMAND(help.Argument);
|
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2004-04-14 22:25:43 +04:00
|
|
|
else if(strcmp(argv[i], "--help-command-list") == 0)
|
2004-04-14 21:40:24 +04:00
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::List;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::TextForm;
|
2004-04-14 21:40:24 +04:00
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
else if(strcmp(argv[i], "--help-module-list") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::ModuleList;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::TextForm;
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
else if(strcmp(argv[i], "--help-property-list") == 0)
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::PropertyList;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::TextForm;
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
else if(strcmp(argv[i], "--copyright") == 0)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Copyright;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::UsageForm;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
else if((strcmp(argv[i], "--version") == 0) ||
|
|
|
|
(strcmp(argv[i], "-version") == 0) ||
|
|
|
|
(strcmp(argv[i], "/V") == 0))
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpType = cmDocumentation::Version;
|
2007-06-28 19:00:57 +04:00
|
|
|
GET_OPT_FILENAME(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::UsageForm;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2007-07-03 16:26:32 +04:00
|
|
|
if(help.HelpType != None)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2003-07-08 06:44:18 +04:00
|
|
|
// This is a help option. See if there is a file name given.
|
|
|
|
result = true;
|
2007-06-28 19:00:57 +04:00
|
|
|
this->RequestedHelpItems.push_back(help);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
return result;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
2003-02-14 21:06:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::Print(Form f, std::ostream& os)
|
2003-02-14 21:06:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
this->CurrentForm = f;
|
2007-02-01 18:38:42 +03:00
|
|
|
Print(os);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::Print(std::ostream& os)
|
|
|
|
{
|
2003-02-19 16:52:45 +03:00
|
|
|
for(unsigned int i=0; i < this->Sections.size(); ++i)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
|
|
|
this->PrintSection(os, this->Sections[i], this->Names[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-06 22:49:52 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetName(const char* name)
|
|
|
|
{
|
|
|
|
this->NameString = name?name:"";
|
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetNameSection(const cmDocumentationEntry* section)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->NameSection.Set(0, section, 0);
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetUsageSection(const cmDocumentationEntry* section)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->UsageSection.Set(0, section, 0);
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-05-10 23:01:22 +04:00
|
|
|
void cmDocumentation
|
|
|
|
::SetDescriptionSection(const cmDocumentationEntry* section)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->DescriptionSection.Set(0, section, 0);
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetOptionsSection(const cmDocumentationEntry* section)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->OptionsSection.Set(0, section, cmDocumentationStandardOptions);
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetCommandsSection(const cmDocumentationEntry* section)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->CommandsSection.Set(cmDocumentationCommandsHeader, section, 0);
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
2007-06-22 16:44:51 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetCompatCommandsSection(const cmDocumentationEntry*
|
|
|
|
section)
|
|
|
|
{
|
|
|
|
this->CompatCommandsSection.Set(cmDocumentationCommandsHeader, section, 0);
|
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2006-12-08 17:27:52 +03:00
|
|
|
void cmDocumentation
|
2007-07-11 23:53:58 +04:00
|
|
|
::SetPropertiesSection(const cmDocumentationEntry* section,
|
|
|
|
cmProperty::ScopeType type)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2007-07-11 23:53:58 +04:00
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case cmProperty::GLOBAL:
|
|
|
|
this->GlobalPropertiesSection.Set(
|
|
|
|
cmDocumentationGlobalPropertiesHeader, section, 0);
|
|
|
|
break;
|
|
|
|
case cmProperty::DIRECTORY:
|
|
|
|
this->DirectoryPropertiesSection.Set(
|
2007-07-20 16:36:16 +04:00
|
|
|
cmDocumentationDirectoryPropertiesHeader, section, 0);
|
2007-07-11 23:53:58 +04:00
|
|
|
break;
|
|
|
|
case cmProperty::TARGET:
|
|
|
|
this->TargetPropertiesSection.Set(
|
|
|
|
cmDocumentationTargetPropertiesHeader, section, 0);
|
|
|
|
break;
|
|
|
|
case cmProperty::TEST:
|
|
|
|
this->TestPropertiesSection.Set(
|
|
|
|
cmDocumentationTestPropertiesHeader, section, 0);
|
|
|
|
break;
|
|
|
|
case cmProperty::SOURCE_FILE:
|
|
|
|
this->SourceFilePropertiesSection.Set(
|
|
|
|
cmDocumentationSourceFilePropertiesHeader, section, 0);
|
|
|
|
break;
|
|
|
|
case cmProperty::VARIABLE:
|
|
|
|
this->VariablePropertiesSection.Set(
|
|
|
|
cmDocumentationVariablePropertiesHeader, section, 0);
|
|
|
|
break;
|
|
|
|
case cmProperty::CACHED_VARIABLE:
|
|
|
|
this->CachedVariablePropertiesSection.Set(
|
|
|
|
cmDocumentationCachedVariablePropertiesHeader, section, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2006-05-10 23:01:22 +04:00
|
|
|
void cmDocumentation
|
|
|
|
::SetGeneratorsSection(const cmDocumentationEntry* section)
|
2003-07-08 05:52:10 +04:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->GeneratorsSection.Set(cmDocumentationGeneratorsHeader, section, 0);
|
2003-07-08 05:52:10 +04:00
|
|
|
}
|
|
|
|
|
2003-07-11 07:15:45 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetSeeAlsoList(const cmDocumentationEntry* also)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->SeeAlsoSection.Clear();
|
2003-07-11 07:15:45 +04:00
|
|
|
this->SeeAlsoString = ".B ";
|
|
|
|
for(const cmDocumentationEntry* i = also; i->brief; ++i)
|
|
|
|
{
|
|
|
|
this->SeeAlsoString += i->brief;
|
|
|
|
this->SeeAlsoString += (i+1)->brief? "(1), ":"(1)";
|
|
|
|
}
|
|
|
|
cmDocumentationEntry e = {0, 0, 0};
|
|
|
|
e.brief = this->SeeAlsoString.c_str();
|
2007-02-01 18:38:42 +03:00
|
|
|
this->SeeAlsoSection.Append(e);
|
2006-10-05 18:55:37 +04:00
|
|
|
for(const cmDocumentationEntry* i = cmDocumentationStandardSeeAlso;
|
|
|
|
i->brief; ++i)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->SeeAlsoSection.Append(*i);
|
2006-10-05 18:55:37 +04:00
|
|
|
}
|
2003-07-11 07:15:45 +04:00
|
|
|
e.brief = 0;
|
2007-02-01 18:38:42 +03:00
|
|
|
this->SeeAlsoSection.Append(e);
|
2003-07-11 07:15:45 +04:00
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintSection(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name)
|
|
|
|
{
|
|
|
|
switch (this->CurrentForm)
|
|
|
|
{
|
|
|
|
case TextForm: this->PrintSectionText(os, section, name); break;
|
|
|
|
case HTMLForm: this->PrintSectionHTML(os, section, name); break;
|
|
|
|
case ManForm: this->PrintSectionMan(os, section, name); break;
|
|
|
|
case UsageForm: this->PrintSectionUsage(os, section, name); break;
|
|
|
|
}
|
2003-02-14 21:06:37 +03:00
|
|
|
}
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::PrintSectionText(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
if(name)
|
|
|
|
{
|
2003-07-11 07:15:45 +04:00
|
|
|
os <<
|
|
|
|
"---------------------------------------"
|
|
|
|
"---------------------------------------\n";
|
2003-02-19 04:42:02 +03:00
|
|
|
os << name << "\n\n";
|
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
if(!section) { return; }
|
2003-02-19 04:42:02 +03:00
|
|
|
for(const cmDocumentationEntry* op = section; op->brief; ++op)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
if(op->name)
|
|
|
|
{
|
|
|
|
if(op->name[0])
|
|
|
|
{
|
|
|
|
os << " " << op->name << "\n";
|
|
|
|
}
|
|
|
|
this->TextIndent = " ";
|
|
|
|
this->PrintFormatted(os, op->brief);
|
|
|
|
if(op->full)
|
|
|
|
{
|
|
|
|
os << "\n";
|
|
|
|
this->PrintFormatted(os, op->full);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->TextIndent = "";
|
|
|
|
this->PrintFormatted(os, op->brief);
|
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintSectionHTML(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name)
|
|
|
|
{
|
|
|
|
if(name)
|
|
|
|
{
|
|
|
|
os << "<h2>" << name << "</h2>\n";
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
if(!section) { return; }
|
2003-02-14 18:53:37 +03:00
|
|
|
for(const cmDocumentationEntry* op = section; op->brief;)
|
|
|
|
{
|
|
|
|
if(op->name)
|
|
|
|
{
|
|
|
|
os << "<ul>\n";
|
|
|
|
for(;op->name;++op)
|
|
|
|
{
|
|
|
|
os << " <li>\n";
|
2003-02-19 04:42:02 +03:00
|
|
|
if(op->name[0])
|
|
|
|
{
|
|
|
|
os << " <b><code>";
|
|
|
|
this->PrintHTMLEscapes(os, op->name);
|
|
|
|
os << "</code></b>: ";
|
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
this->PrintHTMLEscapes(os, op->brief);
|
|
|
|
if(op->full)
|
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
os << "<br>\n ";
|
|
|
|
this->PrintFormatted(os, op->full);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
os << "\n";
|
|
|
|
os << " </li>\n";
|
|
|
|
}
|
|
|
|
os << "</ul>\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
this->PrintFormatted(os, op->brief);
|
2003-02-14 18:53:37 +03:00
|
|
|
os << "\n";
|
|
|
|
++op;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::PrintSectionMan(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
if(name)
|
|
|
|
{
|
|
|
|
os << ".SH " << name << "\n";
|
|
|
|
}
|
|
|
|
if(!section) { return; }
|
|
|
|
for(const cmDocumentationEntry* op = section; op->brief; ++op)
|
|
|
|
{
|
|
|
|
if(op->name)
|
|
|
|
{
|
|
|
|
os << ".TP\n"
|
|
|
|
<< ".B " << (op->name[0]?op->name:"*") << "\n";
|
|
|
|
this->PrintFormatted(os, op->brief);
|
|
|
|
this->PrintFormatted(os, op->full);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os << ".PP\n";
|
|
|
|
this->PrintFormatted(os, op->brief);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintSectionUsage(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name)
|
|
|
|
{
|
|
|
|
if(name)
|
|
|
|
{
|
|
|
|
os << name << "\n";
|
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
if(!section) { return; }
|
|
|
|
for(const cmDocumentationEntry* op = section; op->brief; ++op)
|
|
|
|
{
|
|
|
|
if(op->name)
|
|
|
|
{
|
2003-02-16 19:57:20 +03:00
|
|
|
os << " " << op->name;
|
2004-04-14 21:40:24 +04:00
|
|
|
this->TextIndent = " ";
|
2003-02-19 04:42:02 +03:00
|
|
|
int align = static_cast<int>(strlen(this->TextIndent))-4;
|
|
|
|
for(int i = static_cast<int>(strlen(op->name)); i < align; ++i)
|
2003-02-16 19:57:20 +03:00
|
|
|
{
|
|
|
|
os << " ";
|
|
|
|
}
|
2005-07-18 19:32:02 +04:00
|
|
|
if ( strlen(op->name) > strlen(this->TextIndent)-4 )
|
|
|
|
{
|
|
|
|
os << "\n";
|
|
|
|
os.write(this->TextIndent, strlen(this->TextIndent)-2);
|
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
os << "= ";
|
|
|
|
this->PrintColumn(os, op->brief);
|
|
|
|
os << "\n";
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os << "\n";
|
2003-02-19 04:42:02 +03:00
|
|
|
this->TextIndent = "";
|
|
|
|
this->PrintFormatted(os, op->brief);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2003-04-03 07:44:42 +04:00
|
|
|
os << "\n";
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::PrintFormatted(std::ostream& os, const char* text)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
if(!text)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const char* ptr = text;
|
|
|
|
while(*ptr)
|
|
|
|
{
|
|
|
|
// Any ptrs starting in a space are treated as preformatted text.
|
|
|
|
std::string preformatted;
|
|
|
|
while(*ptr == ' ')
|
|
|
|
{
|
|
|
|
for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
|
|
|
|
{
|
|
|
|
preformatted.append(1, ch);
|
|
|
|
}
|
|
|
|
if(*ptr)
|
|
|
|
{
|
|
|
|
++ptr;
|
|
|
|
preformatted.append(1, '\n');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(preformatted.length())
|
|
|
|
{
|
|
|
|
this->PrintPreformatted(os, preformatted.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Other ptrs are treated as paragraphs.
|
|
|
|
std::string paragraph;
|
|
|
|
for(char ch = *ptr; ch && ch != '\n'; ++ptr, ch = *ptr)
|
|
|
|
{
|
|
|
|
paragraph.append(1, ch);
|
|
|
|
}
|
|
|
|
if(*ptr)
|
|
|
|
{
|
|
|
|
++ptr;
|
|
|
|
paragraph.append(1, '\n');
|
|
|
|
}
|
|
|
|
if(paragraph.length())
|
|
|
|
{
|
|
|
|
this->PrintParagraph(os, paragraph.c_str());
|
|
|
|
}
|
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::PrintPreformatted(std::ostream& os, const char* text)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
switch (this->CurrentForm)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
case TextForm: this->PrintPreformattedText(os, text); break;
|
|
|
|
case HTMLForm: this->PrintPreformattedHTML(os, text); break;
|
|
|
|
case ManForm: this->PrintPreformattedMan(os, text); break;
|
|
|
|
case UsageForm: this->PrintPreformattedText(os, text); break;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::PrintParagraph(std::ostream& os, const char* text)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
switch (this->CurrentForm)
|
|
|
|
{
|
|
|
|
case TextForm: this->PrintParagraphText(os, text); break;
|
|
|
|
case HTMLForm: this->PrintParagraphHTML(os, text); break;
|
|
|
|
case ManForm: this->PrintParagraphMan(os, text); break;
|
|
|
|
case UsageForm: this->PrintParagraphText(os, text); break;
|
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-05-10 23:01:22 +04:00
|
|
|
void cmDocumentation
|
|
|
|
::PrintPreformattedText(std::ostream& os, const char* text)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
bool newline = true;
|
|
|
|
for(const char* ptr = text; *ptr; ++ptr)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
if(newline)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
os << this->TextIndent;
|
|
|
|
newline = false;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
os << *ptr;
|
|
|
|
if(*ptr == '\n')
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
newline = true;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
os << "\n";
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::PrintParagraphText(std::ostream& os, const char* text)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
os << this->TextIndent;
|
|
|
|
this->PrintColumn(os, text);
|
|
|
|
os << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-05-10 23:01:22 +04:00
|
|
|
void cmDocumentation
|
|
|
|
::PrintPreformattedHTML(std::ostream& os, const char* text)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
|
|
|
os << "<pre>";
|
|
|
|
this->PrintHTMLEscapes(os, text);
|
|
|
|
os << "</pre>\n ";
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::PrintParagraphHTML(std::ostream& os, const char* text)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
os << "<p>";
|
|
|
|
this->PrintHTMLEscapes(os, text);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintPreformattedMan(std::ostream& os, const char* text)
|
|
|
|
{
|
2006-08-22 18:38:10 +04:00
|
|
|
std::string man_text = text;
|
|
|
|
cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
|
|
|
|
os << man_text << "\n";
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintParagraphMan(std::ostream& os, const char* text)
|
|
|
|
{
|
2006-08-22 18:38:10 +04:00
|
|
|
std::string man_text = text;
|
|
|
|
cmSystemTools::ReplaceString(man_text, "\\", "\\\\");
|
|
|
|
os << man_text << "\n\n";
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintColumn(std::ostream& os, const char* text)
|
|
|
|
{
|
|
|
|
// Print text arranged in an indented column of fixed witdh.
|
2003-02-14 18:53:37 +03:00
|
|
|
const char* l = text;
|
|
|
|
int column = 0;
|
|
|
|
bool newSentence = false;
|
2003-02-14 21:06:37 +03:00
|
|
|
bool firstLine = true;
|
2003-02-19 16:52:45 +03:00
|
|
|
int width = this->TextWidth - static_cast<int>(strlen(this->TextIndent));
|
2003-02-14 21:06:37 +03:00
|
|
|
|
|
|
|
// Loop until the end of the text.
|
2003-02-14 18:53:37 +03:00
|
|
|
while(*l)
|
|
|
|
{
|
|
|
|
// Parse the next word.
|
|
|
|
const char* r = l;
|
|
|
|
while(*r && (*r != '\n') && (*r != ' ')) { ++r; }
|
|
|
|
|
|
|
|
// Does it fit on this line?
|
|
|
|
if(r-l < (width-column-(newSentence?1:0)))
|
|
|
|
{
|
|
|
|
// Word fits on this line.
|
|
|
|
if(r > l)
|
|
|
|
{
|
|
|
|
if(column)
|
|
|
|
{
|
|
|
|
// Not first word on line. Separate from the previous word
|
|
|
|
// by a space, or two if this is a new sentence.
|
|
|
|
if(newSentence)
|
|
|
|
{
|
|
|
|
os << " ";
|
|
|
|
column += 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os << " ";
|
|
|
|
column += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// First word on line. Print indentation unless this is the
|
|
|
|
// first line.
|
2003-02-19 04:42:02 +03:00
|
|
|
os << (firstLine?"":this->TextIndent);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print the word.
|
|
|
|
os.write(l, static_cast<long>(r-l));
|
|
|
|
newSentence = (*(r-1) == '.');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*r == '\n')
|
|
|
|
{
|
|
|
|
// Text provided a newline. Start a new line.
|
|
|
|
os << "\n";
|
|
|
|
++r;
|
|
|
|
column = 0;
|
2003-02-14 21:06:37 +03:00
|
|
|
firstLine = false;
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// No provided newline. Continue this line.
|
|
|
|
column += static_cast<long>(r-l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Word does not fit on this line. Start a new line.
|
|
|
|
os << "\n";
|
2003-02-14 21:06:37 +03:00
|
|
|
firstLine = false;
|
2003-02-14 18:53:37 +03:00
|
|
|
if(r > l)
|
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
os << this->TextIndent;
|
2003-02-14 18:53:37 +03:00
|
|
|
os.write(l, static_cast<long>(r-l));
|
|
|
|
column = static_cast<long>(r-l);
|
|
|
|
newSentence = (*(r-1) == '.');
|
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
column = 0;
|
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Move to beginning of next word. Skip over whitespace.
|
|
|
|
l = r;
|
|
|
|
while(*l && (*l == ' ')) { ++l; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2006-10-16 22:52:31 +04:00
|
|
|
static bool cmDocumentationIsHyperlinkChar(char c)
|
|
|
|
{
|
|
|
|
// This is not a complete list but works for CMake documentation.
|
|
|
|
return ((c >= 'A' && c <= 'Z') ||
|
|
|
|
(c >= 'a' && c <= 'z') ||
|
|
|
|
(c >= '0' && c <= '9') ||
|
|
|
|
c == '-' || c == '.' || c == '/' || c == '~' || c == '@' ||
|
|
|
|
c == ':' || c == '_' || c == '&' || c == '?' || c == '=');
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static void cmDocumentationPrintHTMLChar(std::ostream& os, char c)
|
2003-02-14 21:28:46 +03:00
|
|
|
{
|
2006-10-16 22:52:31 +04:00
|
|
|
// Use an escape sequence if necessary.
|
2003-02-19 04:42:02 +03:00
|
|
|
static cmDocumentationEntry escapes[] =
|
|
|
|
{
|
|
|
|
{"<", "<", 0},
|
|
|
|
{">", ">", 0},
|
|
|
|
{"&", "&", 0},
|
|
|
|
{"\n", "<br>", 0},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
2006-10-16 22:52:31 +04:00
|
|
|
for(const cmDocumentationEntry* op = escapes; op->name; ++op)
|
|
|
|
{
|
|
|
|
if(op->name[0] == c)
|
|
|
|
{
|
|
|
|
os << op->brief;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// No escape sequence is needed.
|
|
|
|
os << c;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char* cmDocumentationPrintHTMLLink(std::ostream& os, const char* begin)
|
|
|
|
{
|
|
|
|
// Look for the end of the link.
|
|
|
|
const char* end = begin;
|
|
|
|
while(cmDocumentationIsHyperlinkChar(*end))
|
|
|
|
{
|
|
|
|
++end;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the hyperlink itself.
|
|
|
|
os << "<a href=\"";
|
|
|
|
for(const char* c = begin; c != end; ++c)
|
|
|
|
{
|
|
|
|
cmDocumentationPrintHTMLChar(os, *c);
|
|
|
|
}
|
|
|
|
os << "\">";
|
|
|
|
|
|
|
|
// The name of the hyperlink is the text itself.
|
|
|
|
for(const char* c = begin; c != end; ++c)
|
2003-02-14 21:28:46 +03:00
|
|
|
{
|
2006-10-16 22:52:31 +04:00
|
|
|
cmDocumentationPrintHTMLChar(os, *c);
|
|
|
|
}
|
|
|
|
os << "</a>";
|
|
|
|
|
|
|
|
// Return the position at which to continue scanning the input
|
|
|
|
// string.
|
|
|
|
return end;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintHTMLEscapes(std::ostream& os, const char* text)
|
|
|
|
{
|
|
|
|
// Hyperlink prefixes.
|
|
|
|
static const char* hyperlinks[] = {"http://", "ftp://", "mailto:", 0};
|
|
|
|
|
|
|
|
// Print each character.
|
|
|
|
for(const char* p = text; *p;)
|
|
|
|
{
|
|
|
|
// Handle hyperlinks specially to make them active.
|
|
|
|
bool found_hyperlink = false;
|
|
|
|
for(const char** h = hyperlinks; !found_hyperlink && *h; ++h)
|
2003-02-14 21:28:46 +03:00
|
|
|
{
|
2006-10-16 22:52:31 +04:00
|
|
|
if(strncmp(p, *h, strlen(*h)) == 0)
|
2003-02-14 21:28:46 +03:00
|
|
|
{
|
2006-10-16 22:52:31 +04:00
|
|
|
p = cmDocumentationPrintHTMLLink(os, p);
|
|
|
|
found_hyperlink = true;
|
2003-02-14 21:28:46 +03:00
|
|
|
}
|
|
|
|
}
|
2006-10-16 22:52:31 +04:00
|
|
|
|
|
|
|
// Print other characters normally.
|
|
|
|
if(!found_hyperlink)
|
2003-02-14 21:28:46 +03:00
|
|
|
{
|
2006-10-16 22:52:31 +04:00
|
|
|
cmDocumentationPrintHTMLChar(os, *p++);
|
2003-02-14 21:28:46 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintDocumentationSingle(std::ostream& os)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
if(this->CommandsSection.IsEmpty())
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
|
|
|
os << "Internal error: commands list is empty." << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
if(this->CurrentArgument.length() == 0)
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
|
|
|
os << "Argument --help-command needs a command name.\n";
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
for(const cmDocumentationEntry* entry = this->CommandsSection.GetEntries();
|
2004-04-14 22:25:43 +04:00
|
|
|
entry->brief; ++entry)
|
|
|
|
{
|
2007-06-28 19:00:57 +04:00
|
|
|
if(entry->name && this->CurrentArgument == entry->name)
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
|
|
|
this->PrintDocumentationCommand(os, entry);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
for(const cmDocumentationEntry*
|
|
|
|
entry = this->CompatCommandsSection.GetEntries();
|
|
|
|
entry->brief;
|
|
|
|
++entry)
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2007-06-28 19:00:57 +04:00
|
|
|
if(entry->name && this->CurrentArgument == entry->name)
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
|
|
|
this->PrintDocumentationCommand(os, entry);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-14 22:25:43 +04:00
|
|
|
// Argument was not a command. Complain.
|
2007-06-28 19:00:57 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
2004-04-14 22:25:43 +04:00
|
|
|
<< "\" to --help-command is not a CMake command. "
|
|
|
|
<< "Use --help-command-list to see all commands.\n";
|
|
|
|
return false;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationSingleModule(std::ostream& os)
|
|
|
|
{
|
2007-06-28 19:00:57 +04:00
|
|
|
if(this->CurrentArgument.length() == 0)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
|
|
|
os << "Argument --help-module needs a module name.\n";
|
|
|
|
return false;
|
|
|
|
}
|
2006-04-14 07:15:48 +04:00
|
|
|
std::string cmakeModules = this->CMakeRoot;
|
2005-12-14 21:51:08 +03:00
|
|
|
cmakeModules += "/Modules/";
|
2007-06-28 19:00:57 +04:00
|
|
|
cmakeModules += this->CurrentArgument;
|
2005-12-14 21:51:08 +03:00
|
|
|
cmakeModules += ".cmake";
|
2005-12-15 17:19:23 +03:00
|
|
|
if(cmSystemTools::FileExists(cmakeModules.c_str())
|
|
|
|
&& this->CreateSingleModule(cmakeModules.c_str(),
|
2007-06-28 19:00:57 +04:00
|
|
|
this->CurrentArgument.c_str()))
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->PrintDocumentationCommand(os, this->ModulesSection.GetEntries());
|
2006-04-14 07:15:48 +04:00
|
|
|
os << "\n Defined in: ";
|
|
|
|
os << cmakeModules << "\n";
|
2005-12-14 21:51:08 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// Argument was not a module. Complain.
|
2007-06-28 19:00:57 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
2005-12-14 21:51:08 +03:00
|
|
|
<< "\" to --help-module is not a CMake module.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os)
|
|
|
|
{
|
2007-07-11 23:53:58 +04:00
|
|
|
if(this->GlobalPropertiesSection.IsEmpty())
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
|
|
|
os << "Internal error: properties list is empty." << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
if(this->CurrentArgument.length() == 0)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
|
|
|
os << "Argument --help-property needs a property name.\n";
|
|
|
|
return false;
|
|
|
|
}
|
2007-07-11 23:53:58 +04:00
|
|
|
|
|
|
|
for(std::map<cmProperty::ScopeType, cmSection*>::const_iterator
|
|
|
|
sectionIt = this->PropertySections.begin();
|
|
|
|
sectionIt != this->PropertySections.end();
|
|
|
|
++sectionIt)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2007-07-11 23:53:58 +04:00
|
|
|
for(const cmDocumentationEntry*
|
|
|
|
entry = sectionIt->second->GetEntries(); entry->brief; ++entry)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2007-07-11 23:53:58 +04:00
|
|
|
if(entry->name && this->CurrentArgument == entry->name)
|
|
|
|
{
|
|
|
|
this->PrintDocumentationCommand(os, entry);
|
|
|
|
return true;
|
|
|
|
}
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// Argument was not a command. Complain.
|
2007-06-28 19:00:57 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
2006-12-07 17:45:32 +03:00
|
|
|
<< "\" to --help-property is not a CMake property. "
|
|
|
|
<< "Use --help-property-list to see all properties.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-04-14 21:40:24 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintDocumentationList(std::ostream& os)
|
2004-04-14 21:40:24 +04:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
if(this->CommandsSection.IsEmpty())
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
|
|
|
os << "Internal error: commands list is empty." << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
for(const cmDocumentationEntry* entry = this->CommandsSection.GetEntries();
|
2004-04-14 21:40:24 +04:00
|
|
|
entry->brief; ++entry)
|
|
|
|
{
|
|
|
|
if(entry->name)
|
|
|
|
{
|
|
|
|
os << entry->name << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
os << "\nCompatibility commands:" << std::endl;
|
|
|
|
for(const cmDocumentationEntry*
|
|
|
|
entry = this->CompatCommandsSection.GetEntries();
|
|
|
|
entry->brief;
|
|
|
|
++entry)
|
|
|
|
{
|
|
|
|
if(entry->name)
|
|
|
|
{
|
|
|
|
os << entry->name << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
2004-04-14 21:40:24 +04:00
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintPropertyList(std::ostream& os)
|
|
|
|
{
|
2007-07-11 23:53:58 +04:00
|
|
|
if(this->GlobalPropertiesSection.IsEmpty())
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
|
|
|
os << "Internal error: properties list is empty." << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
2007-07-11 23:53:58 +04:00
|
|
|
for(const cmDocumentationEntry*
|
|
|
|
entry = this->GlobalPropertiesSection.GetEntries();
|
|
|
|
entry->brief;
|
|
|
|
++entry)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
|
|
|
if(entry->name)
|
|
|
|
{
|
|
|
|
os << entry->name << std::endl;
|
|
|
|
}
|
|
|
|
}
|
2007-07-11 23:53:58 +04:00
|
|
|
|
|
|
|
for(std::map<cmProperty::ScopeType, cmSection*>::const_iterator
|
|
|
|
sectionIt = this->PropertySections.begin();
|
|
|
|
sectionIt != this->PropertySections.end();
|
|
|
|
++sectionIt)
|
|
|
|
{
|
|
|
|
for(const cmDocumentationEntry*
|
|
|
|
entry = sectionIt->second->GetEntries(); entry->brief; ++entry)
|
|
|
|
{
|
|
|
|
if(entry->name)
|
|
|
|
{
|
|
|
|
os << entry->name << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintModuleList(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->CreateModulesSection();
|
2007-02-01 18:38:42 +03:00
|
|
|
if(this->ModulesSection.IsEmpty())
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
|
|
|
os << "Internal error: modules list is empty." << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
for(const cmDocumentationEntry* entry = this->ModulesSection.GetEntries();
|
2005-12-14 21:51:08 +03:00
|
|
|
entry->brief; ++entry)
|
|
|
|
{
|
|
|
|
if(entry->name)
|
|
|
|
{
|
|
|
|
os << entry->name << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintDocumentationUsage(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->CreateUsageDocumentation();
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Print(os);
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationFull(std::ostream& os)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
|
|
|
this->CreateFullDocumentation();
|
2007-02-01 18:38:42 +03:00
|
|
|
this->PrintHeader(GetNameString(), os);
|
|
|
|
this->Print(os);
|
|
|
|
this->PrintFooter(os);
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
2007-06-28 23:04:28 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationModules(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->CreateModulesDocumentation();
|
|
|
|
this->PrintHeader(GetNameString(), os);
|
|
|
|
this->Print(os);
|
|
|
|
this->PrintFooter(os);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationProperties(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->CreatePropertiesDocumentation();
|
|
|
|
this->PrintHeader(GetNameString(), os);
|
|
|
|
this->Print(os);
|
|
|
|
this->PrintFooter(os);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationCurrentCommands(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->CreateCurrentCommandsDocumentation();
|
|
|
|
this->PrintHeader(GetNameString(), os);
|
|
|
|
this->Print(os);
|
|
|
|
this->PrintFooter(os);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationCompatCommands(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->CreateCompatCommandsDocumentation();
|
|
|
|
this->PrintHeader(GetNameString(), os);
|
|
|
|
this->Print(os);
|
|
|
|
this->PrintFooter(os);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-02-01 18:38:42 +03:00
|
|
|
void cmDocumentation::PrintHeader(const char* name, std::ostream& os)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
switch(this->CurrentForm)
|
|
|
|
{
|
|
|
|
case HTMLForm:
|
2003-02-19 04:42:02 +03:00
|
|
|
os << "<html><body>\n";
|
2007-02-01 18:38:42 +03:00
|
|
|
break;
|
|
|
|
case ManForm:
|
|
|
|
os << ".TH " << name << " 1 \""
|
2003-02-19 04:42:02 +03:00
|
|
|
<< cmSystemTools::GetCurrentDateTime("%B %d, %Y").c_str()
|
2006-05-10 23:01:22 +04:00
|
|
|
<< "\" \"" << this->GetNameString()
|
|
|
|
<< " " << cmVersion::GetCMakeVersion()
|
2004-10-22 23:44:54 +04:00
|
|
|
<< "\"\n";
|
2007-02-01 18:38:42 +03:00
|
|
|
break;
|
|
|
|
case TextForm:
|
|
|
|
case UsageForm:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintFooter(std::ostream& os)
|
|
|
|
{
|
|
|
|
switch(this->CurrentForm)
|
|
|
|
{
|
|
|
|
case HTMLForm:
|
|
|
|
os << "</body></html>\n";
|
|
|
|
break;
|
|
|
|
case ManForm:
|
|
|
|
case TextForm:
|
|
|
|
case UsageForm:
|
|
|
|
break;
|
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
2003-08-06 02:10:45 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::PrintDocumentationCommand(std::ostream& os,
|
2007-06-28 19:00:57 +04:00
|
|
|
const cmDocumentationEntry* entry)
|
2003-08-06 02:10:45 +04:00
|
|
|
{
|
|
|
|
cmDocumentationEntry singleCommandSection[3] =
|
|
|
|
{
|
|
|
|
{entry->name, entry->brief, entry->full},
|
|
|
|
{0,0,0}
|
|
|
|
};
|
|
|
|
this->ClearSections();
|
|
|
|
this->AddSection(0, &singleCommandSection[0]);
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Print(os);
|
2003-08-06 02:10:45 +04:00
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::CreateUsageDocumentation()
|
|
|
|
{
|
|
|
|
this->ClearSections();
|
2007-02-01 18:38:42 +03:00
|
|
|
this->AddSection(this->UsageSection);
|
|
|
|
this->AddSection(this->OptionsSection);
|
|
|
|
this->AddSection(this->GeneratorsSection);
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2003-02-19 04:42:02 +03:00
|
|
|
void cmDocumentation::CreateFullDocumentation()
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
this->ClearSections();
|
2005-12-14 21:51:08 +03:00
|
|
|
this->CreateModulesSection();
|
2007-02-01 18:38:42 +03:00
|
|
|
this->AddSection(this->NameSection);
|
|
|
|
this->AddSection(this->UsageSection);
|
|
|
|
this->AddSection(this->DescriptionSection);
|
|
|
|
this->AddSection(this->OptionsSection);
|
|
|
|
this->AddSection(this->GeneratorsSection);
|
|
|
|
this->AddSection(this->CommandsSection);
|
2007-06-22 16:44:51 +04:00
|
|
|
this->AddSection(this->CompatCommandsSection);
|
2007-02-01 18:38:42 +03:00
|
|
|
this->AddSection(this->ModulesSection);
|
2007-07-11 23:53:58 +04:00
|
|
|
this->AddSection(this->GlobalPropertiesSection);
|
|
|
|
this->AddSection(this->DirectoryPropertiesSection);
|
|
|
|
this->AddSection(this->TargetPropertiesSection);
|
|
|
|
this->AddSection(this->TestPropertiesSection);
|
|
|
|
this->AddSection(this->SourceFilePropertiesSection);
|
|
|
|
this->AddSection(this->VariablePropertiesSection);
|
|
|
|
this->AddSection(this->CachedVariablePropertiesSection);
|
|
|
|
|
2007-02-01 18:38:42 +03:00
|
|
|
this->AddSection(this->CopyrightSection.GetName(this->CurrentForm),
|
|
|
|
cmDocumentationCopyright);
|
|
|
|
|
|
|
|
if(this->CurrentForm == ManForm)
|
|
|
|
{
|
|
|
|
this->AddSection(this->SeeAlsoSection);
|
|
|
|
this->AddSection(this->AuthorSection.GetName(ManForm),
|
|
|
|
cmDocumentationAuthor);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2007-02-01 18:38:42 +03:00
|
|
|
else
|
2006-10-06 22:00:35 +04:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->AddSection(this->SeeAlsoSection.GetName(TextForm),
|
|
|
|
cmDocumentationStandardSeeAlso);
|
2006-10-06 22:00:35 +04:00
|
|
|
}
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
2003-02-17 17:42:13 +03:00
|
|
|
|
2007-06-28 23:04:28 +04:00
|
|
|
void cmDocumentation::CreateCurrentCommandsDocumentation()
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
|
|
|
this->ClearSections();
|
2007-06-28 23:04:28 +04:00
|
|
|
this->AddSection(this->CommandsSection);
|
2007-06-28 19:00:57 +04:00
|
|
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationCopyright);
|
|
|
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationStandardSeeAlso);
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
|
|
|
|
2007-06-28 23:04:28 +04:00
|
|
|
void cmDocumentation::CreateCompatCommandsDocumentation()
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
|
|
|
this->ClearSections();
|
2007-06-28 19:00:57 +04:00
|
|
|
this->AddSection(this->DescriptionSection.GetName(CurrentForm),
|
|
|
|
cmCompatCommandsDocumentationDescription);
|
2007-06-22 16:44:51 +04:00
|
|
|
this->AddSection(this->CompatCommandsSection);
|
2007-06-28 19:00:57 +04:00
|
|
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationCopyright);
|
|
|
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationStandardSeeAlso);
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::CreateModulesDocumentation()
|
2007-06-28 23:04:28 +04:00
|
|
|
{
|
|
|
|
this->ClearSections();
|
|
|
|
this->CreateModulesSection();
|
2007-06-28 19:00:57 +04:00
|
|
|
this->AddSection(this->DescriptionSection.GetName(CurrentForm),
|
|
|
|
cmModulesDocumentationDescription);
|
2007-06-22 16:44:51 +04:00
|
|
|
this->AddSection(this->ModulesSection);
|
2007-06-28 19:00:57 +04:00
|
|
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationCopyright);
|
|
|
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationStandardSeeAlso);
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::CreatePropertiesDocumentation()
|
|
|
|
{
|
|
|
|
this->ClearSections();
|
2007-06-28 19:00:57 +04:00
|
|
|
this->AddSection(this->DescriptionSection.GetName(CurrentForm),
|
|
|
|
cmPropertiesDocumentationDescription);
|
2007-07-11 23:53:58 +04:00
|
|
|
this->AddSection(this->GlobalPropertiesSection);
|
|
|
|
this->AddSection(this->DirectoryPropertiesSection);
|
|
|
|
this->AddSection(this->TargetPropertiesSection);
|
|
|
|
this->AddSection(this->TestPropertiesSection);
|
|
|
|
this->AddSection(this->SourceFilePropertiesSection);
|
|
|
|
this->AddSection(this->VariablePropertiesSection);
|
|
|
|
this->AddSection(this->CachedVariablePropertiesSection);
|
2007-06-28 19:00:57 +04:00
|
|
|
this->AddSection(this->CopyrightSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationCopyright);
|
|
|
|
this->AddSection(this->SeeAlsoSection.GetName(CurrentForm),
|
|
|
|
cmDocumentationStandardSeeAlso);
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
|
|
|
|
2003-02-17 17:42:13 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-02-01 18:38:42 +03:00
|
|
|
void cmDocumentation::cmSection::Set(const cmDocumentationEntry* header,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const cmDocumentationEntry* footer)
|
2003-02-17 17:42:13 +03:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Entries.erase(this->Entries.begin(), this->Entries.end());
|
2003-02-19 04:42:02 +03:00
|
|
|
if(header)
|
2003-02-17 17:42:13 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
for(const cmDocumentationEntry* op = header; op->brief; ++op)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Entries.push_back(*op);
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(section)
|
|
|
|
{
|
|
|
|
for(const cmDocumentationEntry* op = section; op->brief; ++op)
|
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Entries.push_back(*op);
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2003-02-17 17:42:13 +03:00
|
|
|
}
|
2003-02-19 04:42:02 +03:00
|
|
|
if(footer)
|
2003-02-17 17:42:13 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
for(const cmDocumentationEntry* op = footer; op->brief; ++op)
|
2003-02-17 17:42:13 +03:00
|
|
|
{
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Entries.push_back(*op);
|
2003-02-17 17:42:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cmDocumentationEntry empty = {0,0,0};
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Entries.push_back(empty);
|
2003-02-17 17:42:13 +03:00
|
|
|
}
|
2003-08-06 22:49:52 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-01-22 18:52:24 +03:00
|
|
|
const char* cmDocumentation::GetNameString() const
|
2003-08-06 22:49:52 +04:00
|
|
|
{
|
|
|
|
if(this->NameString.length() > 0)
|
|
|
|
{
|
|
|
|
return this->NameString.c_str();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "CMake";
|
|
|
|
}
|
|
|
|
}
|
2004-04-14 22:25:43 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-01-22 18:52:24 +03:00
|
|
|
bool cmDocumentation::IsOption(const char* arg) const
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2006-05-10 23:01:22 +04:00
|
|
|
return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) ||
|
2004-04-14 22:25:43 +04:00
|
|
|
(strcmp(arg, "/?") == 0));
|
|
|
|
}
|