cmDocumentation.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. private:
  76. void PrintSection(std::ostream& os,
  77. const cmDocumentationEntry* section,
  78. const char* name);
  79. void PrintSectionText(std::ostream& os,
  80. const cmDocumentationEntry* section,
  81. const char* name);
  82. void PrintSectionHTML(std::ostream& os,
  83. const cmDocumentationEntry* section,
  84. const char* name);
  85. void PrintSectionMan(std::ostream& os, const cmDocumentationEntry* section,
  86. const char* name);
  87. void PrintSectionUsage(std::ostream& os,
  88. const cmDocumentationEntry* section,
  89. const char* name);
  90. void PrintFormatted(std::ostream& os, const char* text);
  91. void PrintPreformatted(std::ostream& os, const char* text);
  92. void PrintPreformattedText(std::ostream& os, const char* text);
  93. void PrintPreformattedHTML(std::ostream& os, const char* text);
  94. void PrintPreformattedMan(std::ostream& os, const char* text);
  95. void PrintParagraph(std::ostream& os, const char* text);
  96. void PrintParagraphText(std::ostream& os, const char* text);
  97. void PrintParagraphHTML(std::ostream& os, const char* text);
  98. void PrintParagraphMan(std::ostream& os, const char* text);
  99. void PrintColumn(std::ostream& os, const char* text);
  100. void PrintHTMLEscapes(std::ostream& os, const char* text);
  101. bool CreateSingleModule(const char* fname, const char* moduleName);
  102. bool CreateModulesSection();
  103. bool PrintCopyright(std::ostream& os);
  104. bool PrintVersion(std::ostream& os);
  105. bool PrintDocumentationList(std::ostream& os);
  106. bool PrintModuleList(std::ostream& os);
  107. bool PrintDocumentationSingle(std::ostream& os);
  108. bool PrintDocumentationSingleModule(std::ostream& os);
  109. bool PrintDocumentationUsage(std::ostream& os);
  110. bool PrintDocumentationFull(std::ostream& os);
  111. bool PrintDocumentationHTML(std::ostream& os);
  112. bool PrintDocumentationMan(std::ostream& os);
  113. void PrintDocumentationCommand(std::ostream& os,
  114. cmDocumentationEntry* entry);
  115. void CreateUsageDocumentation();
  116. void CreateFullDocumentation();
  117. void CreateManDocumentation();
  118. void SetSection(const cmDocumentationEntry* header,
  119. const cmDocumentationEntry* section,
  120. const cmDocumentationEntry* footer,
  121. std::vector<cmDocumentationEntry>&);
  122. const char* GetNameString();
  123. bool IsOption(const char* arg);
  124. std::string NameString;
  125. std::vector<cmDocumentationEntry> NameSection;
  126. std::vector<cmDocumentationEntry> UsageSection;
  127. std::vector<cmDocumentationEntry> DescriptionSection;
  128. std::vector<cmDocumentationEntry> OptionsSection;
  129. std::vector<cmDocumentationEntry> CommandsSection;
  130. std::vector<cmDocumentationEntry> ModulesSection;
  131. std::vector<cmDocumentationEntry> GeneratorsSection;
  132. std::vector<cmDocumentationEntry> SeeAlsoSection;
  133. std::string SeeAlsoString;
  134. std::string SingleCommand;
  135. std::string SingleModuleName;
  136. std::vector< char* > ModuleStrings;
  137. std::vector< const char* > Names;
  138. std::vector< const cmDocumentationEntry* > Sections;
  139. Form CurrentForm;
  140. const char* TextIndent;
  141. int TextWidth;
  142. typedef std::map<Type, cmStdString> RequestedMapType;
  143. RequestedMapType RequestedMap;
  144. };
  145. #endif