cmDocumentation.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. // High-level interface for standard documents:
  22. /** Types of help provided. */
  23. enum Type { None, Usage, Full, HTML, Man, Copyright, Version };
  24. /**
  25. * Check command line arguments for documentation options. Returns
  26. * true if documentation options are found, and false otherwise.
  27. * When true is returned, PrintRequestedDocumentation should be
  28. * called.
  29. */
  30. bool CheckOptions(int argc, const char* const* argv);
  31. /**
  32. * Print help requested on the command line. Call after
  33. * CheckOptions returns true. Returns true on success, and false
  34. * otherwise. Failure can occur when output files specified on the
  35. * command line cannot be written.
  36. */
  37. bool PrintRequestedDocumentation(std::ostream& os);
  38. /** Print help of the given type. */
  39. void PrintDocumentation(Type ht, std::ostream& os);
  40. /** Set the program name for standard document generation. */
  41. void SetName(const char* name);
  42. /** Set the program name section for standard document
  43. * generation. */
  44. void SetNameSection(const cmDocumentationEntry*);
  45. /** Set the program usage for standard document generation. */
  46. void SetUsageSection(const cmDocumentationEntry*);
  47. /** Set the program description for standard document generation. */
  48. void SetDescriptionSection(const cmDocumentationEntry*);
  49. /** Set the program options for standard document generation. */
  50. void SetOptionsSection(const cmDocumentationEntry*);
  51. /** Set the listfile commands for standard document generation. */
  52. void SetCommandsSection(const cmDocumentationEntry*);
  53. /** Set the generator descriptions for standard document generation. */
  54. void SetGeneratorsSection(const cmDocumentationEntry*);
  55. /** Set the see-also list of references to the other tools. */
  56. void SetSeeAlsoList(const cmDocumentationEntry*);
  57. // Low-level interface for custom documents:
  58. /** Forms of documentation output. */
  59. enum Form { TextForm, HTMLForm, ManForm, UsageForm };
  60. /**
  61. * Print documentation in the given form. All previously added
  62. * sections will be generated.
  63. */
  64. void Print(Form f, std::ostream& os);
  65. /**
  66. * Add a section of documentation. The cmDocumentationEntry pointer
  67. * should point at an array terminated by an all zero ({0,0,0})
  68. * entry. This can be used to generate custom help documents.
  69. */
  70. void AddSection(const char* name, const cmDocumentationEntry* d);
  71. /** Clear all previously added sections of help. */
  72. void ClearSections();
  73. private:
  74. void PrintSection(std::ostream& os,
  75. const cmDocumentationEntry* section,
  76. const char* name);
  77. void PrintSectionText(std::ostream& os,
  78. const cmDocumentationEntry* section,
  79. const char* name);
  80. void PrintSectionHTML(std::ostream& os,
  81. const cmDocumentationEntry* section,
  82. const char* name);
  83. void PrintSectionMan(std::ostream& os, const cmDocumentationEntry* section,
  84. const char* name);
  85. void PrintSectionUsage(std::ostream& os,
  86. const cmDocumentationEntry* section,
  87. const char* name);
  88. void PrintFormatted(std::ostream& os, const char* text);
  89. void PrintPreformatted(std::ostream& os, const char* text);
  90. void PrintPreformattedText(std::ostream& os, const char* text);
  91. void PrintPreformattedHTML(std::ostream& os, const char* text);
  92. void PrintPreformattedMan(std::ostream& os, const char* text);
  93. void PrintParagraph(std::ostream& os, const char* text);
  94. void PrintParagraphText(std::ostream& os, const char* text);
  95. void PrintParagraphHTML(std::ostream& os, const char* text);
  96. void PrintParagraphMan(std::ostream& os, const char* text);
  97. void PrintColumn(std::ostream& os, const char* text);
  98. void PrintHTMLEscapes(std::ostream& os, const char* text);
  99. void PrintCopyright(std::ostream& os);
  100. void PrintVersion(std::ostream& os);
  101. void PrintDocumentationUsage(std::ostream& os);
  102. void PrintDocumentationFull(std::ostream& os);
  103. void PrintDocumentationHTML(std::ostream& os);
  104. void PrintDocumentationMan(std::ostream& os);
  105. void PrintDocumentationCommand(std::ostream& os,
  106. cmDocumentationEntry* entry);
  107. void CreateUsageDocumentation();
  108. void CreateFullDocumentation();
  109. void CreateManDocumentation();
  110. void SetSection(const cmDocumentationEntry* header,
  111. const cmDocumentationEntry* section,
  112. const cmDocumentationEntry* footer,
  113. std::vector<cmDocumentationEntry>&);
  114. const char* GetNameString();
  115. std::string NameString;
  116. std::vector<cmDocumentationEntry> NameSection;
  117. std::vector<cmDocumentationEntry> UsageSection;
  118. std::vector<cmDocumentationEntry> DescriptionSection;
  119. std::vector<cmDocumentationEntry> OptionsSection;
  120. std::vector<cmDocumentationEntry> CommandsSection;
  121. std::vector<cmDocumentationEntry> GeneratorsSection;
  122. std::vector<cmDocumentationEntry> SeeAlsoSection;
  123. std::string SeeAlsoString;
  124. std::vector< const char* > Names;
  125. std::vector< const cmDocumentationEntry* > Sections;
  126. Form CurrentForm;
  127. const char* TextIndent;
  128. int TextWidth;
  129. typedef std::map<Type, cmStdString> RequestedMapType;
  130. RequestedMapType RequestedMap;
  131. };
  132. #endif