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"
|
|
|
|
|
|
|
|
/** Class to generate documentation. */
|
|
|
|
class cmDocumentation
|
|
|
|
{
|
|
|
|
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
|
|
|
/** Types of help provided. */
|
2005-12-14 21:51:08 +03:00
|
|
|
enum Type { None, Usage, Single, SingleModule, List, ModuleList,
|
|
|
|
Full, HTML, Man, Copyright, Version };
|
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*);
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
/** Forms of documentation output. */
|
|
|
|
enum Form { TextForm, HTMLForm, ManForm, UsageForm };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Print documentation in the given form. All previously added
|
|
|
|
* sections will be generated.
|
|
|
|
*/
|
|
|
|
void Print(Form f, std::ostream& os);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
/** 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;}
|
2003-02-14 18:53:37 +03:00
|
|
|
private:
|
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);
|
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);
|
2004-04-14 22:25:43 +04:00
|
|
|
bool PrintDocumentationUsage(std::ostream& os);
|
|
|
|
bool PrintDocumentationFull(std::ostream& os);
|
|
|
|
bool PrintDocumentationHTML(std::ostream& os);
|
|
|
|
bool PrintDocumentationMan(std::ostream& os);
|
2003-08-06 02:10:45 +04:00
|
|
|
void PrintDocumentationCommand(std::ostream& os,
|
|
|
|
cmDocumentationEntry* entry);
|
2003-02-19 04:42:02 +03:00
|
|
|
|
|
|
|
void CreateUsageDocumentation();
|
|
|
|
void CreateFullDocumentation();
|
|
|
|
void CreateManDocumentation();
|
|
|
|
|
|
|
|
void SetSection(const cmDocumentationEntry* header,
|
|
|
|
const cmDocumentationEntry* section,
|
|
|
|
const cmDocumentationEntry* footer,
|
|
|
|
std::vector<cmDocumentationEntry>&);
|
2003-08-06 22:49:52 +04:00
|
|
|
const char* GetNameString();
|
2004-04-14 22:25:43 +04:00
|
|
|
bool IsOption(const char* arg);
|
2003-02-19 04:42:02 +03:00
|
|
|
|
2003-08-06 22:49:52 +04:00
|
|
|
std::string NameString;
|
2003-02-19 04:42:02 +03:00
|
|
|
std::vector<cmDocumentationEntry> NameSection;
|
|
|
|
std::vector<cmDocumentationEntry> UsageSection;
|
|
|
|
std::vector<cmDocumentationEntry> DescriptionSection;
|
|
|
|
std::vector<cmDocumentationEntry> OptionsSection;
|
|
|
|
std::vector<cmDocumentationEntry> CommandsSection;
|
2005-12-14 21:51:08 +03:00
|
|
|
std::vector<cmDocumentationEntry> ModulesSection;
|
2003-07-08 05:52:10 +04:00
|
|
|
std::vector<cmDocumentationEntry> GeneratorsSection;
|
2003-07-11 07:15:45 +04:00
|
|
|
std::vector<cmDocumentationEntry> SeeAlsoSection;
|
|
|
|
std::string SeeAlsoString;
|
2004-04-14 22:25:43 +04:00
|
|
|
std::string SingleCommand;
|
2005-12-14 21:51:08 +03:00
|
|
|
std::string SingleModuleName;
|
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;
|
|
|
|
const char* TextIndent;
|
|
|
|
int TextWidth;
|
2003-07-08 06:44:18 +04:00
|
|
|
|
|
|
|
typedef std::map<Type, cmStdString> RequestedMapType;
|
|
|
|
RequestedMapType RequestedMap;
|
2003-02-14 18:53:37 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|