cmDocumentation.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef _cmDocumentation_h
  14. #define _cmDocumentation_h
  15. #include "cmStandardIncludes.h"
  16. /** Class to generate documentation. */
  17. class cmDocumentation
  18. {
  19. public:
  20. cmDocumentation();
  21. ~cmDocumentation();
  22. // High-level interface for standard documents:
  23. /** Types of help provided. */
  24. enum Type { None, Usage, Single, SingleModule, List, ModuleList,
  25. Full, HTML, Man, Copyright, Version };
  26. /**
  27. * Check command line arguments for documentation options. Returns
  28. * true if documentation options are found, and false otherwise.
  29. * When true is returned, PrintRequestedDocumentation should be
  30. * called.
  31. */
  32. bool CheckOptions(int argc, const char* const* argv);
  33. /**
  34. * Print help requested on the command line. Call after
  35. * CheckOptions returns true. Returns true on success, and false
  36. * otherwise. Failure can occur when output files specified on the
  37. * command line cannot be written.
  38. */
  39. bool PrintRequestedDocumentation(std::ostream& os);
  40. /** Print help of the given type. */
  41. bool PrintDocumentation(Type ht, std::ostream& os);
  42. /** Set the program name for standard document generation. */
  43. void SetName(const char* name);
  44. /** Set the program name section for standard document
  45. * generation. */
  46. void SetNameSection(const cmDocumentationEntry*);
  47. /** Set the program usage for standard document generation. */
  48. void SetUsageSection(const cmDocumentationEntry*);
  49. /** Set the program description for standard document generation. */
  50. void SetDescriptionSection(const cmDocumentationEntry*);
  51. /** Set the program options for standard document generation. */
  52. void SetOptionsSection(const cmDocumentationEntry*);
  53. /** Set the listfile commands for standard document generation. */
  54. void SetCommandsSection(const cmDocumentationEntry*);
  55. /** Set the generator descriptions for standard document generation. */
  56. void SetGeneratorsSection(const cmDocumentationEntry*);
  57. /** Set the see-also list of references to the other tools. */
  58. void SetSeeAlsoList(const cmDocumentationEntry*);
  59. // Low-level interface for custom documents:
  60. /** Forms of documentation output. */
  61. enum Form { TextForm, HTMLForm, ManForm, UsageForm };
  62. /**
  63. * Print documentation in the given form. All previously added
  64. * sections will be generated.
  65. */
  66. void Print(Form f, std::ostream& os);
  67. /**
  68. * Add a section of documentation. The cmDocumentationEntry pointer
  69. * should point at an array terminated by an all zero ({0,0,0})
  70. * entry. This can be used to generate custom help documents.
  71. */
  72. void AddSection(const char* name, const cmDocumentationEntry* d);
  73. /** Clear all previously added sections of help. */
  74. void ClearSections();
  75. /** Set cmake root so we can find installed files */
  76. void SetCMakeRoot(const char* root) { this->CMakeRoot = root;}
  77. private:
  78. void PrintSection(std::ostream& os,
  79. const cmDocumentationEntry* section,
  80. const char* name);
  81. void PrintSectionText(std::ostream& os,
  82. const cmDocumentationEntry* section,
  83. const char* name);
  84. void PrintSectionHTML(std::ostream& os,
  85. const cmDocumentationEntry* section,
  86. const char* name);
  87. void PrintSectionMan(std::ostream& os, const cmDocumentationEntry* section,
  88. const char* name);
  89. void PrintSectionUsage(std::ostream& os,
  90. const cmDocumentationEntry* section,
  91. const char* name);
  92. void PrintFormatted(std::ostream& os, const char* text);
  93. void PrintPreformatted(std::ostream& os, const char* text);
  94. void PrintPreformattedText(std::ostream& os, const char* text);
  95. void PrintPreformattedHTML(std::ostream& os, const char* text);
  96. void PrintPreformattedMan(std::ostream& os, const char* text);
  97. void PrintParagraph(std::ostream& os, const char* text);
  98. void PrintParagraphText(std::ostream& os, const char* text);
  99. void PrintParagraphHTML(std::ostream& os, const char* text);
  100. void PrintParagraphMan(std::ostream& os, const char* text);
  101. void PrintColumn(std::ostream& os, const char* text);
  102. void PrintHTMLEscapes(std::ostream& os, const char* text);
  103. bool CreateSingleModule(const char* fname, const char* moduleName);
  104. bool CreateModulesSection();
  105. bool PrintCopyright(std::ostream& os);
  106. bool PrintVersion(std::ostream& os);
  107. bool PrintDocumentationList(std::ostream& os);
  108. bool PrintModuleList(std::ostream& os);
  109. bool PrintDocumentationSingle(std::ostream& os);
  110. bool PrintDocumentationSingleModule(std::ostream& os);
  111. bool PrintDocumentationUsage(std::ostream& os);
  112. bool PrintDocumentationFull(std::ostream& os);
  113. bool PrintDocumentationHTML(std::ostream& os);
  114. bool PrintDocumentationMan(std::ostream& os);
  115. void PrintDocumentationCommand(std::ostream& os,
  116. cmDocumentationEntry* entry);
  117. void CreateUsageDocumentation();
  118. void CreateFullDocumentation();
  119. void CreateManDocumentation();
  120. void SetSection(const cmDocumentationEntry* header,
  121. const cmDocumentationEntry* section,
  122. const cmDocumentationEntry* footer,
  123. std::vector<cmDocumentationEntry>&);
  124. const char* GetNameString();
  125. bool IsOption(const char* arg);
  126. std::string NameString;
  127. std::vector<cmDocumentationEntry> NameSection;
  128. std::vector<cmDocumentationEntry> UsageSection;
  129. std::vector<cmDocumentationEntry> DescriptionSection;
  130. std::vector<cmDocumentationEntry> OptionsSection;
  131. std::vector<cmDocumentationEntry> CommandsSection;
  132. std::vector<cmDocumentationEntry> ModulesSection;
  133. std::vector<cmDocumentationEntry> GeneratorsSection;
  134. std::vector<cmDocumentationEntry> SeeAlsoSection;
  135. std::string SeeAlsoString;
  136. std::string SingleCommand;
  137. std::string SingleModuleName;
  138. std::string CMakeRoot;
  139. std::vector< char* > ModuleStrings;
  140. std::vector< const char* > Names;
  141. std::vector< const cmDocumentationEntry* > Sections;
  142. Form CurrentForm;
  143. const char* TextIndent;
  144. int TextWidth;
  145. typedef std::map<Type, cmStdString> RequestedMapType;
  146. RequestedMapType RequestedMap;
  147. };
  148. #endif