2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2003-02-14 15:53:37 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2003-02-14 15:53:37 +00:00
|
|
|
|
2009-09-28 15:43:28 +00: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 15:53:37 +00:00
|
|
|
#ifndef _cmDocumentation_h
|
|
|
|
#define _cmDocumentation_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
2007-07-11 19:53:58 +00:00
|
|
|
#include "cmProperty.h"
|
2007-09-19 13:05:28 +00:00
|
|
|
#include "cmDocumentationFormatter.h"
|
|
|
|
#include "cmDocumentationFormatterHTML.h"
|
2008-02-19 19:33:43 +00:00
|
|
|
#include "cmDocumentationFormatterDocbook.h"
|
2007-09-19 13:05:28 +00:00
|
|
|
#include "cmDocumentationFormatterMan.h"
|
|
|
|
#include "cmDocumentationFormatterText.h"
|
|
|
|
#include "cmDocumentationFormatterUsage.h"
|
2007-10-22 16:49:09 +00:00
|
|
|
#include "cmDocumentationSection.h"
|
2011-11-15 19:24:38 +00:00
|
|
|
#include "cmake.h"
|
2007-07-02 15:24:44 +00:00
|
|
|
|
2007-09-19 17:14:25 +00:00
|
|
|
namespace cmsys
|
|
|
|
{
|
|
|
|
class Directory;
|
|
|
|
}
|
|
|
|
|
2003-02-14 15:53:37 +00:00
|
|
|
/** Class to generate documentation. */
|
2007-07-02 15:24:44 +00:00
|
|
|
class cmDocumentation: public cmDocumentationEnums
|
2003-02-14 15:53:37 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmDocumentation();
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2005-12-14 18:51:08 +00:00
|
|
|
~cmDocumentation();
|
2012-02-04 11:15:57 +00: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 01:42:02 +00:00
|
|
|
// High-level interface for standard documents:
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2003-02-19 01:42:02 +00:00
|
|
|
/**
|
|
|
|
* Check command line arguments for documentation options. Returns
|
2003-07-08 02:44:18 +00:00
|
|
|
* true if documentation options are found, and false otherwise.
|
|
|
|
* When true is returned, PrintRequestedDocumentation should be
|
2012-06-21 21:02:55 +00:00
|
|
|
* called. exitOpt can be used for things like cmake -E, so that
|
2008-08-19 19:42:48 +00:00
|
|
|
* all arguments after the -E are ignored and not searched for
|
|
|
|
* help arguments.
|
2003-02-19 01:42:02 +00:00
|
|
|
*/
|
2012-06-21 21:02:55 +00:00
|
|
|
bool CheckOptions(int argc, const char* const* argv,
|
2008-08-19 19:42:48 +00:00
|
|
|
const char* exitOpt =0);
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2003-07-08 02:44:18 +00: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);
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2003-02-19 01:42:02 +00:00
|
|
|
/** Print help of the given type. */
|
2008-10-10 15:23:35 +00:00
|
|
|
bool PrintDocumentation(Type ht, std::ostream& os, const char* docname=0);
|
2009-11-24 16:46:06 +00:00
|
|
|
|
|
|
|
void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2003-02-19 01:42:02 +00:00
|
|
|
/** Set the program name for standard document generation. */
|
2003-08-06 18:49:52 +00:00
|
|
|
void SetName(const char* name);
|
|
|
|
|
2007-10-22 16:49:09 +00: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 15:38:42 +00:00
|
|
|
|
2007-10-22 19:33:19 +00:00
|
|
|
/** Add the documentation to the beginning/end of the section */
|
|
|
|
void PrependSection(const char *sectionName,
|
|
|
|
const char *docs[][3]);
|
2007-10-24 15:36:47 +00:00
|
|
|
void PrependSection(const char *sectionName,
|
|
|
|
std::vector<cmDocumentationEntry> &docs);
|
|
|
|
void PrependSection(const char *sectionName,
|
|
|
|
cmDocumentationEntry &docs);
|
2007-10-22 19:33:19 +00:00
|
|
|
void AppendSection(const char *sectionName,
|
|
|
|
const char *docs[][3]);
|
|
|
|
void AppendSection(const char *sectionName,
|
|
|
|
std::vector<cmDocumentationEntry> &docs);
|
2007-10-24 15:36:47 +00:00
|
|
|
void AppendSection(const char *sectionName,
|
|
|
|
cmDocumentationEntry &docs);
|
2007-10-22 19:33:19 +00:00
|
|
|
|
2003-02-19 01:42:02 +00:00
|
|
|
/**
|
|
|
|
* Print documentation in the given form. All previously added
|
|
|
|
* sections will be generated.
|
|
|
|
*/
|
2012-06-21 21:06:08 +00:00
|
|
|
void Print(Form f, int manSection, std::ostream& os);
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2007-02-01 15:38:42 +00:00
|
|
|
/**
|
|
|
|
* Print documentation in the current form. All previously added
|
|
|
|
* sections will be generated.
|
|
|
|
*/
|
|
|
|
void Print(std::ostream& os);
|
|
|
|
|
2003-02-19 01:42:02 +00:00
|
|
|
/**
|
2007-10-22 16:49:09 +00:00
|
|
|
* Add a section of documentation. This can be used to generate custom help
|
|
|
|
* documents.
|
2003-02-19 01:42:02 +00:00
|
|
|
*/
|
2007-10-22 16:49:09 +00:00
|
|
|
void AddSectionToPrint(const char *section);
|
|
|
|
|
|
|
|
void SetSeeAlsoList(const char *data[][3]);
|
2007-02-01 15:38:42 +00:00
|
|
|
|
2003-02-19 01:42:02 +00:00
|
|
|
/** Clear all previously added sections of help. */
|
2012-06-21 21:02:55 +00:00
|
|
|
void ClearSections();
|
|
|
|
|
2006-04-14 03:15:48 +00:00
|
|
|
/** Set cmake root so we can find installed files */
|
|
|
|
void SetCMakeRoot(const char* root) { this->CMakeRoot = root;}
|
2007-09-19 17:14:25 +00:00
|
|
|
|
|
|
|
/** Set CMAKE_MODULE_PATH so we can find additional cmake modules */
|
|
|
|
void SetCMakeModulePath(const char* path) { this->CMakeModulePath = path;}
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2012-06-21 21:19:55 +00:00
|
|
|
static Form GetFormFromFilename(const std::string& filename,
|
|
|
|
int* ManSection);
|
2007-06-28 15:00:57 +00:00
|
|
|
|
2011-11-13 21:44:53 +00: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-18 21:07:39 +00:00
|
|
|
/** Add automatic variables sections */
|
|
|
|
void addAutomaticVariableSections(const std::string& section);
|
|
|
|
|
2012-02-04 11:15:57 +00:00
|
|
|
/**
|
|
|
|
* Retrieve the list of documented module located in
|
|
|
|
* path which match the globing expression globExpr.
|
2013-09-19 17:08:38 +00:00
|
|
|
* @param[in] path directory where to start the search
|
2012-02-04 11:15:57 +00:00
|
|
|
* we will recurse into it.
|
2013-09-19 17:08:38 +00:00
|
|
|
* @param[in] globExpr the globing expression used to
|
2012-02-04 11:15:57 +00:00
|
|
|
* match the file in path.
|
2013-09-19 17:08:38 +00:00
|
|
|
* @param[out] docModuleList the list of obtained pairs (may be empty)
|
2012-02-04 11:15:57 +00:00
|
|
|
* @return 0 on success 1 on error or empty list
|
|
|
|
*/
|
|
|
|
int getDocumentedModulesListInDir(
|
|
|
|
std::string path,
|
|
|
|
std::string globExpr,
|
|
|
|
documentedModulesList_t& docModuleList);
|
|
|
|
|
2011-11-15 19:24:38 +00:00
|
|
|
/**
|
2012-01-02 23:54:08 +00:00
|
|
|
* Get the documentation of macros, functions and variable documented
|
2011-11-15 19:24:38 +00:00
|
|
|
* with CMake structured documentation in a CMake script.
|
2012-01-02 23:54:08 +00:00
|
|
|
* (in fact it may be in any file which follow the structured doc format)
|
2011-11-15 19:24:38 +00: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 11:15:57 +00:00
|
|
|
* Current markup are ##section, ##module,
|
|
|
|
* ##macro, ##function, ##variable and ##end.
|
2012-01-02 23:54:08 +00:00
|
|
|
* ##end is closing either of the previous ones.
|
2011-11-15 19:24:38 +00: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.
|
2013-09-19 17:08:38 +00:00
|
|
|
* @param[in,out] cm the cmake object instance to which variable
|
|
|
|
* documentation will be attached
|
|
|
|
* (using @see cmake::DefineProperty)
|
2011-11-15 19:24:38 +00:00
|
|
|
* @return the number of documented items (command and variable)
|
|
|
|
* found in the file.
|
|
|
|
*/
|
2012-01-02 23:54:08 +00:00
|
|
|
int GetStructuredDocFromFile(const char* fname,
|
2011-11-15 19:24:38 +00:00
|
|
|
std::vector<cmDocumentationEntry>& commands,
|
2012-02-18 21:07:39 +00:00
|
|
|
cmake* cm);
|
2003-02-14 15:53:37 +00:00
|
|
|
private:
|
2012-06-21 21:06:08 +00:00
|
|
|
void SetForm(Form f, int manSection);
|
2008-10-10 15:23:35 +00:00
|
|
|
void SetDocName(const char* docname);
|
2003-02-19 01:42:02 +00:00
|
|
|
|
2012-06-21 21:02:55 +00:00
|
|
|
bool CreateSingleModule(const char* fname,
|
2007-10-22 16:49:09 +00:00
|
|
|
const char* moduleName,
|
|
|
|
cmDocumentationSection &sec);
|
2012-06-21 21:02:55 +00:00
|
|
|
void CreateModuleDocsForDir(cmsys::Directory& dir,
|
2007-10-22 16:49:09 +00:00
|
|
|
cmDocumentationSection &moduleSection);
|
2005-12-14 18:51:08 +00:00
|
|
|
bool CreateModulesSection();
|
2007-09-19 17:14:25 +00:00
|
|
|
bool CreateCustomModulesSection();
|
2007-10-22 16:49:09 +00:00
|
|
|
void CreateFullDocumentation();
|
|
|
|
|
2008-10-10 15:23:35 +00:00
|
|
|
void AddDocumentIntroToPrint(const char* intro[2]);
|
|
|
|
|
2004-04-14 18:25:43 +00:00
|
|
|
bool PrintCopyright(std::ostream& os);
|
|
|
|
bool PrintVersion(std::ostream& os);
|
2007-10-22 16:49:09 +00:00
|
|
|
bool PrintDocumentationGeneric(std::ostream& os, const char *section);
|
|
|
|
bool PrintDocumentationList(std::ostream& os, const char *section);
|
2004-04-14 18:25:43 +00:00
|
|
|
bool PrintDocumentationSingle(std::ostream& os);
|
2005-12-14 18:51:08 +00:00
|
|
|
bool PrintDocumentationSingleModule(std::ostream& os);
|
2006-12-07 14:45:32 +00:00
|
|
|
bool PrintDocumentationSingleProperty(std::ostream& os);
|
2008-03-04 14:16:33 +00:00
|
|
|
bool PrintDocumentationSinglePolicy(std::ostream& os);
|
2007-10-24 15:36:47 +00:00
|
|
|
bool PrintDocumentationSingleVariable(std::ostream& os);
|
2004-04-14 18:25:43 +00:00
|
|
|
bool PrintDocumentationUsage(std::ostream& os);
|
|
|
|
bool PrintDocumentationFull(std::ostream& os);
|
2007-06-28 19:04:28 +00:00
|
|
|
bool PrintDocumentationModules(std::ostream& os);
|
2007-09-19 17:14:25 +00:00
|
|
|
bool PrintDocumentationCustomModules(std::ostream& os);
|
2008-03-04 14:16:33 +00:00
|
|
|
bool PrintDocumentationPolicies(std::ostream& os);
|
2007-06-28 19:04:28 +00:00
|
|
|
bool PrintDocumentationProperties(std::ostream& os);
|
2007-10-24 15:36:47 +00:00
|
|
|
bool PrintDocumentationVariables(std::ostream& os);
|
2007-06-28 19:04:28 +00:00
|
|
|
bool PrintDocumentationCurrentCommands(std::ostream& os);
|
|
|
|
bool PrintDocumentationCompatCommands(std::ostream& os);
|
2003-08-05 22:10:45 +00:00
|
|
|
void PrintDocumentationCommand(std::ostream& os,
|
2007-10-22 16:49:09 +00:00
|
|
|
const cmDocumentationEntry &entry);
|
2007-09-19 13:05:28 +00:00
|
|
|
|
2003-02-19 01:42:02 +00:00
|
|
|
|
2007-01-22 15:52:24 +00:00
|
|
|
const char* GetNameString() const;
|
2008-10-10 15:23:35 +00:00
|
|
|
const char* GetDocName(bool fallbackToNameString = true) const;
|
|
|
|
const char* GetDefaultDocName(Type ht) const;
|
2007-01-22 15:52:24 +00:00
|
|
|
bool IsOption(const char* arg) const;
|
2003-02-19 01:42:02 +00:00
|
|
|
|
2009-11-24 16:46:06 +00:00
|
|
|
bool ShowGenerators;
|
|
|
|
|
2003-08-06 18:49:52 +00:00
|
|
|
std::string NameString;
|
2008-10-10 15:23:35 +00:00
|
|
|
std::string DocName;
|
2007-10-22 16:49:09 +00:00
|
|
|
std::map<std::string,cmDocumentationSection*> AllSections;
|
2012-06-21 21:02:55 +00:00
|
|
|
|
2003-07-11 03:15:45 +00:00
|
|
|
std::string SeeAlsoString;
|
2006-04-14 03:15:48 +00:00
|
|
|
std::string CMakeRoot;
|
2007-09-19 17:14:25 +00:00
|
|
|
std::string CMakeModulePath;
|
|
|
|
std::set<std::string> ModulesFound;
|
2005-12-14 18:51:08 +00:00
|
|
|
std::vector< char* > ModuleStrings;
|
2007-10-22 16:49:09 +00:00
|
|
|
std::vector<const cmDocumentationSection *> PrintSections;
|
2007-06-28 15:00:57 +00:00
|
|
|
std::string CurrentArgument;
|
|
|
|
|
|
|
|
struct RequestedHelpItem
|
|
|
|
{
|
2012-06-21 21:06:08 +00:00
|
|
|
RequestedHelpItem():HelpForm(TextForm), HelpType(None), ManSection(1) {}
|
2007-07-03 12:26:32 +00:00
|
|
|
cmDocumentationEnums::Form HelpForm;
|
|
|
|
cmDocumentationEnums::Type HelpType;
|
2007-06-28 15:00:57 +00:00
|
|
|
std::string Filename;
|
|
|
|
std::string Argument;
|
2012-06-21 21:06:08 +00:00
|
|
|
int ManSection;
|
2007-06-28 15:00:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<RequestedHelpItem> RequestedHelpItems;
|
2007-09-19 13:05:28 +00:00
|
|
|
cmDocumentationFormatter* CurrentFormatter;
|
|
|
|
cmDocumentationFormatterHTML HTMLFormatter;
|
2008-02-19 19:33:43 +00:00
|
|
|
cmDocumentationFormatterDocbook DocbookFormatter;
|
2007-09-19 13:05:28 +00:00
|
|
|
cmDocumentationFormatterMan ManFormatter;
|
|
|
|
cmDocumentationFormatterText TextFormatter;
|
|
|
|
cmDocumentationFormatterUsage UsageFormatter;
|
2007-10-24 15:36:47 +00:00
|
|
|
|
|
|
|
std::vector<std::string> PropertySections;
|
|
|
|
std::vector<std::string> VariableSections;
|
2003-02-14 15:53:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|