2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2003-02-14 18:53:37 +03:00
|
|
|
#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>
|
2012-02-04 15:15:57 +04:00
|
|
|
#include <cmsys/Glob.hxx>
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2012-02-19 03:01:39 +04:00
|
|
|
#include <algorithm>
|
2007-06-28 19:00:57 +04:00
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmDocumentationStandardOptions[][3] =
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
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."},
|
2011-10-12 17:52:20 +04:00
|
|
|
{"--help,-help,-usage,-h,-H,/?", "Print usage information and exit.",
|
2004-04-14 22:25:43 +04:00
|
|
|
"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."},
|
2011-10-12 17:57:22 +04:00
|
|
|
{"--version,-version,/V [file]",
|
|
|
|
"Show program name/version banner and exit.",
|
2003-08-06 02:10:45 +04:00
|
|
|
"If a file is specified, the version is written into it."},
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,0,0}
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
2007-06-22 16:44:51 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmModulesDocumentationDescription[][3] =
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2007-07-20 16:36:16 +04:00
|
|
|
" CMake Modules - Modules coming with CMake, the Cross-Platform Makefile "
|
2007-10-09 22:35:25 +04:00
|
|
|
"Generator.", 0},
|
2007-06-22 16:44:51 +04:00
|
|
|
// CMAKE_DOCUMENTATION_OVERVIEW,
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2007-06-22 16:44:51 +04:00
|
|
|
"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 "
|
2007-10-09 22:35:25 +04:00
|
|
|
"existance of headers to name just a few.", 0},
|
|
|
|
{0,0,0}
|
2007-06-22 16:44:51 +04:00
|
|
|
};
|
|
|
|
|
2007-09-19 21:14:25 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmCustomModulesDocumentationDescription[][3] =
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
|
|
|
" Custom CMake Modules - Additional Modules for CMake.", 0},
|
2007-09-19 21:14:25 +04:00
|
|
|
// CMAKE_DOCUMENTATION_OVERVIEW,
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2007-09-19 21:14:25 +04:00
|
|
|
"This is the documentation for additional modules and scripts for CMake. "
|
|
|
|
"Using these modules you can check the computer system for "
|
|
|
|
"installed software packages, features of the compiler and the "
|
2007-10-09 22:35:25 +04:00
|
|
|
"existance of headers to name just a few.", 0},
|
|
|
|
{0,0,0}
|
2007-09-19 21:14:25 +04:00
|
|
|
};
|
|
|
|
|
2007-06-22 16:44:51 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmPropertiesDocumentationDescription[][3] =
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2007-07-11 23:53:58 +04:00
|
|
|
" CMake Properties - Properties supported by CMake, "
|
2007-10-09 22:35:25 +04:00
|
|
|
"the Cross-Platform Makefile Generator.", 0},
|
2007-06-22 16:44:51 +04:00
|
|
|
// CMAKE_DOCUMENTATION_OVERVIEW,
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2007-06-22 16:44:51 +04:00
|
|
|
"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 "
|
2008-01-10 06:09:19 +03:00
|
|
|
"values of properties the behaviour of the build system can be customized.",
|
2007-10-09 22:35:25 +04:00
|
|
|
0},
|
|
|
|
{0,0,0}
|
2007-06-22 16:44:51 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmCompatCommandsDocumentationDescription[][3] =
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2007-07-11 23:53:58 +04:00
|
|
|
" CMake Compatibility Listfile Commands - "
|
2007-10-09 22:35:25 +04:00
|
|
|
"Obsolete commands supported by CMake for compatibility.", 0},
|
2007-06-22 16:44:51 +04:00
|
|
|
// CMAKE_DOCUMENTATION_OVERVIEW,
|
2007-10-09 22:35:25 +04:00
|
|
|
{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 "
|
2007-10-09 22:35:25 +04:00
|
|
|
"should instead use the newer, faster and shinier new commands. ;-)", 0},
|
|
|
|
{0,0,0}
|
2007-06-22 16:44:51 +04:00
|
|
|
};
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmDocumentationModulesHeader[][3] =
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2005-12-14 21:51:08 +03:00
|
|
|
"The following modules are provided with CMake. "
|
2007-10-09 22:35:25 +04:00
|
|
|
"They can be used with INCLUDE(ModuleName).", 0},
|
|
|
|
{0,0,0}
|
2005-12-14 21:51:08 +03:00
|
|
|
};
|
|
|
|
|
2007-09-19 21:14:25 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmDocumentationCustomModulesHeader[][3] =
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2007-09-19 21:14:25 +04:00
|
|
|
"The following modules are also available for CMake. "
|
2007-10-09 22:35:25 +04:00
|
|
|
"They can be used with INCLUDE(ModuleName).", 0},
|
|
|
|
{0,0,0}
|
2007-09-19 21:14:25 +04:00
|
|
|
};
|
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmDocumentationGeneratorsHeader[][3] =
|
2003-07-08 05:52:10 +04:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
|
|
|
"The following generators are available on this platform:", 0},
|
|
|
|
{0,0,0}
|
2003-07-08 05:52:10 +04:00
|
|
|
};
|
|
|
|
|
2003-02-17 17:56:41 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmDocumentationStandardSeeAlso[][3] =
|
2003-02-17 17:56:41 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
|
|
|
"The following resources are available to get help using CMake:", 0},
|
2006-10-05 18:55:37 +04:00
|
|
|
{"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."},
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2006-10-05 18:55:37 +04:00
|
|
|
"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"
|
2007-10-09 22:35:25 +04:00
|
|
|
, 0},
|
|
|
|
{0,0,0}
|
2003-02-17 17:56:41 +03:00
|
|
|
};
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
static const char *cmDocumentationCopyright[][3] =
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2009-09-28 19:43:28 +04:00
|
|
|
"Copyright 2000-2009 Kitware, Inc., Insight Software Consortium. "
|
2007-10-09 22:35:25 +04:00
|
|
|
"All rights reserved.", 0},
|
|
|
|
{0,
|
2003-02-14 18:53:37 +03:00
|
|
|
"Redistribution and use in source and binary forms, with or without "
|
|
|
|
"modification, are permitted provided that the following conditions are "
|
2007-10-09 22:35:25 +04:00
|
|
|
"met:", 0},
|
2003-02-19 04:42:02 +03:00
|
|
|
{"",
|
2003-02-14 18:53:37 +03:00
|
|
|
"Redistributions of source code must retain the above copyright notice, "
|
2007-10-09 22:35:25 +04:00
|
|
|
"this list of conditions and the following disclaimer.", 0},
|
2003-02-19 04:42:02 +03:00
|
|
|
{"",
|
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.",
|
2007-10-09 22:35:25 +04:00
|
|
|
0},
|
2003-02-19 04:42:02 +03:00
|
|
|
{"",
|
2009-09-28 19:43:28 +04:00
|
|
|
"Neither the names of Kitware, Inc., the Insight Software Consortium, "
|
|
|
|
"nor the names of their contributors may be used to endorse or promote "
|
|
|
|
"products derived from this software without specific prior written "
|
|
|
|
"permission.", 0},
|
2007-10-09 22:35:25 +04:00
|
|
|
{0,
|
2009-09-28 19:43:28 +04:00
|
|
|
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "
|
|
|
|
"\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT "
|
2003-02-14 18:53:37 +03:00
|
|
|
"LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR "
|
2009-09-28 19:43:28 +04:00
|
|
|
"A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT "
|
|
|
|
"HOLDER 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 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.",
|
|
|
|
0},
|
2007-10-09 22:35:25 +04:00
|
|
|
{0, 0, 0}
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
#define DOCUMENT_INTRO(type, default_name, desc) \
|
|
|
|
static char const *cmDocumentation##type##Intro[2] = { default_name, desc };
|
|
|
|
#define GET_DOCUMENT_INTRO(type) cmDocumentation##type##Intro
|
|
|
|
|
|
|
|
DOCUMENT_INTRO(Modules, "cmakemodules",
|
|
|
|
"Reference of available CMake modules.");
|
|
|
|
DOCUMENT_INTRO(CustomModules, "cmakecustommodules",
|
|
|
|
"Reference of available CMake custom modules.");
|
|
|
|
DOCUMENT_INTRO(Policies, "cmakepolicies",
|
|
|
|
"Reference of CMake policies.");
|
|
|
|
DOCUMENT_INTRO(Properties, "cmakeprops",
|
|
|
|
"Reference of CMake properties.");
|
|
|
|
DOCUMENT_INTRO(Variables, "cmakevars",
|
|
|
|
"Reference of CMake variables.");
|
|
|
|
DOCUMENT_INTRO(Commands, "cmakecommands",
|
|
|
|
"Reference of available CMake commands.");
|
|
|
|
DOCUMENT_INTRO(CompatCommands, "cmakecompat",
|
|
|
|
"Reference of CMake compatibility commands.");
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmDocumentation::cmDocumentation()
|
2007-10-22 20:49:09 +04:00
|
|
|
:CurrentFormatter(0)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2012-06-22 01:06:08 +04:00
|
|
|
this->SetForm(TextForm, 0);
|
2011-11-14 01:44:53 +04:00
|
|
|
this->addCommonStandardDocSections();
|
2009-11-24 19:46:06 +03:00
|
|
|
this->ShowGenerators = true;
|
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;
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
for(std::map<std::string,cmDocumentationSection *>::iterator i =
|
2007-10-22 23:33:19 +04:00
|
|
|
this->AllSections.begin();
|
|
|
|
i != this->AllSections.end(); ++i)
|
|
|
|
{
|
|
|
|
delete i->second;
|
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
cmDocumentationSection *sec = this->AllSections["Copyright"];
|
|
|
|
const std::vector<cmDocumentationEntry> &entries = sec->GetEntries();
|
|
|
|
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
|
|
|
|
op != entries.end(); ++op)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if(op->Name.size())
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2003-02-19 04:42:02 +03:00
|
|
|
os << " * ";
|
2007-09-19 17:05:28 +04:00
|
|
|
this->TextFormatter.SetIndent(" ");
|
2007-10-22 20:49:09 +04:00
|
|
|
this->TextFormatter.PrintColumn(os, op->Brief.c_str());
|
2003-02-14 18:53:37 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-19 17:05:28 +04:00
|
|
|
this->TextFormatter.SetIndent("");
|
2007-10-22 20:49:09 +04:00
|
|
|
this->TextFormatter.PrintColumn(os, op->Brief.c_str());
|
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
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
os << this->GetNameString() << " version "
|
2006-05-10 23:01:22 +04:00
|
|
|
<< cmVersion::GetCMakeVersion() << "\n";
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
void cmDocumentation::AddSectionToPrint(const char *section)
|
2007-02-01 18:38:42 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if (this->AllSections.find(section) != this->AllSections.end())
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->PrintSections.push_back(this->AllSections[section]);
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
2007-02-01 18:38:42 +03:00
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::ClearSections()
|
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
this->PrintSections.erase(this->PrintSections.begin(),
|
2007-10-22 20:49:09 +04:00
|
|
|
this->PrintSections.end());
|
2007-12-29 19:53:36 +03:00
|
|
|
this->ModulesFound.clear();
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2008-10-10 19:23:35 +04:00
|
|
|
void cmDocumentation::AddDocumentIntroToPrint(const char* intro[2])
|
|
|
|
{
|
2008-10-11 23:35:30 +04:00
|
|
|
const char* docname = this->GetDocName(false);
|
|
|
|
if(intro && docname)
|
2008-10-10 19:23:35 +04:00
|
|
|
{
|
|
|
|
cmDocumentationSection* section;
|
|
|
|
std::string desc("");
|
|
|
|
|
|
|
|
desc += docname;
|
|
|
|
desc += " - ";
|
|
|
|
desc += intro[1];
|
|
|
|
|
|
|
|
section = new cmDocumentationSection("Introduction", "NAME");
|
|
|
|
section->Append(0, desc.c_str(), 0);
|
|
|
|
this->PrintSections.push_back(section);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentation(Type ht, std::ostream& os,
|
|
|
|
const char* docname)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
if ((this->CurrentFormatter->GetForm() != HTMLForm)
|
2008-02-19 22:33:43 +03:00
|
|
|
&& (this->CurrentFormatter->GetForm() != DocbookForm)
|
2007-09-19 17:05:28 +04:00
|
|
|
&& (this->CurrentFormatter->GetForm() != ManForm))
|
2004-10-22 23:44:54 +04:00
|
|
|
{
|
|
|
|
this->PrintVersion(os);
|
|
|
|
}
|
2007-02-01 18:38:42 +03:00
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
// Handle Document Name. docname==0 disables intro.
|
|
|
|
this->SetDocName("");
|
|
|
|
if (docname)
|
|
|
|
{
|
|
|
|
if (*docname)
|
|
|
|
this->SetDocName(docname);
|
|
|
|
else // empty string was given. select default if possible
|
|
|
|
this->SetDocName(this->GetDefaultDocName(ht));
|
|
|
|
}
|
|
|
|
|
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);
|
2008-03-04 17:16:33 +03:00
|
|
|
case cmDocumentation::SinglePolicy:
|
|
|
|
return this->PrintDocumentationSinglePolicy(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-10-24 19:36:47 +04:00
|
|
|
case cmDocumentation::SingleVariable:
|
|
|
|
return this->PrintDocumentationSingleVariable(os);
|
2007-10-22 20:49:09 +04:00
|
|
|
case cmDocumentation::List:
|
|
|
|
this->PrintDocumentationList(os,"Commands");
|
|
|
|
this->PrintDocumentationList(os,"Compatibility Commands");
|
|
|
|
return true;
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::ModuleList:
|
|
|
|
// find the modules first, print the custom module docs only if
|
2008-01-15 01:05:09 +03:00
|
|
|
// any custom modules have been found actually, Alex
|
|
|
|
this->CreateCustomModulesSection();
|
|
|
|
this->CreateModulesSection();
|
|
|
|
if (this->AllSections.find("Custom CMake Modules")
|
|
|
|
!= this->AllSections.end())
|
|
|
|
{
|
|
|
|
this->PrintDocumentationList(os,"Custom CMake Modules");
|
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
this->PrintDocumentationList(os,"Modules");
|
|
|
|
return true;
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::PropertyList:
|
2007-10-22 23:33:19 +04:00
|
|
|
this->PrintDocumentationList(os,"Properties Description");
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::vector<std::string>::iterator i =
|
2007-10-24 19:36:47 +04:00
|
|
|
this->PropertySections.begin();
|
|
|
|
i != this->PropertySections.end(); ++i)
|
|
|
|
{
|
|
|
|
this->PrintDocumentationList(os,i->c_str());
|
|
|
|
}
|
|
|
|
return true;
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::VariableList:
|
|
|
|
for (std::vector<std::string>::iterator i =
|
2007-10-24 19:36:47 +04:00
|
|
|
this->VariableSections.begin();
|
|
|
|
i != this->VariableSections.end(); ++i)
|
|
|
|
{
|
|
|
|
this->PrintDocumentationList(os,i->c_str());
|
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
return true;
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Full:
|
2007-06-28 23:04:28 +04:00
|
|
|
return this->PrintDocumentationFull(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Modules:
|
2007-06-28 23:04:28 +04:00
|
|
|
return this->PrintDocumentationModules(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::CustomModules:
|
2007-09-19 21:14:25 +04:00
|
|
|
return this->PrintDocumentationCustomModules(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Policies:
|
2008-03-04 17:16:33 +03:00
|
|
|
return this->PrintDocumentationPolicies(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Properties:
|
2007-06-28 23:04:28 +04:00
|
|
|
return this->PrintDocumentationProperties(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Variables:
|
2007-10-24 19:36:47 +04:00
|
|
|
return this->PrintDocumentationVariables(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Commands:
|
2007-06-28 23:04:28 +04:00
|
|
|
return this->PrintDocumentationCurrentCommands(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::CompatCommands:
|
2007-06-28 23:04:28 +04:00
|
|
|
return this->PrintDocumentationCompatCommands(os);
|
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Copyright:
|
2007-06-28 23:04:28 +04:00
|
|
|
return this->PrintCopyright(os);
|
2011-10-13 21:51:18 +04:00
|
|
|
case cmDocumentation::Version:
|
2007-06-28 23:04:28 +04:00
|
|
|
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()
|
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
cmDocumentationSection *sec =
|
2007-10-22 20:49:09 +04:00
|
|
|
new cmDocumentationSection("Standard CMake Modules", "MODULES");
|
|
|
|
this->AllSections["Modules"] = sec;
|
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-10-22 23:33:19 +04:00
|
|
|
sec->Append(cmDocumentationModulesHeader[0]);
|
|
|
|
sec->Append(cmModulesDocumentationDescription);
|
2007-10-22 20:49:09 +04:00
|
|
|
this->CreateModuleDocsForDir(dir, *this->AllSections["Modules"]);
|
2007-09-19 21:14:25 +04:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::CreateCustomModulesSection()
|
|
|
|
{
|
|
|
|
bool sectionHasHeader = false;
|
|
|
|
|
|
|
|
std::vector<std::string> dirs;
|
|
|
|
cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs);
|
|
|
|
|
|
|
|
for(std::vector<std::string>::const_iterator dirIt = dirs.begin();
|
|
|
|
dirIt != dirs.end();
|
|
|
|
++dirIt)
|
|
|
|
{
|
|
|
|
cmsys::Directory dir;
|
|
|
|
dir.Load(dirIt->c_str());
|
|
|
|
if (dir.GetNumberOfFiles() > 0)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-09-19 21:14:25 +04:00
|
|
|
if (!sectionHasHeader)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
cmDocumentationSection *sec =
|
2007-10-22 20:49:09 +04:00
|
|
|
new cmDocumentationSection("Custom CMake Modules","CUSTOM MODULES");
|
|
|
|
this->AllSections["Custom CMake Modules"] = sec;
|
|
|
|
sec->Append(cmDocumentationCustomModulesHeader[0]);
|
2007-10-22 23:33:19 +04:00
|
|
|
sec->Append(cmCustomModulesDocumentationDescription);
|
2007-09-20 16:33:07 +04:00
|
|
|
sectionHasHeader = true;
|
2007-09-19 21:14:25 +04:00
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
this->CreateModuleDocsForDir
|
|
|
|
(dir, *this->AllSections["Custom CMake Modules"]);
|
2007-09-19 21:14:25 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
void cmDocumentation
|
2011-10-13 21:51:18 +04:00
|
|
|
::CreateModuleDocsForDir(cmsys::Directory& dir,
|
2007-10-22 20:49:09 +04:00
|
|
|
cmDocumentationSection &moduleSection)
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
// sort the files alphabetically, so the docs for one module are easier
|
2008-01-10 00:59:01 +03:00
|
|
|
// to find than if they are in random order
|
|
|
|
std::vector<std::string> sortedFiles;
|
2007-09-19 21:14:25 +04:00
|
|
|
for(unsigned int i = 0; i < dir.GetNumberOfFiles(); ++i)
|
2008-01-10 00:59:01 +03:00
|
|
|
{
|
|
|
|
sortedFiles.push_back(dir.GetFile(i));
|
|
|
|
}
|
|
|
|
std::sort(sortedFiles.begin(), sortedFiles.end());
|
|
|
|
|
|
|
|
for(std::vector<std::string>::const_iterator fname = sortedFiles.begin();
|
|
|
|
fname!=sortedFiles.end(); ++fname)
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2008-01-10 00:59:01 +03:00
|
|
|
if(fname->length() > 6)
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2008-01-10 00:59:01 +03:00
|
|
|
if(fname->substr(fname->length()-6, 6) == ".cmake")
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2008-01-10 00:59:01 +03:00
|
|
|
std::string moduleName = fname->substr(0, fname->length()-6);
|
2007-12-29 19:53:36 +03:00
|
|
|
// this check is to avoid creating documentation for the modules with
|
|
|
|
// the same name in multiple directories of CMAKE_MODULE_PATH
|
2007-09-19 21:14:25 +04:00
|
|
|
if (this->ModulesFound.find(moduleName) == this->ModulesFound.end())
|
2007-06-09 00:06:33 +04:00
|
|
|
{
|
2007-09-19 21:14:25 +04:00
|
|
|
this->ModulesFound.insert(moduleName);
|
|
|
|
std::string path = dir.GetPath();
|
2007-06-09 00:06:33 +04:00
|
|
|
path += "/";
|
2008-01-10 00:59:01 +03:00
|
|
|
path += (*fname);
|
2011-10-13 21:51:18 +04:00
|
|
|
this->CreateSingleModule(path.c_str(), moduleName.c_str(),
|
2007-09-20 16:33:07 +04:00
|
|
|
moduleSection);
|
2007-06-09 00:06:33 +04:00
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
2007-09-19 21:14:25 +04:00
|
|
|
}
|
2007-06-09 00:06:33 +04:00
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
bool cmDocumentation::CreateSingleModule(const char* fname,
|
2007-09-19 21:14:25 +04:00
|
|
|
const char* moduleName,
|
2007-10-22 20:49:09 +04:00
|
|
|
cmDocumentationSection &moduleSection)
|
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;
|
2011-10-13 21:51:18 +04:00
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
std::string line;
|
|
|
|
std::string text;
|
|
|
|
std::string brief;
|
|
|
|
brief = " ";
|
|
|
|
bool newParagraph = true;
|
|
|
|
while ( fin && cmSystemTools::GetLineFromStream(fin, line) )
|
|
|
|
{
|
|
|
|
if(line.size() && line[0] == '#')
|
|
|
|
{
|
2011-11-15 23:24:38 +04:00
|
|
|
/* line beginnings with ## are mark-up ignore them */
|
2012-02-01 00:26:44 +04:00
|
|
|
if (line.size()>=2 && line[1] == '#') continue;
|
2005-12-14 21:51:08 +03:00
|
|
|
// blank line
|
|
|
|
if(line.size() <= 2)
|
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
text += "\n";
|
2005-12-14 21:51:08 +03:00
|
|
|
newParagraph = true;
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
else if(line[2] == '-')
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
|
|
|
brief = line.c_str()+4;
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
else
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
|
|
|
// 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
|
|
|
|
{
|
2010-05-08 12:10:19 +04:00
|
|
|
break;
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
|
|
|
}
|
2010-05-08 12:10:19 +04:00
|
|
|
|
|
|
|
if(text.length() < 2 && brief.length() == 1)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
moduleSection.Append(pname, pbrief, ptext);
|
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;
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
// Loop over requested documentation types.
|
2011-10-13 21:51:18 +04:00
|
|
|
for(std::vector<RequestedHelpItem>::const_iterator
|
2007-06-28 19:00:57 +04:00
|
|
|
i = this->RequestedHelpItems.begin();
|
2011-10-13 21:51:18 +04:00
|
|
|
i != this->RequestedHelpItems.end();
|
2007-06-28 19:00:57 +04:00
|
|
|
++i)
|
2003-07-08 06:44:18 +04:00
|
|
|
{
|
2012-06-22 01:06:08 +04:00
|
|
|
this->SetForm(i->HelpForm, i->ManSection);
|
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;
|
2008-10-10 19:23:35 +04:00
|
|
|
std::string docname("");
|
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;
|
|
|
|
}
|
2008-10-10 19:23:35 +04:00
|
|
|
if(i->Filename != "-")
|
|
|
|
{
|
|
|
|
docname = cmSystemTools::GetFilenameWithoutLastExtension(i->Filename);
|
|
|
|
}
|
2003-07-08 06:44:18 +04:00
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
// Print this documentation type to the stream.
|
2008-10-10 19:23:35 +04:00
|
|
|
if(!this->PrintDocumentation(i->HelpType, *s, docname.c_str()) || !*s)
|
2003-07-08 06:44:18 +04:00
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
// Close the file if we wrote one.
|
|
|
|
if(fout)
|
|
|
|
{
|
|
|
|
delete fout;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-08-09 16:48:56 +04:00
|
|
|
#define GET_OPT_ARGUMENT(target) \
|
2007-06-28 19:00:57 +04:00
|
|
|
if((i+1 < argc) && !this->IsOption(argv[i+1])) \
|
|
|
|
{ \
|
|
|
|
target = argv[i+1]; \
|
|
|
|
i = i+1; \
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
cmDocumentation::Form cmDocumentation::GetFormFromFilename(
|
2012-06-22 01:19:55 +04:00
|
|
|
const std::string& filename,
|
|
|
|
int* manSection)
|
2007-06-28 19:00:57 +04:00
|
|
|
{
|
2008-10-10 19:23:17 +04:00
|
|
|
std::string ext = cmSystemTools::GetFilenameLastExtension(filename);
|
2007-06-28 19:00:57 +04:00
|
|
|
ext = cmSystemTools::UpperCase(ext);
|
|
|
|
if ((ext == ".HTM") || (ext == ".HTML"))
|
|
|
|
{
|
|
|
|
return cmDocumentation::HTMLForm;
|
|
|
|
}
|
|
|
|
|
2008-02-19 22:33:43 +03:00
|
|
|
if (ext == ".DOCBOOK")
|
|
|
|
{
|
|
|
|
return cmDocumentation::DocbookForm;
|
|
|
|
}
|
|
|
|
|
2007-06-28 19:00:57 +04:00
|
|
|
// ".1" to ".9" should be manpages
|
|
|
|
if ((ext.length()==2) && (ext[1] >='1') && (ext[1]<='9'))
|
|
|
|
{
|
2012-06-22 01:19:55 +04:00
|
|
|
if (manSection)
|
|
|
|
{
|
|
|
|
*manSection = ext[1] - '0';
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
return cmDocumentation::ManForm;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmDocumentation::TextForm;
|
|
|
|
}
|
|
|
|
|
2011-11-14 01:44:53 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::addCommonStandardDocSections()
|
|
|
|
{
|
|
|
|
cmDocumentationSection *sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("Author","AUTHOR");
|
|
|
|
sec->Append(cmDocumentationEntry
|
|
|
|
(0,
|
|
|
|
"This manual page was generated by the \"--help-man\" option.",
|
|
|
|
0));
|
|
|
|
this->AllSections["Author"] = sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("Copyright","COPYRIGHT");
|
|
|
|
sec->Append(cmDocumentationCopyright);
|
|
|
|
this->AllSections["Copyright"] = sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("See Also","SEE ALSO");
|
|
|
|
sec->Append(cmDocumentationStandardSeeAlso);
|
|
|
|
this->AllSections["Standard See Also"] = sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("Options","OPTIONS");
|
|
|
|
sec->Append(cmDocumentationStandardOptions);
|
|
|
|
this->AllSections["Options"] = sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("Compatibility Commands",
|
|
|
|
"COMPATIBILITY COMMANDS");
|
|
|
|
sec->Append(cmCompatCommandsDocumentationDescription);
|
|
|
|
this->AllSections["Compatibility Commands"] = sec;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::addCMakeStandardDocSections()
|
|
|
|
{
|
|
|
|
cmDocumentationSection *sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("Properties","PROPERTIES");
|
|
|
|
sec->Append(cmPropertiesDocumentationDescription);
|
|
|
|
this->AllSections["Properties Description"] = sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("Generators","GENERATORS");
|
|
|
|
sec->Append(cmDocumentationGeneratorsHeader);
|
|
|
|
this->AllSections["Generators"] = sec;
|
|
|
|
|
|
|
|
this->PropertySections.push_back("Properties of Global Scope");
|
|
|
|
this->PropertySections.push_back("Properties on Directories");
|
|
|
|
this->PropertySections.push_back("Properties on Targets");
|
|
|
|
this->PropertySections.push_back("Properties on Tests");
|
|
|
|
this->PropertySections.push_back("Properties on Source Files");
|
|
|
|
this->PropertySections.push_back("Properties on Cache Entries");
|
|
|
|
|
|
|
|
this->VariableSections.push_back("Variables that Provide Information");
|
|
|
|
this->VariableSections.push_back("Variables That Change Behavior");
|
|
|
|
this->VariableSections.push_back("Variables That Describe the System");
|
|
|
|
this->VariableSections.push_back("Variables that Control the Build");
|
|
|
|
this->VariableSections.push_back("Variables for Languages");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::addCTestStandardDocSections()
|
|
|
|
{
|
|
|
|
// This is currently done for backward compatibility reason
|
|
|
|
// We may suppress some of these.
|
|
|
|
addCMakeStandardDocSections();
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::addCPackStandardDocSections()
|
|
|
|
{
|
|
|
|
cmDocumentationSection *sec;
|
|
|
|
|
|
|
|
sec = new cmDocumentationSection("Generators","GENERATORS");
|
|
|
|
sec->Append(cmDocumentationGeneratorsHeader);
|
|
|
|
this->AllSections["Generators"] = sec;
|
|
|
|
|
|
|
|
this->VariableSections.push_back(
|
|
|
|
"Variables common to all CPack generators");
|
|
|
|
}
|
|
|
|
|
2012-02-19 01:07:39 +04:00
|
|
|
void cmDocumentation::addAutomaticVariableSections(const std::string& section)
|
|
|
|
{
|
|
|
|
std::vector<std::string>::iterator it;
|
2012-02-19 03:01:39 +04:00
|
|
|
it = std::find(this->VariableSections.begin(),
|
|
|
|
this->VariableSections.end(),
|
|
|
|
section);
|
2012-02-19 01:07:39 +04:00
|
|
|
/* if the section does not exist then add it */
|
|
|
|
if (it==this->VariableSections.end())
|
|
|
|
{
|
|
|
|
this->VariableSections.push_back(section);
|
|
|
|
}
|
|
|
|
}
|
2012-02-04 15:15:57 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
int cmDocumentation::getDocumentedModulesListInDir(
|
|
|
|
std::string path,
|
|
|
|
std::string globExpr,
|
|
|
|
documentedModulesList_t& docedModuleList)
|
|
|
|
{
|
|
|
|
cmsys::Glob gl;
|
|
|
|
std::string findExpr;
|
|
|
|
std::vector<std::string> files;
|
|
|
|
std::string line;
|
|
|
|
documentedModuleSectionPair_t docPair;
|
|
|
|
int nbDocumentedModules = 0;
|
|
|
|
|
|
|
|
findExpr = path + "/" + globExpr;
|
|
|
|
if (gl.FindFiles(findExpr))
|
|
|
|
{
|
|
|
|
files = gl.GetFiles();
|
|
|
|
for (std::vector<std::string>::iterator itf=files.begin();
|
|
|
|
itf!=files.end();++itf)
|
|
|
|
{
|
|
|
|
std::ifstream fin((*itf).c_str());
|
|
|
|
// file access trouble ignore it (ignore this kind of error)
|
|
|
|
if (!fin) continue;
|
|
|
|
/* read first line in order to get doc section */
|
|
|
|
if (cmSystemTools::GetLineFromStream(fin, line))
|
|
|
|
{
|
|
|
|
/* Doc section indicates that
|
|
|
|
* this file has structured doc in it.
|
|
|
|
*/
|
|
|
|
if (line.find("##section")!=std::string::npos)
|
|
|
|
{
|
|
|
|
// ok found one more documented module
|
|
|
|
++nbDocumentedModules;
|
|
|
|
docPair.first = *itf;
|
|
|
|
// 10 is the size of '##section' + 1
|
|
|
|
docPair.second = line.substr(10,std::string::npos);
|
|
|
|
docedModuleList.push_back(docPair);
|
|
|
|
}
|
|
|
|
// No else if no section is found (undocumented module)
|
|
|
|
}
|
|
|
|
// No else cannot read first line (ignore this kind of error)
|
2012-02-06 20:20:54 +04:00
|
|
|
line = "";
|
2012-02-04 15:15:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (nbDocumentedModules>0)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-15 23:24:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static void trim(std::string& s)
|
|
|
|
{
|
|
|
|
std::string::size_type pos = s.find_last_not_of(' ');
|
2012-01-25 02:38:22 +04:00
|
|
|
if(pos != std::string::npos)
|
|
|
|
{
|
2011-11-15 23:24:38 +04:00
|
|
|
s.erase(pos + 1);
|
|
|
|
pos = s.find_first_not_of(' ');
|
|
|
|
if(pos != std::string::npos) s.erase(0, pos);
|
2012-01-25 02:38:22 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
s.erase(s.begin(), s.end());
|
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
}
|
|
|
|
|
2012-01-03 03:54:08 +04:00
|
|
|
int cmDocumentation::GetStructuredDocFromFile(
|
2011-11-15 23:24:38 +04:00
|
|
|
const char* fname,
|
|
|
|
std::vector<cmDocumentationEntry>& commands,
|
2012-02-19 01:07:39 +04:00
|
|
|
cmake* cm)
|
2011-11-15 23:24:38 +04:00
|
|
|
{
|
|
|
|
typedef enum sdoce {
|
2012-01-03 03:54:08 +04:00
|
|
|
SDOC_NONE, SDOC_MODULE, SDOC_MACRO, SDOC_FUNCTION, SDOC_VARIABLE,
|
2012-02-02 04:44:21 +04:00
|
|
|
SDOC_SECTION,
|
2011-11-15 23:24:38 +04:00
|
|
|
SDOC_UNKNOWN} sdoc_t;
|
|
|
|
int nbDocItemFound = 0;
|
|
|
|
int docCtxIdx = 0;
|
|
|
|
std::vector<int> docContextStack(60);
|
|
|
|
docContextStack[docCtxIdx]=SDOC_NONE;
|
|
|
|
cmDocumentationEntry e;
|
|
|
|
std::ifstream fin(fname);
|
|
|
|
if(!fin)
|
|
|
|
{
|
|
|
|
return nbDocItemFound;
|
|
|
|
}
|
2012-02-19 01:07:39 +04:00
|
|
|
std::string section;
|
2011-11-15 23:24:38 +04:00
|
|
|
std::string name;
|
|
|
|
std::string full;
|
|
|
|
std::string brief;
|
|
|
|
std::string line;
|
2012-01-03 03:54:08 +04:00
|
|
|
bool newCtx = false; /* we've just entered ##<beginkey> context */
|
|
|
|
bool inBrief = false; /* we are currently parsing brief desc. */
|
|
|
|
bool inFullFirstParagraph = false; /* we are currently parsing full
|
|
|
|
desc. first paragraph */
|
2011-11-15 23:24:38 +04:00
|
|
|
brief = "";
|
|
|
|
full = "";
|
|
|
|
bool newParagraph = true;
|
|
|
|
while ( fin && cmSystemTools::GetLineFromStream(fin, line) )
|
|
|
|
{
|
|
|
|
if(line.size() && line[0] == '#')
|
|
|
|
{
|
|
|
|
/* handle structured doc context */
|
2012-02-02 04:44:21 +04:00
|
|
|
if ((line.size()>=2) && line[1]=='#')
|
2012-01-25 02:38:22 +04:00
|
|
|
{
|
2012-02-02 04:44:21 +04:00
|
|
|
/* markup word is following '##' stopping at first space
|
|
|
|
* Some markup word like 'section' may have more characters
|
|
|
|
* following but we don't handle those here.
|
|
|
|
*/
|
|
|
|
std::string mkword = line.substr(2,line.find(' ',2)-2);
|
2011-11-15 23:24:38 +04:00
|
|
|
if (mkword=="macro")
|
|
|
|
{
|
|
|
|
docCtxIdx++;
|
|
|
|
docContextStack[docCtxIdx]=SDOC_MACRO;
|
|
|
|
newCtx = true;
|
|
|
|
}
|
|
|
|
else if (mkword=="variable")
|
|
|
|
{
|
|
|
|
docCtxIdx++;
|
|
|
|
docContextStack[docCtxIdx]=SDOC_VARIABLE;
|
|
|
|
newCtx = true;
|
|
|
|
}
|
2012-01-03 03:54:08 +04:00
|
|
|
else if (mkword=="function")
|
|
|
|
{
|
|
|
|
docCtxIdx++;
|
|
|
|
docContextStack[docCtxIdx]=SDOC_FUNCTION;
|
|
|
|
newCtx = true;
|
|
|
|
}
|
|
|
|
else if (mkword=="module")
|
|
|
|
{
|
|
|
|
docCtxIdx++;
|
|
|
|
docContextStack[docCtxIdx]=SDOC_MODULE;
|
|
|
|
newCtx = true;
|
|
|
|
}
|
2012-02-02 04:44:21 +04:00
|
|
|
else if (mkword=="section")
|
|
|
|
{
|
|
|
|
docCtxIdx++;
|
|
|
|
docContextStack[docCtxIdx]=SDOC_SECTION;
|
2012-02-19 01:07:39 +04:00
|
|
|
// 10 is the size of '##section' + 1
|
|
|
|
section = line.substr(10,std::string::npos);
|
2012-02-02 04:44:21 +04:00
|
|
|
/* drop the rest of the line */
|
2012-02-06 20:20:54 +04:00
|
|
|
line = "";
|
2012-02-02 04:44:21 +04:00
|
|
|
newCtx = true;
|
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
else if (mkword.substr(0,3)=="end")
|
|
|
|
{
|
|
|
|
switch (docContextStack[docCtxIdx]) {
|
|
|
|
case SDOC_MACRO:
|
2012-01-03 03:54:08 +04:00
|
|
|
/* for now MACRO and FUNCTION are handled in the same way */
|
|
|
|
case SDOC_FUNCTION:
|
2011-11-15 23:24:38 +04:00
|
|
|
commands.push_back(cmDocumentationEntry(name.c_str(),
|
|
|
|
brief.c_str(),full.c_str()));
|
|
|
|
break;
|
|
|
|
case SDOC_VARIABLE:
|
2012-02-19 01:07:39 +04:00
|
|
|
this->addAutomaticVariableSections(section);
|
2011-11-15 23:24:38 +04:00
|
|
|
cm->DefineProperty
|
|
|
|
(name.c_str(), cmProperty::VARIABLE,
|
|
|
|
brief.c_str(),
|
|
|
|
full.c_str(),false,
|
2012-02-19 01:07:39 +04:00
|
|
|
section.c_str());
|
2011-11-15 23:24:38 +04:00
|
|
|
break;
|
2012-01-03 03:54:08 +04:00
|
|
|
case SDOC_MODULE:
|
|
|
|
/* not implemented */
|
|
|
|
break;
|
2012-02-02 04:44:21 +04:00
|
|
|
case SDOC_SECTION:
|
|
|
|
/* not implemented */
|
|
|
|
break;
|
2012-01-03 03:54:08 +04:00
|
|
|
default:
|
|
|
|
/* ignore other cases */
|
|
|
|
break;
|
2011-11-15 23:24:38 +04:00
|
|
|
}
|
|
|
|
docCtxIdx--;
|
|
|
|
newCtx = false;
|
2012-01-03 03:54:08 +04:00
|
|
|
++nbDocItemFound;
|
2011-11-15 23:24:38 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// error out unhandled context
|
|
|
|
return nbDocItemFound;
|
|
|
|
}
|
|
|
|
/* context is set go to next doc line */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now parse the text attached to the context
|
|
|
|
|
|
|
|
// The first line after the context mark-up contains::
|
|
|
|
// name - brief until. (brief is dot terminated or
|
|
|
|
// followed by a blank line)
|
|
|
|
if (newCtx)
|
|
|
|
{
|
2012-01-03 03:54:08 +04:00
|
|
|
// no brief (for easy variable definition)
|
|
|
|
if (line.find("-")==std::string::npos)
|
|
|
|
{
|
|
|
|
name = line.substr(1,std::string::npos);
|
|
|
|
trim(name);
|
|
|
|
brief = "";
|
|
|
|
inBrief = false;
|
|
|
|
full = "";
|
|
|
|
}
|
|
|
|
// here we have a name and brief beginning
|
|
|
|
else
|
|
|
|
{
|
|
|
|
name = line.substr(1,line.find("-")-1);
|
|
|
|
trim(name);
|
|
|
|
// we are parsing the brief context
|
|
|
|
brief = line.substr(line.find("-")+1,std::string::npos);
|
|
|
|
trim(brief);
|
|
|
|
// Brief may already be terminated on the first line
|
|
|
|
if (brief.find('.')!=std::string::npos)
|
|
|
|
{
|
|
|
|
inBrief = false;
|
|
|
|
full = brief.substr(brief.find('.')+1,std::string::npos);
|
|
|
|
trim(full);
|
|
|
|
inFullFirstParagraph = true;
|
|
|
|
brief = brief.substr(0,brief.find('.'));
|
|
|
|
}
|
|
|
|
// brief is continued on following lines
|
|
|
|
else
|
|
|
|
{
|
|
|
|
inBrief = true;
|
|
|
|
full = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
newCtx = false;
|
|
|
|
continue;
|
2011-11-15 23:24:38 +04:00
|
|
|
}
|
|
|
|
// blank line
|
|
|
|
if(line.size() <= 2)
|
|
|
|
{
|
2012-01-03 03:54:08 +04:00
|
|
|
if (inBrief) {
|
|
|
|
inBrief = false;
|
|
|
|
full = "";
|
|
|
|
} else {
|
2012-01-25 02:38:22 +04:00
|
|
|
if (full.length()>0)
|
|
|
|
{
|
|
|
|
full += "\n";
|
|
|
|
}
|
2012-01-03 03:54:08 +04:00
|
|
|
// the first paragraph of full has ended
|
|
|
|
inFullFirstParagraph = false;
|
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
newParagraph = true;
|
|
|
|
}
|
2012-01-03 03:54:08 +04:00
|
|
|
// brief is terminated by '.'
|
|
|
|
else if (inBrief && (line.find('.')!=std::string::npos))
|
2011-11-15 23:24:38 +04:00
|
|
|
{
|
2012-01-03 03:54:08 +04:00
|
|
|
/* the brief just ended */
|
2011-11-15 23:24:38 +04:00
|
|
|
inBrief = false;
|
2012-01-03 03:54:08 +04:00
|
|
|
std::string endBrief = line.substr(1,line.find('.'));
|
|
|
|
trim(endBrief);
|
|
|
|
trim(brief);
|
|
|
|
brief += " " + endBrief;
|
|
|
|
full += line.substr(line.find('.')+1,std::string::npos);
|
|
|
|
trim(full);
|
|
|
|
inFullFirstParagraph = true;
|
2011-11-15 23:24:38 +04:00
|
|
|
}
|
|
|
|
// we handle full text or multi-line brief.
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string* text;
|
2012-01-03 03:54:08 +04:00
|
|
|
if (inBrief)
|
|
|
|
{
|
|
|
|
text = &brief;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
text = &full;
|
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
// two spaces
|
|
|
|
if(line[1] == ' ' && line[2] == ' ')
|
|
|
|
{
|
2012-01-03 03:54:08 +04:00
|
|
|
// there is no "full first paragraph at all."
|
|
|
|
if (line[3] == ' ')
|
2011-11-15 23:24:38 +04:00
|
|
|
{
|
2012-01-03 03:54:08 +04:00
|
|
|
inFullFirstParagraph = false;
|
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
|
2012-01-03 03:54:08 +04:00
|
|
|
if(!newParagraph && !inFullFirstParagraph)
|
|
|
|
{
|
|
|
|
*text += "\n";
|
|
|
|
newParagraph = true;
|
2011-11-15 23:24:38 +04:00
|
|
|
}
|
2012-01-25 02:38:22 +04:00
|
|
|
// Skip #, and leave space for pre-formatted
|
|
|
|
if (inFullFirstParagraph)
|
|
|
|
{
|
|
|
|
std::string temp = line.c_str()+1;
|
|
|
|
trim(temp);
|
|
|
|
*text += " " + temp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*text += line.c_str()+1;
|
|
|
|
*text += "\n";
|
|
|
|
}
|
2011-11-15 23:24:38 +04:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* next line is not the first context line */
|
|
|
|
newCtx = false;
|
|
|
|
}
|
|
|
|
return nbDocItemFound;
|
|
|
|
}
|
|
|
|
|
2003-07-08 06:44:18 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2008-08-19 23:42:48 +04:00
|
|
|
bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
|
|
|
|
const char* exitOpt)
|
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
|
|
|
{
|
2008-08-19 23:42:48 +04:00
|
|
|
if(exitOpt && strcmp(argv[i], exitOpt) == 0)
|
|
|
|
{
|
|
|
|
return result;
|
|
|
|
}
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
2007-10-10 19:47:43 +04:00
|
|
|
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
2007-06-28 19:00:57 +04:00
|
|
|
// 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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2007-06-28 23:04:28 +04:00
|
|
|
}
|
2008-03-04 17:16:33 +03:00
|
|
|
else if(strcmp(argv[i], "--help-policies") == 0)
|
|
|
|
{
|
|
|
|
help.HelpType = cmDocumentation::Policies;
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2008-03-04 17:16:33 +03:00
|
|
|
}
|
2007-10-24 19:36:47 +04:00
|
|
|
else if(strcmp(argv[i], "--help-variables") == 0)
|
|
|
|
{
|
|
|
|
help.HelpType = cmDocumentation::Variables;
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2007-10-24 19:36:47 +04:00
|
|
|
}
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2007-06-28 23:04:28 +04:00
|
|
|
}
|
2007-09-19 21:14:25 +04:00
|
|
|
else if(strcmp(argv[i], "--help-custom-modules") == 0)
|
|
|
|
{
|
|
|
|
help.HelpType = cmDocumentation::CustomModules;
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2007-09-19 21:14:25 +04:00
|
|
|
}
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::ManForm;
|
2012-06-22 01:19:55 +04:00
|
|
|
help.ManSection = 1;
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2007-10-10 19:47:43 +04:00
|
|
|
help.Argument = cmSystemTools::LowerCase(help.Argument);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2008-03-04 17:16:33 +03:00
|
|
|
else if(strcmp(argv[i], "--help-policy") == 0)
|
|
|
|
{
|
|
|
|
help.HelpType = cmDocumentation::SinglePolicy;
|
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2008-03-04 17:16:33 +03:00
|
|
|
}
|
2007-10-24 19:36:47 +04:00
|
|
|
else if(strcmp(argv[i], "--help-variable") == 0)
|
|
|
|
{
|
|
|
|
help.HelpType = cmDocumentation::SingleVariable;
|
|
|
|
GET_OPT_ARGUMENT(help.Argument);
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2012-06-22 01:19:55 +04:00
|
|
|
help.HelpForm = this->GetFormFromFilename(help.Filename,
|
|
|
|
&help.ManSection);
|
2007-10-24 19:36:47 +04: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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::TextForm;
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2007-10-24 19:36:47 +04:00
|
|
|
else if(strcmp(argv[i], "--help-variable-list") == 0)
|
|
|
|
{
|
|
|
|
help.HelpType = cmDocumentation::VariableList;
|
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
|
|
|
help.HelpForm = cmDocumentation::TextForm;
|
|
|
|
}
|
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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(help.Filename);
|
2007-07-03 16:26:32 +04:00
|
|
|
help.HelpForm = cmDocumentation::UsageForm;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
else if((strcmp(argv[i], "--version") == 0) ||
|
|
|
|
(strcmp(argv[i], "-version") == 0) ||
|
2003-07-08 06:44:18 +04:00
|
|
|
(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-08-09 16:48:56 +04:00
|
|
|
GET_OPT_ARGUMENT(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
|
|
|
//----------------------------------------------------------------------------
|
2012-06-22 01:06:08 +04:00
|
|
|
void cmDocumentation::Print(Form f, int manSection, std::ostream& os)
|
2003-02-14 21:06:37 +03:00
|
|
|
{
|
2012-06-22 01:06:08 +04:00
|
|
|
this->SetForm(f, manSection);
|
2007-10-22 20:49:09 +04:00
|
|
|
this->Print(os);
|
2007-02-01 18:38:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::Print(std::ostream& os)
|
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
// if the formatter supports it, print a master index for
|
2008-03-05 19:05:22 +03:00
|
|
|
// all sections
|
|
|
|
this->CurrentFormatter->PrintIndex(os, this->PrintSections);
|
2007-10-22 20:49:09 +04:00
|
|
|
for(unsigned int i=0; i < this->PrintSections.size(); ++i)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
std::string name = this->PrintSections[i]->
|
|
|
|
GetName((this->CurrentFormatter->GetForm()));
|
2011-10-13 21:51:18 +04:00
|
|
|
this->CurrentFormatter->PrintSection(os,*this->PrintSections[i],
|
2007-10-22 20:49:09 +04:00
|
|
|
name.c_str());
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-06 22:49:52 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetName(const char* name)
|
|
|
|
{
|
|
|
|
this->NameString = name?name:"";
|
|
|
|
}
|
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmDocumentation::SetDocName(const char *docname)
|
|
|
|
{
|
|
|
|
this->DocName = docname?docname:"";
|
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::SetSection(const char *name,
|
2007-10-22 20:49:09 +04:00
|
|
|
cmDocumentationSection *section)
|
2003-02-19 04:42:02 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if (this->AllSections.find(name) != this->AllSections.end())
|
|
|
|
{
|
|
|
|
delete this->AllSections[name];
|
|
|
|
}
|
|
|
|
this->AllSections[name] = section;
|
2003-02-19 04:42:02 +03:00
|
|
|
}
|
|
|
|
|
2007-06-22 16:44:51 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::SetSection(const char *name,
|
2007-10-22 20:49:09 +04:00
|
|
|
std::vector<cmDocumentationEntry> &docs)
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
cmDocumentationSection *sec =
|
|
|
|
new cmDocumentationSection(name,
|
2007-10-22 20:49:09 +04:00
|
|
|
cmSystemTools::UpperCase(name).c_str());
|
|
|
|
sec->Append(docs);
|
|
|
|
this->SetSection(name,sec);
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::SetSection(const char *name,
|
2007-10-22 20:49:09 +04:00
|
|
|
const char *docs[][3])
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
cmDocumentationSection *sec =
|
|
|
|
new cmDocumentationSection(name,
|
2007-10-22 20:49:09 +04:00
|
|
|
cmSystemTools::UpperCase(name).c_str());
|
|
|
|
sec->Append(docs);
|
|
|
|
this->SetSection(name,sec);
|
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
|
2007-10-22 20:49:09 +04:00
|
|
|
::SetSections(std::map<std::string,cmDocumentationSection *> §ions)
|
2003-07-08 05:52:10 +04:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::map<std::string,cmDocumentationSection *>::const_iterator
|
2007-10-22 20:49:09 +04:00
|
|
|
it = sections.begin(); it != sections.end(); ++it)
|
|
|
|
{
|
|
|
|
this->SetSection(it->first.c_str(),it->second);
|
2011-10-13 21:51:18 +04:00
|
|
|
}
|
2003-07-08 05:52:10 +04:00
|
|
|
}
|
|
|
|
|
2007-10-22 23:33:19 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::PrependSection(const char *name,
|
2007-10-22 23:33:19 +04:00
|
|
|
const char *docs[][3])
|
|
|
|
{
|
|
|
|
cmDocumentationSection *sec = 0;
|
|
|
|
if (this->AllSections.find(name) == this->AllSections.end())
|
|
|
|
{
|
2007-10-23 18:07:40 +04:00
|
|
|
sec = new cmDocumentationSection
|
|
|
|
(name, cmSystemTools::UpperCase(name).c_str());
|
2007-10-22 23:33:19 +04:00
|
|
|
this->SetSection(name,sec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sec = this->AllSections[name];
|
|
|
|
}
|
|
|
|
sec->Prepend(docs);
|
|
|
|
}
|
|
|
|
|
2007-10-24 19:36:47 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::PrependSection(const char *name,
|
2007-10-24 19:36:47 +04:00
|
|
|
std::vector<cmDocumentationEntry> &docs)
|
|
|
|
{
|
|
|
|
cmDocumentationSection *sec = 0;
|
|
|
|
if (this->AllSections.find(name) == this->AllSections.end())
|
|
|
|
{
|
|
|
|
sec = new cmDocumentationSection
|
|
|
|
(name, cmSystemTools::UpperCase(name).c_str());
|
|
|
|
this->SetSection(name,sec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sec = this->AllSections[name];
|
|
|
|
}
|
|
|
|
sec->Prepend(docs);
|
|
|
|
}
|
|
|
|
|
2007-10-22 23:33:19 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::AppendSection(const char *name,
|
2007-10-22 23:33:19 +04:00
|
|
|
const char *docs[][3])
|
|
|
|
{
|
|
|
|
cmDocumentationSection *sec = 0;
|
|
|
|
if (this->AllSections.find(name) == this->AllSections.end())
|
|
|
|
{
|
2007-10-23 18:07:40 +04:00
|
|
|
sec = new cmDocumentationSection
|
|
|
|
(name, cmSystemTools::UpperCase(name).c_str());
|
2007-10-22 23:33:19 +04:00
|
|
|
this->SetSection(name,sec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sec = this->AllSections[name];
|
|
|
|
}
|
|
|
|
sec->Append(docs);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::AppendSection(const char *name,
|
2007-10-22 23:33:19 +04:00
|
|
|
std::vector<cmDocumentationEntry> &docs)
|
|
|
|
{
|
|
|
|
cmDocumentationSection *sec = 0;
|
|
|
|
if (this->AllSections.find(name) == this->AllSections.end())
|
|
|
|
{
|
2007-10-23 18:07:40 +04:00
|
|
|
sec = new cmDocumentationSection
|
|
|
|
(name, cmSystemTools::UpperCase(name).c_str());
|
2007-10-22 23:33:19 +04:00
|
|
|
this->SetSection(name,sec);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sec = this->AllSections[name];
|
|
|
|
}
|
|
|
|
sec->Append(docs);
|
|
|
|
}
|
|
|
|
|
2007-10-24 19:36:47 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::AppendSection(const char *name,
|
2007-10-24 19:36:47 +04:00
|
|
|
cmDocumentationEntry &docs)
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<cmDocumentationEntry> docsVec;
|
|
|
|
docsVec.push_back(docs);
|
|
|
|
this->AppendSection(name,docsVec);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2011-10-13 21:51:18 +04:00
|
|
|
void cmDocumentation::PrependSection(const char *name,
|
2007-10-24 19:36:47 +04:00
|
|
|
cmDocumentationEntry &docs)
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<cmDocumentationEntry> docsVec;
|
|
|
|
docsVec.push_back(docs);
|
|
|
|
this->PrependSection(name,docsVec);
|
|
|
|
}
|
|
|
|
|
2003-07-11 07:15:45 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
void cmDocumentation::SetSeeAlsoList(const char *data[][3])
|
2003-07-11 07:15:45 +04:00
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
cmDocumentationSection *sec =
|
2007-10-22 20:49:09 +04:00
|
|
|
new cmDocumentationSection("See Also", "SEE ALSO");
|
|
|
|
this->AllSections["See Also"] = sec;
|
2003-07-11 07:15:45 +04:00
|
|
|
this->SeeAlsoString = ".B ";
|
2007-10-22 20:49:09 +04:00
|
|
|
int i = 0;
|
|
|
|
while(data[i][1])
|
2003-07-11 07:15:45 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->SeeAlsoString += data[i][1];
|
2011-10-13 21:51:18 +04:00
|
|
|
this->SeeAlsoString += data[i+1][1]? "(1), ":"(1)";
|
2007-10-22 20:49:09 +04:00
|
|
|
++i;
|
2003-07-11 07:15:45 +04:00
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
sec->Append(0,this->SeeAlsoString.c_str(),0);
|
|
|
|
sec->Append(cmDocumentationStandardSeeAlso);
|
2003-07-11 07:15:45 +04:00
|
|
|
}
|
|
|
|
|
2003-02-14 21:28:46 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
bool cmDocumentation::PrintDocumentationGeneric(std::ostream& os,
|
|
|
|
const char *section)
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if(this->AllSections.find(section) == this->AllSections.end())
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
os << "Internal error: " << section << " list is empty." << std::endl;
|
2004-04-14 22:25:43 +04:00
|
|
|
return false;
|
|
|
|
}
|
2007-06-28 19:00:57 +04:00
|
|
|
if(this->CurrentArgument.length() == 0)
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
os << "Required argument missing.\n";
|
2004-04-14 22:25:43 +04:00
|
|
|
return false;
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
const std::vector<cmDocumentationEntry> &entries =
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AllSections[section]->GetEntries();
|
2011-10-13 21:51:18 +04:00
|
|
|
for(std::vector<cmDocumentationEntry>::const_iterator ei =
|
2007-10-22 20:49:09 +04:00
|
|
|
entries.begin();
|
|
|
|
ei != entries.end(); ++ei)
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if(this->CurrentArgument == ei->Name)
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->PrintDocumentationCommand(os, *ei);
|
2004-04-14 22:25:43 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationSingle(std::ostream& os)
|
|
|
|
{
|
|
|
|
if (this->PrintDocumentationGeneric(os,"Commands"))
|
2007-06-22 16:44:51 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (this->PrintDocumentationGeneric(os,"Compatibility Commands"))
|
|
|
|
{
|
|
|
|
return true;
|
2007-06-22 16:44:51 +04:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2007-09-19 21:14:25 +04:00
|
|
|
std::string moduleName;
|
|
|
|
// find the module
|
|
|
|
std::vector<std::string> dirs;
|
|
|
|
cmSystemTools::ExpandListArgument(this->CMakeModulePath, dirs);
|
|
|
|
for(std::vector<std::string>::const_iterator dirIt = dirs.begin();
|
|
|
|
dirIt != dirs.end();
|
|
|
|
++dirIt)
|
|
|
|
{
|
|
|
|
moduleName = *dirIt;
|
|
|
|
moduleName += "/";
|
|
|
|
moduleName += this->CurrentArgument;
|
|
|
|
moduleName += ".cmake";
|
|
|
|
if(cmSystemTools::FileExists(moduleName.c_str()))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
moduleName = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (moduleName.empty())
|
|
|
|
{
|
|
|
|
moduleName = this->CMakeRoot;
|
|
|
|
moduleName += "/Modules/";
|
|
|
|
moduleName += this->CurrentArgument;
|
|
|
|
moduleName += ".cmake";
|
|
|
|
if(!cmSystemTools::FileExists(moduleName.c_str()))
|
|
|
|
{
|
|
|
|
moduleName = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-29 18:23:26 +03:00
|
|
|
if(!moduleName.empty())
|
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
cmDocumentationSection *sec =
|
2007-11-29 18:23:26 +03:00
|
|
|
new cmDocumentationSection("Standard CMake Modules", "MODULES");
|
|
|
|
this->AllSections["Modules"] = sec;
|
2011-10-13 21:51:18 +04:00
|
|
|
if (this->CreateSingleModule(moduleName.c_str(),
|
2007-09-19 21:14:25 +04:00
|
|
|
this->CurrentArgument.c_str(),
|
2007-10-22 20:49:09 +04:00
|
|
|
*this->AllSections["Modules"]))
|
2007-11-29 18:23:26 +03:00
|
|
|
{
|
2010-03-26 23:57:01 +03:00
|
|
|
if(this->AllSections["Modules"]->GetEntries().size())
|
|
|
|
{
|
|
|
|
this->PrintDocumentationCommand
|
|
|
|
(os, this->AllSections["Modules"]->GetEntries()[0]);
|
|
|
|
os << "\n Defined in: ";
|
|
|
|
os << moduleName << "\n";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2007-11-29 18:23:26 +03:00
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
}
|
2007-11-29 18:23:26 +03:00
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
// Argument was not a module. Complain.
|
2007-06-28 19:00:57 +04:00
|
|
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
2007-09-19 21:14:25 +04:00
|
|
|
<< "\" to --help-module is not a CMake module.\n";
|
2005-12-14 21:51:08 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationSingleProperty(std::ostream& os)
|
|
|
|
{
|
2007-10-24 19:36:47 +04:00
|
|
|
bool done = false;
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::vector<std::string>::iterator i =
|
2007-10-24 19:36:47 +04:00
|
|
|
this->PropertySections.begin();
|
|
|
|
!done && i != this->PropertySections.end(); ++i)
|
2004-04-14 22:25:43 +04:00
|
|
|
{
|
2007-10-24 19:36:47 +04:00
|
|
|
done = this->PrintDocumentationGeneric(os,i->c_str());
|
2004-04-14 22:25:43 +04:00
|
|
|
}
|
2007-10-24 19:36:47 +04:00
|
|
|
|
|
|
|
if (done)
|
2007-06-28 19:00:57 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
return true;
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2007-10-24 19:36:47 +04:00
|
|
|
|
|
|
|
// Argument was not a command. Complain.
|
|
|
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
|
|
|
<< "\" to --help-property is not a CMake property. "
|
|
|
|
<< "Use --help-property-list to see all properties.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-03-04 17:16:33 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationSinglePolicy(std::ostream& os)
|
|
|
|
{
|
|
|
|
if (this->PrintDocumentationGeneric(os,"Policies"))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Argument was not a command. Complain.
|
|
|
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
|
|
|
<< "\" to --help-policy is not a CMake policy.\n";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-10-24 19:36:47 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationSingleVariable(std::ostream& os)
|
|
|
|
{
|
|
|
|
bool done = false;
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::vector<std::string>::iterator i =
|
2007-10-24 19:36:47 +04:00
|
|
|
this->VariableSections.begin();
|
|
|
|
!done && i != this->VariableSections.end(); ++i)
|
2006-12-07 17:45:32 +03:00
|
|
|
{
|
2007-10-24 19:36:47 +04:00
|
|
|
done = this->PrintDocumentationGeneric(os,i->c_str());
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
2007-10-24 19:36:47 +04:00
|
|
|
|
|
|
|
if (done)
|
2007-07-11 23:53:58 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
return true;
|
2007-07-11 23:53:58 +04:00
|
|
|
}
|
|
|
|
|
2007-10-22 20:49:09 +04:00
|
|
|
// Argument was not a command. Complain.
|
|
|
|
os << "Argument \"" << this->CurrentArgument.c_str()
|
2007-10-24 19:36:47 +04:00
|
|
|
<< "\" to --help-variable is not a defined variable. "
|
|
|
|
<< "Use --help-variable-list to see all defined variables.\n";
|
2007-10-22 20:49:09 +04:00
|
|
|
return false;
|
2006-12-07 17:45:32 +03:00
|
|
|
}
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
bool cmDocumentation::PrintDocumentationList(std::ostream& os,
|
|
|
|
const char *section)
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if(this->AllSections.find(section) == this->AllSections.end())
|
2005-12-14 21:51:08 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
os << "Internal error: " << section << " list is empty." << std::endl;
|
2005-12-14 21:51:08 +03:00
|
|
|
return false;
|
|
|
|
}
|
2007-09-19 21:14:25 +04:00
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
const std::vector<cmDocumentationEntry> &entries =
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AllSections[section]->GetEntries();
|
2011-10-13 21:51:18 +04:00
|
|
|
for(std::vector<cmDocumentationEntry>::const_iterator ei =
|
2007-10-22 20:49:09 +04:00
|
|
|
entries.begin();
|
|
|
|
ei != entries.end(); ++ei)
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
if(ei->Name.size())
|
2007-09-19 21:14:25 +04:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
os << ei->Name << std::endl;
|
2007-09-19 21:14:25 +04:00
|
|
|
}
|
|
|
|
}
|
2005-12-14 21:51:08 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
//----------------------------------------------------------------------------
|
2004-04-14 22:25:43 +04:00
|
|
|
bool cmDocumentation::PrintDocumentationUsage(std::ostream& os)
|
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->ClearSections();
|
|
|
|
this->AddSectionToPrint("Usage");
|
|
|
|
this->AddSectionToPrint("Options");
|
2009-11-24 19:46:06 +03:00
|
|
|
if(this->ShowGenerators)
|
|
|
|
{
|
|
|
|
this->AddSectionToPrint("Generators");
|
|
|
|
}
|
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();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetNameString(), GetNameString(), os);
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Print(os);
|
2007-09-19 17:05:28 +04:00
|
|
|
this->CurrentFormatter->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)
|
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->ClearSections();
|
|
|
|
this->CreateModulesSection();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Modules));
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Description");
|
|
|
|
this->AddSectionToPrint("Modules");
|
|
|
|
this->AddSectionToPrint("Copyright");
|
|
|
|
this->AddSectionToPrint("See Also");
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os);
|
2007-06-28 23:04:28 +04:00
|
|
|
this->Print(os);
|
2007-09-19 17:05:28 +04:00
|
|
|
this->CurrentFormatter->PrintFooter(os);
|
2007-06-28 23:04:28 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-09-19 21:14:25 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationCustomModules(std::ostream& os)
|
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->ClearSections();
|
|
|
|
this->CreateCustomModulesSection();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(CustomModules));
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Description");
|
2008-02-17 22:04:01 +03:00
|
|
|
this->AddSectionToPrint("Custom CMake Modules");
|
2008-02-19 22:33:43 +03:00
|
|
|
// the custom modules are most probably not under Kitware's copyright, Alex
|
|
|
|
// this->AddSectionToPrint("Copyright");
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("See Also");
|
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os);
|
2007-09-19 21:14:25 +04:00
|
|
|
this->Print(os);
|
|
|
|
this->CurrentFormatter->PrintFooter(os);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-03-04 17:16:33 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationPolicies(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->ClearSections();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Policies));
|
2008-03-04 17:16:33 +03:00
|
|
|
this->AddSectionToPrint("Description");
|
|
|
|
this->AddSectionToPrint("Policies");
|
|
|
|
this->AddSectionToPrint("Copyright");
|
|
|
|
this->AddSectionToPrint("See Also");
|
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os);
|
2008-03-04 17:16:33 +03:00
|
|
|
this->Print(os);
|
|
|
|
this->CurrentFormatter->PrintFooter(os);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-06-28 23:04:28 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationProperties(std::ostream& os)
|
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->ClearSections();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Properties));
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Properties Description");
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::vector<std::string>::iterator i =
|
2007-10-24 19:36:47 +04:00
|
|
|
this->PropertySections.begin();
|
|
|
|
i != this->PropertySections.end(); ++i)
|
|
|
|
{
|
|
|
|
this->AddSectionToPrint(i->c_str());
|
|
|
|
}
|
|
|
|
this->AddSectionToPrint("Copyright");
|
|
|
|
this->AddSectionToPrint("Standard See Also");
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os);
|
2007-10-24 19:36:47 +04:00
|
|
|
this->Print(os);
|
|
|
|
this->CurrentFormatter->PrintFooter(os);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationVariables(std::ostream& os)
|
|
|
|
{
|
|
|
|
this->ClearSections();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Variables));
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::vector<std::string>::iterator i =
|
2007-10-24 19:36:47 +04:00
|
|
|
this->VariableSections.begin();
|
|
|
|
i != this->VariableSections.end(); ++i)
|
|
|
|
{
|
|
|
|
this->AddSectionToPrint(i->c_str());
|
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Copyright");
|
|
|
|
this->AddSectionToPrint("Standard See Also");
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os);
|
2007-06-28 23:04:28 +04:00
|
|
|
this->Print(os);
|
2007-09-19 17:05:28 +04:00
|
|
|
this->CurrentFormatter->PrintFooter(os);
|
2007-06-28 23:04:28 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationCurrentCommands(std::ostream& os)
|
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->ClearSections();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(Commands));
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Commands");
|
|
|
|
this->AddSectionToPrint("Copyright");
|
|
|
|
this->AddSectionToPrint("Standard See Also");
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os);
|
2007-06-28 23:04:28 +04:00
|
|
|
this->Print(os);
|
2007-09-19 17:05:28 +04:00
|
|
|
this->CurrentFormatter->PrintFooter(os);
|
2007-06-28 23:04:28 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
bool cmDocumentation::PrintDocumentationCompatCommands(std::ostream& os)
|
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->ClearSections();
|
2008-10-10 19:23:35 +04:00
|
|
|
this->AddDocumentIntroToPrint(GET_DOCUMENT_INTRO(CompatCommands));
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Compatibility Commands Description");
|
|
|
|
this->AddSectionToPrint("Compatibility Commands");
|
|
|
|
this->AddSectionToPrint("Copyright");
|
|
|
|
this->AddSectionToPrint("Standard See Also");
|
2008-10-10 19:23:35 +04:00
|
|
|
this->CurrentFormatter->PrintHeader(GetDocName(), GetNameString(), os);
|
2007-06-28 23:04:28 +04:00
|
|
|
this->Print(os);
|
2007-09-19 17:05:28 +04:00
|
|
|
this->CurrentFormatter->PrintFooter(os);
|
2007-06-28 23:04:28 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2003-08-06 02:10:45 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2007-10-22 20:49:09 +04:00
|
|
|
void cmDocumentation
|
|
|
|
::PrintDocumentationCommand(std::ostream& os,
|
|
|
|
const cmDocumentationEntry &entry)
|
2003-08-06 02:10:45 +04:00
|
|
|
{
|
2008-07-22 01:52:59 +04:00
|
|
|
// the string "SingleItem" will be used in a few places to detect the case
|
|
|
|
// that only the documentation for a single item is printed
|
|
|
|
cmDocumentationSection *sec = new cmDocumentationSection("SingleItem","");
|
2007-10-22 20:49:09 +04:00
|
|
|
sec->Append(entry);
|
|
|
|
this->AllSections["temp"] = sec;
|
2003-08-06 02:10:45 +04:00
|
|
|
this->ClearSections();
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("temp");
|
2007-02-01 18:38:42 +03:00
|
|
|
this->Print(os);
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AllSections.erase("temp");
|
|
|
|
delete sec;
|
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();
|
2007-09-19 21:14:25 +04:00
|
|
|
this->CreateCustomModulesSection();
|
2005-12-14 21:51:08 +03:00
|
|
|
this->CreateModulesSection();
|
2007-10-22 20:49:09 +04:00
|
|
|
|
|
|
|
std::set<std::string> emitted;
|
|
|
|
this->AddSectionToPrint("Name");
|
|
|
|
emitted.insert("Name");
|
|
|
|
this->AddSectionToPrint("Usage");
|
|
|
|
emitted.insert("Usage");
|
|
|
|
this->AddSectionToPrint("Description");
|
|
|
|
emitted.insert("Description");
|
|
|
|
this->AddSectionToPrint("Options");
|
|
|
|
emitted.insert("Options");
|
|
|
|
this->AddSectionToPrint("Generators");
|
|
|
|
emitted.insert("Generators");
|
|
|
|
this->AddSectionToPrint("Commands");
|
|
|
|
emitted.insert("Commands");
|
|
|
|
|
2011-10-13 21:51:18 +04:00
|
|
|
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Properties Description");
|
|
|
|
emitted.insert("Properties Description");
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::vector<std::string>::iterator i =
|
2007-10-24 19:36:47 +04:00
|
|
|
this->PropertySections.begin();
|
|
|
|
i != this->PropertySections.end(); ++i)
|
|
|
|
{
|
|
|
|
this->AddSectionToPrint(i->c_str());
|
|
|
|
emitted.insert(i->c_str());
|
|
|
|
}
|
2007-10-22 20:49:09 +04:00
|
|
|
|
|
|
|
emitted.insert("Copyright");
|
|
|
|
emitted.insert("See Also");
|
|
|
|
emitted.insert("Standard See Also");
|
|
|
|
emitted.insert("Author");
|
|
|
|
|
|
|
|
// add any sections not yet written out, or to be written out
|
2011-10-13 21:51:18 +04:00
|
|
|
for (std::map<std::string, cmDocumentationSection*>::iterator i =
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AllSections.begin();
|
|
|
|
i != this->AllSections.end(); ++i)
|
|
|
|
{
|
|
|
|
if (emitted.find(i->first) == emitted.end())
|
|
|
|
{
|
|
|
|
this->AddSectionToPrint(i->first.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
this->AddSectionToPrint("Copyright");
|
2007-02-01 18:38:42 +03:00
|
|
|
|
2007-09-19 17:05:28 +04:00
|
|
|
if(this->CurrentFormatter->GetForm() == ManForm)
|
2007-02-01 18:38:42 +03:00
|
|
|
{
|
2007-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("See Also");
|
|
|
|
this->AddSectionToPrint("Author");
|
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-10-22 20:49:09 +04:00
|
|
|
this->AddSectionToPrint("Standard See Also");
|
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-09-19 17:05:28 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2012-06-22 01:06:08 +04:00
|
|
|
void cmDocumentation::SetForm(Form f, int manSection)
|
2007-09-19 17:05:28 +04:00
|
|
|
{
|
|
|
|
switch(f)
|
|
|
|
{
|
|
|
|
case HTMLForm:
|
|
|
|
this->CurrentFormatter = &this->HTMLFormatter;
|
|
|
|
break;
|
2008-02-19 22:33:43 +03:00
|
|
|
case DocbookForm:
|
|
|
|
this->CurrentFormatter = &this->DocbookFormatter;
|
|
|
|
break;
|
2007-09-19 17:05:28 +04:00
|
|
|
case ManForm:
|
2012-06-22 01:06:08 +04:00
|
|
|
this->ManFormatter.SetManSection(manSection);
|
2007-09-19 17:05:28 +04:00
|
|
|
this->CurrentFormatter = &this->ManFormatter;
|
|
|
|
break;
|
|
|
|
case TextForm:
|
|
|
|
this->CurrentFormatter = &this->TextFormatter;
|
|
|
|
break;
|
|
|
|
case UsageForm:
|
|
|
|
this->CurrentFormatter = & this->UsageFormatter;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
const char* cmDocumentation::GetDocName(bool fallbackToNameString) const
|
|
|
|
{
|
|
|
|
if (this->DocName.length() > 0)
|
|
|
|
{
|
|
|
|
return this->DocName.c_str();
|
|
|
|
}
|
|
|
|
else if (fallbackToNameString)
|
|
|
|
{
|
|
|
|
return this->GetNameString();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
#define CASE_DEFAULT_DOCNAME(doctype) \
|
|
|
|
case cmDocumentation::doctype : \
|
|
|
|
return GET_DOCUMENT_INTRO(doctype)[0];
|
|
|
|
const char* cmDocumentation::GetDefaultDocName(Type ht) const
|
|
|
|
{
|
|
|
|
switch (ht)
|
|
|
|
{
|
|
|
|
CASE_DEFAULT_DOCNAME(Modules)
|
|
|
|
CASE_DEFAULT_DOCNAME(CustomModules)
|
|
|
|
CASE_DEFAULT_DOCNAME(Policies)
|
|
|
|
CASE_DEFAULT_DOCNAME(Properties)
|
|
|
|
CASE_DEFAULT_DOCNAME(Variables)
|
|
|
|
CASE_DEFAULT_DOCNAME(Commands)
|
|
|
|
CASE_DEFAULT_DOCNAME(CompatCommands)
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2011-10-13 21:51:18 +04:00
|
|
|
return ((arg[0] == '-') || (strcmp(arg, "/V") == 0) ||
|
2004-04-14 22:25:43 +04:00
|
|
|
(strcmp(arg, "/?") == 0));
|
|
|
|
}
|