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
|
|
|
#ifndef _cmDocumentation_h
|
|
|
|
#define _cmDocumentation_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
2007-07-11 23:53:58 +04:00
|
|
|
#include "cmProperty.h"
|
2007-09-19 17:05:28 +04:00
|
|
|
#include "cmDocumentationFormatter.h"
|
|
|
|
#include "cmDocumentationFormatterHTML.h"
|
2008-02-19 22:33:43 +03:00
|
|
|
#include "cmDocumentationFormatterDocbook.h"
|
2007-09-19 17:05:28 +04:00
|
|
|
#include "cmDocumentationFormatterMan.h"
|
|
|
|
#include "cmDocumentationFormatterText.h"
|
|
|
|
#include "cmDocumentationFormatterUsage.h"
|
2007-10-22 20:49:09 +04:00
|
|
|
#include "cmDocumentationSection.h"
|
2011-11-15 23:24:38 +04:00
|
|
|
#include "cmake.h"
|
2007-07-02 19:24:44 +04:00
|
|
|
|
2007-09-19 21:14:25 +04:00
|
|
|
namespace cmsys
|
|
|
|
{
|
|
|
|
class Directory;
|
|
|
|
}
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
/** Class to generate documentation. */
|
2007-07-02 19:24:44 +04:00
|
|
|
class cmDocumentation: public cmDocumentationEnums
|
2003-02-14 18:53:37 +03:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmDocumentation();
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
~cmDocumentation();
|
2012-02-04 15:15:57 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An helper type pair for [structured] documented modules.
|
|
|
|
* The comment of those module contains structure markup
|
|
|
|
* which makes it possible to retrieve the documentation
|
|
|
|
* of variables, macros and functions defined in the module.
|
|
|
|
* - first is the filename of the module
|
|
|
|
* - second is the section of the doc the module belongs too
|
|
|
|
*/
|
|
|
|
typedef std::pair<std::string,std::string> documentedModuleSectionPair_t;
|
|
|
|
/**
|
|
|
|
* A list of documented module(s).
|
|
|
|
*/
|
|
|
|
typedef std::list<documentedModuleSectionPair_t> documentedModulesList_t;
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
// High-level interface for standard documents:
|
2003-02-14 18:53:37 +03:00
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
/**
|
|
|
|
* Check command line arguments for documentation options. Returns
|
2003-07-08 06:44:18 +04:00
|
|
|
* true if documentation options are found, and false otherwise.
|
|
|
|
* When true is returned, PrintRequestedDocumentation should be
|
2008-08-19 23:42:48 +04:00
|
|
|
* called. exitOpt can be used for things like cmake -E, so that
|
|
|
|
* all arguments after the -E are ignored and not searched for
|
|
|
|
* help arguments.
|
2003-02-19 04:42:02 +03:00
|
|
|
*/
|
2008-08-19 23:42:48 +04:00
|
|
|
bool CheckOptions(int argc, const char* const* argv,
|
|
|
|
const char* exitOpt =0);
|
2003-07-08 06:44:18 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Print help requested on the command line. Call after
|
|
|
|
* CheckOptions returns true. Returns true on success, and false
|
|
|
|
* otherwise. Failure can occur when output files specified on the
|
|
|
|
* command line cannot be written.
|
|
|
|
*/
|
|
|
|
bool PrintRequestedDocumentation(std::ostream& os);
|
2003-02-19 04:42:02 +03:00
|
|
|
|
|
|
|
/** Print help of the given type. */
|
2008-10-10 19:23:35 +04:00
|
|
|
bool PrintDocumentation(Type ht, std::ostream& os, const char* docname=0);
|
2009-11-24 19:46:06 +03:00
|
|
|
|
|
|
|
void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
|
2003-02-19 04:42:02 +03:00
|
|
|
|
|
|
|
/** Set the program name for standard document generation. */
|
2003-08-06 22:49:52 +04:00
|
|
|
void SetName(const char* name);
|
|
|
|
|
2007-10-22 20:49:09 +04:00
|
|
|
/** Set a section of the documentation. Typical sections include Name,
|
|
|
|
Usage, Description, Options, SeeAlso */
|
|
|
|
void SetSection(const char *sectionName,
|
|
|
|
cmDocumentationSection *section);
|
|
|
|
void SetSection(const char *sectionName,
|
|
|
|
std::vector<cmDocumentationEntry> &docs);
|
|
|
|
void SetSection(const char *sectionName,
|
|
|
|
const char *docs[][3]);
|
|
|
|
void SetSections(std::map<std::string,cmDocumentationSection *>
|
|
|
|
§ions);
|
2007-02-01 18:38:42 +03:00
|
|
|
|
2007-10-22 23:33:19 +04:00
|
|
|
/** Add the documentation to the beginning/end of the section */
|
|
|
|
void PrependSection(const char *sectionName,
|
|
|
|
const char *docs[][3]);
|
2007-10-24 19:36:47 +04:00
|
|
|
void PrependSection(const char *sectionName,
|
|
|
|
std::vector<cmDocumentationEntry> &docs);
|
|
|
|
void PrependSection(const char *sectionName,
|
|
|
|
cmDocumentationEntry &docs);
|
2007-10-22 23:33:19 +04:00
|
|
|
void AppendSection(const char *sectionName,
|
|
|
|
const char *docs[][3]);
|
|
|
|
void AppendSection(const char *sectionName,
|
|
|
|
std::vector<cmDocumentationEntry> &docs);
|
2007-10-24 19:36:47 +04:00
|
|
|
void AppendSection(const char *sectionName,
|
|
|
|
cmDocumentationEntry &docs);
|
2007-10-22 23:33:19 +04:00
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
/**
|
|
|
|
* Print documentation in the given form. All previously added
|
|
|
|
* sections will be generated.
|
|
|
|
*/
|
|
|
|
void Print(Form f, std::ostream& os);
|
|
|
|
|
2007-02-01 18:38:42 +03:00
|
|
|
/**
|
|
|
|
* Print documentation in the current form. All previously added
|
|
|
|
* sections will be generated.
|
|
|
|
*/
|
|
|
|
void Print(std::ostream& os);
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
/**
|
2007-10-22 20:49:09 +04:00
|
|
|
* Add a section of documentation. This can be used to generate custom help
|
|
|
|
* documents.
|
2003-02-19 04:42:02 +03:00
|
|
|
*/
|
2007-10-22 20:49:09 +04:00
|
|
|
void AddSectionToPrint(const char *section);
|
|
|
|
|
|
|
|
void SetSeeAlsoList(const char *data[][3]);
|
2007-02-01 18:38:42 +03:00
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
/** Clear all previously added sections of help. */
|
|
|
|
void ClearSections();
|
2006-04-14 07:15:48 +04:00
|
|
|
|
|
|
|
/** Set cmake root so we can find installed files */
|
|
|
|
void SetCMakeRoot(const char* root) { this->CMakeRoot = root;}
|
2007-09-19 21:14:25 +04:00
|
|
|
|
|
|
|
/** Set CMAKE_MODULE_PATH so we can find additional cmake modules */
|
|
|
|
void SetCMakeModulePath(const char* path) { this->CMakeModulePath = path;}
|
2007-06-28 19:00:57 +04:00
|
|
|
|
|
|
|
static Form GetFormFromFilename(const std::string& filename);
|
|
|
|
|
2011-11-14 01:44:53 +04:00
|
|
|
/** Add common (to all tools) documentation section(s) */
|
|
|
|
void addCommonStandardDocSections();
|
|
|
|
|
|
|
|
/** Add the CMake standard documentation section(s) */
|
|
|
|
void addCMakeStandardDocSections();
|
|
|
|
|
|
|
|
/** Add the CTest standard documentation section(s) */
|
|
|
|
void addCTestStandardDocSections();
|
|
|
|
|
|
|
|
/** Add the CPack standard documentation section(s) */
|
|
|
|
void addCPackStandardDocSections();
|
|
|
|
|
2012-02-04 15:15:57 +04:00
|
|
|
/**
|
|
|
|
* Retrieve the list of documented module located in
|
|
|
|
* path which match the globing expression globExpr.
|
|
|
|
* @param[in] path, directory where to start the search
|
|
|
|
* we will recurse into it.
|
|
|
|
* @param[in] globExpr, the globing expression used to
|
|
|
|
* match the file in path.
|
|
|
|
* @param[out] the list of obtained pairs (may be empty)
|
|
|
|
* @return 0 on success 1 on error or empty list
|
|
|
|
*/
|
|
|
|
int getDocumentedModulesListInDir(
|
|
|
|
std::string path,
|
|
|
|
std::string globExpr,
|
|
|
|
documentedModulesList_t& docModuleList);
|
|
|
|
|
2011-11-15 23:24:38 +04:00
|
|
|
/**
|
2012-01-03 03:54:08 +04:00
|
|
|
* Get the documentation of macros, functions and variable documented
|
2011-11-15 23:24:38 +04:00
|
|
|
* with CMake structured documentation in a CMake script.
|
2012-01-03 03:54:08 +04:00
|
|
|
* (in fact it may be in any file which follow the structured doc format)
|
2011-11-15 23:24:38 +04:00
|
|
|
* Structured documentation begin with
|
|
|
|
* ## (double sharp) in column 1 & 2 immediately followed
|
|
|
|
* by a markup. Those ## are ignored by the legacy module
|
|
|
|
* documentation parser @see CreateSingleModule.
|
2012-02-04 15:15:57 +04:00
|
|
|
* Current markup are ##section, ##module,
|
|
|
|
* ##macro, ##function, ##variable and ##end.
|
2012-01-03 03:54:08 +04:00
|
|
|
* ##end is closing either of the previous ones.
|
2011-11-15 23:24:38 +04:00
|
|
|
* @param[in] fname the script file name to be parsed for documentation
|
|
|
|
* @param[in,out] commands the vector of command/macros documentation
|
|
|
|
* entry found in the script file.
|
|
|
|
* @param[in,out] the cmake object instance to which variable documentation
|
|
|
|
* will be attached (using @see cmake::DefineProperty)
|
2012-01-03 03:54:08 +04:00
|
|
|
* @param[in] the documentation section in which the property will be
|
|
|
|
* inserted.
|
2011-11-15 23:24:38 +04:00
|
|
|
* @return the number of documented items (command and variable)
|
|
|
|
* found in the file.
|
|
|
|
*/
|
2012-01-03 03:54:08 +04:00
|
|
|
int GetStructuredDocFromFile(const char* fname,
|
2011-11-15 23:24:38 +04:00
|
|
|
std::vector<cmDocumentationEntry>& commands,
|
|
|
|
cmake* cm,
|
|
|
|
const char *docSection);
|
2003-02-14 18:53:37 +03:00
|
|
|
private:
|
2007-09-19 17:05:28 +04:00
|
|
|
void SetForm(Form f);
|
2008-10-10 19:23:35 +04:00
|
|
|
void SetDocName(const char* docname);
|
2003-02-19 04:42:02 +03:00
|
|
|
|
2007-09-19 21:14:25 +04:00
|
|
|
bool CreateSingleModule(const char* fname,
|
2007-10-22 20:49:09 +04:00
|
|
|
const char* moduleName,
|
|
|
|
cmDocumentationSection &sec);
|
|
|
|
void CreateModuleDocsForDir(cmsys::Directory& dir,
|
|
|
|
cmDocumentationSection &moduleSection);
|
2005-12-14 21:51:08 +03:00
|
|
|
bool CreateModulesSection();
|
2007-09-19 21:14:25 +04:00
|
|
|
bool CreateCustomModulesSection();
|
2007-10-22 20:49:09 +04:00
|
|
|
void CreateFullDocumentation();
|
|
|
|
|
2008-10-10 19:23:35 +04:00
|
|
|
void AddDocumentIntroToPrint(const char* intro[2]);
|
|
|
|
|
2004-04-14 22:25:43 +04:00
|
|
|
bool PrintCopyright(std::ostream& os);
|
|
|
|
bool PrintVersion(std::ostream& os);
|
2007-10-22 20:49:09 +04:00
|
|
|
bool PrintDocumentationGeneric(std::ostream& os, const char *section);
|
|
|
|
bool PrintDocumentationList(std::ostream& os, const char *section);
|
2004-04-14 22:25:43 +04:00
|
|
|
bool PrintDocumentationSingle(std::ostream& os);
|
2005-12-14 21:51:08 +03:00
|
|
|
bool PrintDocumentationSingleModule(std::ostream& os);
|
2006-12-07 17:45:32 +03:00
|
|
|
bool PrintDocumentationSingleProperty(std::ostream& os);
|
2008-03-04 17:16:33 +03:00
|
|
|
bool PrintDocumentationSinglePolicy(std::ostream& os);
|
2007-10-24 19:36:47 +04:00
|
|
|
bool PrintDocumentationSingleVariable(std::ostream& os);
|
2004-04-14 22:25:43 +04:00
|
|
|
bool PrintDocumentationUsage(std::ostream& os);
|
|
|
|
bool PrintDocumentationFull(std::ostream& os);
|
2007-06-28 23:04:28 +04:00
|
|
|
bool PrintDocumentationModules(std::ostream& os);
|
2007-09-19 21:14:25 +04:00
|
|
|
bool PrintDocumentationCustomModules(std::ostream& os);
|
2008-03-04 17:16:33 +03:00
|
|
|
bool PrintDocumentationPolicies(std::ostream& os);
|
2007-06-28 23:04:28 +04:00
|
|
|
bool PrintDocumentationProperties(std::ostream& os);
|
2007-10-24 19:36:47 +04:00
|
|
|
bool PrintDocumentationVariables(std::ostream& os);
|
2007-06-28 23:04:28 +04:00
|
|
|
bool PrintDocumentationCurrentCommands(std::ostream& os);
|
|
|
|
bool PrintDocumentationCompatCommands(std::ostream& os);
|
2003-08-06 02:10:45 +04:00
|
|
|
void PrintDocumentationCommand(std::ostream& os,
|
2007-10-22 20:49:09 +04:00
|
|
|
const cmDocumentationEntry &entry);
|
2007-09-19 17:05:28 +04:00
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
|
2007-01-22 18:52:24 +03:00
|
|
|
const char* GetNameString() const;
|
2008-10-10 19:23:35 +04:00
|
|
|
const char* GetDocName(bool fallbackToNameString = true) const;
|
|
|
|
const char* GetDefaultDocName(Type ht) const;
|
2007-01-22 18:52:24 +03:00
|
|
|
bool IsOption(const char* arg) const;
|
2003-02-19 04:42:02 +03:00
|
|
|
|
2009-11-24 19:46:06 +03:00
|
|
|
bool ShowGenerators;
|
|
|
|
|
2003-08-06 22:49:52 +04:00
|
|
|
std::string NameString;
|
2008-10-10 19:23:35 +04:00
|
|
|
std::string DocName;
|
2007-10-22 20:49:09 +04:00
|
|
|
std::map<std::string,cmDocumentationSection*> AllSections;
|
2007-07-11 23:53:58 +04:00
|
|
|
|
2003-07-11 07:15:45 +04:00
|
|
|
std::string SeeAlsoString;
|
2006-04-14 07:15:48 +04:00
|
|
|
std::string CMakeRoot;
|
2007-09-19 21:14:25 +04:00
|
|
|
std::string CMakeModulePath;
|
|
|
|
std::set<std::string> ModulesFound;
|
2005-12-14 21:51:08 +03:00
|
|
|
std::vector< char* > ModuleStrings;
|
2007-10-22 20:49:09 +04:00
|
|
|
std::vector<const cmDocumentationSection *> PrintSections;
|
2007-06-28 19:00:57 +04:00
|
|
|
std::string CurrentArgument;
|
|
|
|
|
|
|
|
struct RequestedHelpItem
|
|
|
|
{
|
2007-07-03 16:26:32 +04:00
|
|
|
RequestedHelpItem():HelpForm(TextForm), HelpType(None) {}
|
|
|
|
cmDocumentationEnums::Form HelpForm;
|
|
|
|
cmDocumentationEnums::Type HelpType;
|
2007-06-28 19:00:57 +04:00
|
|
|
std::string Filename;
|
|
|
|
std::string Argument;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<RequestedHelpItem> RequestedHelpItems;
|
2007-09-19 17:05:28 +04:00
|
|
|
cmDocumentationFormatter* CurrentFormatter;
|
|
|
|
cmDocumentationFormatterHTML HTMLFormatter;
|
2008-02-19 22:33:43 +03:00
|
|
|
cmDocumentationFormatterDocbook DocbookFormatter;
|
2007-09-19 17:05:28 +04:00
|
|
|
cmDocumentationFormatterMan ManFormatter;
|
|
|
|
cmDocumentationFormatterText TextFormatter;
|
|
|
|
cmDocumentationFormatterUsage UsageFormatter;
|
2007-10-24 19:36:47 +04:00
|
|
|
|
|
|
|
std::vector<std::string> PropertySections;
|
|
|
|
std::vector<std::string> VariableSections;
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|