cmDocumentation.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 SetNameSection(const cmDocumentationEntry*);
  42. /** Set the program usage for standard document generation. */
  43. void SetUsageSection(const cmDocumentationEntry*);
  44. /** Set the program description for standard document generation. */
  45. void SetDescriptionSection(const cmDocumentationEntry*);
  46. /** Set the program options for standard document generation. */
  47. void SetOptionsSection(const cmDocumentationEntry*);
  48. /** Set the listfile commands for standard document generation. */
  49. void SetCommandsSection(const cmDocumentationEntry*);
  50. /** Set the generator descriptions for standard document generation. */
  51. void SetGeneratorsSection(const cmDocumentationEntry*);
  52. /** Set the see-also list of references to the other tools. */
  53. void SetSeeAlsoList(const cmDocumentationEntry*);
  54. // Low-level interface for custom documents:
  55. /** Forms of documentation output. */
  56. enum Form { TextForm, HTMLForm, ManForm, UsageForm };
  57. /**
  58. * Print documentation in the given form. All previously added
  59. * sections will be generated.
  60. */
  61. void Print(Form f, std::ostream& os);
  62. /**
  63. * Add a section of documentation. The cmDocumentationEntry pointer
  64. * should point at an array terminated by an all zero ({0,0,0})
  65. * entry. This can be used to generate custom help documents.
  66. */
  67. void AddSection(const char* name, const cmDocumentationEntry* d);
  68. /** Clear all previously added sections of help. */
  69. void ClearSections();
  70. private:
  71. void PrintSection(std::ostream& os,
  72. const cmDocumentationEntry* section,
  73. const char* name);
  74. void PrintSectionText(std::ostream& os,
  75. const cmDocumentationEntry* section,
  76. const char* name);
  77. void PrintSectionHTML(std::ostream& os,
  78. const cmDocumentationEntry* section,
  79. const char* name);
  80. void PrintSectionMan(std::ostream& os, const cmDocumentationEntry* section,
  81. const char* name);
  82. void PrintSectionUsage(std::ostream& os,
  83. const cmDocumentationEntry* section,
  84. const char* name);
  85. void PrintFormatted(std::ostream& os, const char* text);
  86. void PrintPreformatted(std::ostream& os, const char* text);
  87. void PrintPreformattedText(std::ostream& os, const char* text);
  88. void PrintPreformattedHTML(std::ostream& os, const char* text);
  89. void PrintPreformattedMan(std::ostream& os, const char* text);
  90. void PrintParagraph(std::ostream& os, const char* text);
  91. void PrintParagraphText(std::ostream& os, const char* text);
  92. void PrintParagraphHTML(std::ostream& os, const char* text);
  93. void PrintParagraphMan(std::ostream& os, const char* text);
  94. void PrintColumn(std::ostream& os, const char* text);
  95. void PrintHTMLEscapes(std::ostream& os, const char* text);
  96. void PrintCopyright(std::ostream& os);
  97. void PrintVersion(std::ostream& os);
  98. void PrintDocumentationUsage(std::ostream& os);
  99. void PrintDocumentationFull(std::ostream& os);
  100. void PrintDocumentationHTML(std::ostream& os);
  101. void PrintDocumentationMan(std::ostream& os);
  102. void CreateUsageDocumentation();
  103. void CreateFullDocumentation();
  104. void CreateManDocumentation();
  105. void SetSection(const cmDocumentationEntry* header,
  106. const cmDocumentationEntry* section,
  107. const cmDocumentationEntry* footer,
  108. std::vector<cmDocumentationEntry>&);
  109. std::vector<cmDocumentationEntry> NameSection;
  110. std::vector<cmDocumentationEntry> UsageSection;
  111. std::vector<cmDocumentationEntry> DescriptionSection;
  112. std::vector<cmDocumentationEntry> OptionsSection;
  113. std::vector<cmDocumentationEntry> CommandsSection;
  114. std::vector<cmDocumentationEntry> GeneratorsSection;
  115. std::vector<cmDocumentationEntry> SeeAlsoSection;
  116. std::string SeeAlsoString;
  117. std::vector< const char* > Names;
  118. std::vector< const cmDocumentationEntry* > Sections;
  119. Form CurrentForm;
  120. const char* TextIndent;
  121. int TextWidth;
  122. typedef std::map<Type, cmStdString> RequestedMapType;
  123. RequestedMapType RequestedMap;
  124. };
  125. #endif