2003-02-14 18:53:37 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
|
|
|
#ifndef _cmDocumentation_h
|
|
|
|
#define _cmDocumentation_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
|
2007-07-02 19:24:44 +04:00
|
|
|
/** This is just a helper class to make it build with MSVC 6.0.
|
|
|
|
Actually the enums and internal classes could directly go into
|
|
|
|
cmDocumentation, but then MSVC6 complains in RequestedHelpItem that
|
|
|
|
cmDocumentation is an undefined type and so it doesn't know the enums.
|
|
|
|
Moving the enums to a class which is then already completely parsed helps.
|
|
|
|
against this. */
|
|
|
|
class cmDocumentationEnums
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Types of help provided. */
|
|
|
|
enum Type
|
|
|
|
{ None, Usage, Single, SingleModule, SingleProperty,
|
|
|
|
List, ModuleList, PropertyList,
|
|
|
|
Full, Properties, Modules, Commands, CompatCommands,
|
|
|
|
Copyright, Version };
|
|
|
|
|
|
|
|
/** Forms of documentation output. */
|
|
|
|
enum Form { TextForm, HTMLForm, ManForm, UsageForm };
|
|
|
|
};
|
|
|
|
|
|
|
|
|
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
|
|
|
|
* called.
|
2003-02-19 04:42:02 +03:00
|
|
|
*/
|
2003-07-24 01:27:34 +04:00
|
|
|
bool CheckOptions(int argc, const char* const* argv);
|
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. */
|
2004-04-14 22:25:43 +04:00
|
|
|
bool PrintDocumentation(Type ht, std::ostream& os);
|
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);
|
|
|
|
|
|
|
|
/** Set the program name section for standard document
|
|
|
|
* generation. */
|
2003-02-19 04:42:02 +03:00
|
|
|
void SetNameSection(const cmDocumentationEntry*);
|
|
|
|
|
|
|
|
/** Set the program usage for standard document generation. */
|
|
|
|
void SetUsageSection(const cmDocumentationEntry*);
|
|
|
|
|
|
|
|
/** Set the program description for standard document generation. */
|
|
|
|
void SetDescriptionSection(const cmDocumentationEntry*);
|
|
|
|
|
|
|
|
/** Set the program options for standard document generation. */
|
|
|
|
void SetOptionsSection(const cmDocumentationEntry*);
|
|
|
|
|
|
|
|
/** Set the listfile commands for standard document generation. */
|
|
|
|
void SetCommandsSection(const cmDocumentationEntry*);
|
|
|
|
|
2007-06-22 16:44:51 +04:00
|
|
|
/** Set the listfile compat. commands for standard document generation. */
|
|
|
|
void SetCompatCommandsSection(const cmDocumentationEntry*);
|
|
|
|
|
2006-12-07 17:45:32 +03:00
|
|
|
/** Set the properties for standard document generation. */
|
|
|
|
void SetPropertiesSection(const cmDocumentationEntry*);
|
|
|
|
|
2003-07-08 05:52:10 +04:00
|
|
|
/** Set the generator descriptions for standard document generation. */
|
|
|
|
void SetGeneratorsSection(const cmDocumentationEntry*);
|
|
|
|
|
2003-07-11 07:15:45 +04:00
|
|
|
/** Set the see-also list of references to the other tools. */
|
|
|
|
void SetSeeAlsoList(const cmDocumentationEntry*);
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
// Low-level interface for custom documents:
|
2007-02-01 18:38:42 +03:00
|
|
|
/** Internal class representing a section of the documentation.
|
|
|
|
* Cares e.g. for the different section titles in the different
|
|
|
|
* output formats.
|
|
|
|
*/
|
|
|
|
class cmSection
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Create a cmSection, with a special name for man-output mode. */
|
|
|
|
cmSection(const char* name, const char* manName)
|
|
|
|
:Name(name), ManName(manName) {}
|
|
|
|
|
|
|
|
/** Has any content been added to this section or is it empty ? */
|
2007-02-02 17:11:41 +03:00
|
|
|
bool IsEmpty() const
|
|
|
|
{ return this->Entries.empty(); }
|
2007-02-01 18:38:42 +03:00
|
|
|
|
|
|
|
/** Clear contents. */
|
2007-02-02 17:11:41 +03:00
|
|
|
void Clear()
|
|
|
|
{ this->Entries.clear(); }
|
2007-02-01 18:38:42 +03:00
|
|
|
|
|
|
|
/** Return the name of this section for the given output form. */
|
2007-02-02 17:11:41 +03:00
|
|
|
const char* GetName(Form form) const
|
|
|
|
{ return (form==ManForm?this->ManName.c_str():this->Name.c_str()); }
|
2007-02-01 18:38:42 +03:00
|
|
|
|
|
|
|
/** Return a pointer to the first entry of this section. */
|
2007-02-02 17:11:41 +03:00
|
|
|
const cmDocumentationEntry *GetEntries() const
|
2007-06-28 19:00:57 +04:00
|
|
|
{ return this->Entries.empty()?&this->EmptySection:&this->Entries[0];}
|
2007-02-01 18:38:42 +03:00
|
|
|
|
|
|
|
/** Append an entry to this section. */
|
2007-02-02 17:11:41 +03:00
|
|
|
void Append(const cmDocumentationEntry& entry)
|
2007-02-02 22:13:51 +03:00
|
|
|
{ this->Entries.push_back(entry); }
|
2007-02-01 18:38:42 +03:00
|
|
|
|
|
|
|
/** Set the contents of this section. */
|
|
|
|
void Set(const cmDocumentationEntry* header,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const cmDocumentationEntry* footer);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string Name;
|
|
|
|
std::string ManName;
|
|
|
|
std::vector<cmDocumentationEntry> Entries;
|
2007-06-28 19:00:57 +04:00
|
|
|
static const cmDocumentationEntry EmptySection;
|
2007-02-01 18:38:42 +03: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
|
|
|
/**
|
|
|
|
* Add a section of documentation. The cmDocumentationEntry pointer
|
|
|
|
* should point at an array terminated by an all zero ({0,0,0})
|
|
|
|
* entry. This can be used to generate custom help documents.
|
|
|
|
*/
|
|
|
|
void AddSection(const char* name, const cmDocumentationEntry* d);
|
|
|
|
|
2007-02-01 18:38:42 +03:00
|
|
|
/** Convenience function, does the same as above */
|
|
|
|
void AddSection(const cmSection& section);
|
|
|
|
|
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-06-28 19:00:57 +04:00
|
|
|
|
|
|
|
static Form GetFormFromFilename(const std::string& filename);
|
|
|
|
|
2003-02-14 18:53:37 +03:00
|
|
|
private:
|
2007-02-01 18:38:42 +03:00
|
|
|
void PrintHeader(const char* title, std::ostream& os);
|
|
|
|
void PrintFooter(std::ostream& os);
|
|
|
|
|
2003-02-19 04:42:02 +03:00
|
|
|
void PrintSection(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name);
|
|
|
|
void PrintSectionText(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name);
|
|
|
|
void PrintSectionHTML(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name);
|
|
|
|
void PrintSectionMan(std::ostream& os, const cmDocumentationEntry* section,
|
2003-02-14 18:53:37 +03:00
|
|
|
const char* name);
|
2003-02-19 04:42:02 +03:00
|
|
|
void PrintSectionUsage(std::ostream& os,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const char* name);
|
|
|
|
void PrintFormatted(std::ostream& os, const char* text);
|
|
|
|
void PrintPreformatted(std::ostream& os, const char* text);
|
|
|
|
void PrintPreformattedText(std::ostream& os, const char* text);
|
|
|
|
void PrintPreformattedHTML(std::ostream& os, const char* text);
|
|
|
|
void PrintPreformattedMan(std::ostream& os, const char* text);
|
|
|
|
void PrintParagraph(std::ostream& os, const char* text);
|
|
|
|
void PrintParagraphText(std::ostream& os, const char* text);
|
|
|
|
void PrintParagraphHTML(std::ostream& os, const char* text);
|
|
|
|
void PrintParagraphMan(std::ostream& os, const char* text);
|
|
|
|
void PrintColumn(std::ostream& os, const char* text);
|
|
|
|
void PrintHTMLEscapes(std::ostream& os, const char* text);
|
|
|
|
|
2005-12-14 21:51:08 +03:00
|
|
|
bool CreateSingleModule(const char* fname, const char* moduleName);
|
|
|
|
bool CreateModulesSection();
|
2004-04-14 22:25:43 +04:00
|
|
|
bool PrintCopyright(std::ostream& os);
|
|
|
|
bool PrintVersion(std::ostream& os);
|
|
|
|
bool PrintDocumentationList(std::ostream& os);
|
2005-12-14 21:51:08 +03:00
|
|
|
bool PrintModuleList(std::ostream& os);
|
2006-12-07 17:45:32 +03:00
|
|
|
bool PrintPropertyList(std::ostream& os);
|
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);
|
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);
|
|
|
|
bool PrintDocumentationProperties(std::ostream& os);
|
|
|
|
bool PrintDocumentationCurrentCommands(std::ostream& os);
|
|
|
|
bool PrintDocumentationCompatCommands(std::ostream& os);
|
2003-08-06 02:10:45 +04:00
|
|
|
void PrintDocumentationCommand(std::ostream& os,
|
2007-06-28 19:00:57 +04:00
|
|
|
const cmDocumentationEntry* entry);
|
2003-02-19 04:42:02 +03:00
|
|
|
|
|
|
|
void CreateUsageDocumentation();
|
|
|
|
void CreateFullDocumentation();
|
2007-06-28 23:04:28 +04:00
|
|
|
void CreateCurrentCommandsDocumentation();
|
|
|
|
void CreateCompatCommandsDocumentation();
|
2007-06-22 16:44:51 +04:00
|
|
|
void CreateModulesDocumentation();
|
|
|
|
void CreatePropertiesDocumentation();
|
2003-02-19 04:42:02 +03:00
|
|
|
|
|
|
|
void SetSection(const cmDocumentationEntry* header,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const cmDocumentationEntry* footer,
|
|
|
|
std::vector<cmDocumentationEntry>&);
|
2007-01-22 18:52:24 +03:00
|
|
|
const char* GetNameString() const;
|
|
|
|
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;
|
2007-02-01 18:38:42 +03:00
|
|
|
cmSection NameSection;
|
|
|
|
cmSection UsageSection;
|
|
|
|
cmSection DescriptionSection;
|
|
|
|
cmSection OptionsSection;
|
|
|
|
cmSection CommandsSection;
|
|
|
|
cmSection CompatCommandsSection;
|
|
|
|
cmSection ModulesSection;
|
|
|
|
cmSection PropertiesSection;
|
|
|
|
cmSection GeneratorsSection;
|
|
|
|
cmSection SeeAlsoSection;
|
|
|
|
cmSection CopyrightSection;
|
|
|
|
cmSection AuthorSection;
|
|
|
|
|
2003-07-11 07:15:45 +04:00
|
|
|
std::string SeeAlsoString;
|
2006-04-14 07:15:48 +04:00
|
|
|
std::string CMakeRoot;
|
2005-12-14 21:51:08 +03:00
|
|
|
std::vector< char* > ModuleStrings;
|
2003-02-19 04:42:02 +03:00
|
|
|
std::vector< const char* > Names;
|
|
|
|
std::vector< const cmDocumentationEntry* > Sections;
|
|
|
|
Form CurrentForm;
|
2007-06-28 19:00:57 +04:00
|
|
|
std::string CurrentArgument;
|
2003-02-19 04:42:02 +03:00
|
|
|
const char* TextIndent;
|
|
|
|
int TextWidth;
|
2007-06-28 19:00:57 +04:00
|
|
|
|
|
|
|
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;
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|