2009-10-02 01:21: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-10-02 01:21: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-10-02 01:21: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"
|
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();
|
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);
|
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);
|
|
|
|
|
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
|
|
|
|
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
|