cmDocumentation.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. * the type of help to be provided. If non-zero, the result should
  27. * be passed to PrintDocumentation to produce the desired
  28. * documentation.
  29. */
  30. Type CheckOptions(int argc, char** argv);
  31. /** Print help of the given type. */
  32. void PrintDocumentation(Type ht, std::ostream& os);
  33. /** Set the program name for standard document generation. */
  34. void SetNameSection(const cmDocumentationEntry*);
  35. /** Set the program usage for standard document generation. */
  36. void SetUsageSection(const cmDocumentationEntry*);
  37. /** Set the program description for standard document generation. */
  38. void SetDescriptionSection(const cmDocumentationEntry*);
  39. /** Set the program options for standard document generation. */
  40. void SetOptionsSection(const cmDocumentationEntry*);
  41. /** Set the listfile commands for standard document generation. */
  42. void SetCommandsSection(const cmDocumentationEntry*);
  43. // Low-level interface for custom documents:
  44. /** Forms of documentation output. */
  45. enum Form { TextForm, HTMLForm, ManForm, UsageForm };
  46. /**
  47. * Print documentation in the given form. All previously added
  48. * sections will be generated.
  49. */
  50. void Print(Form f, std::ostream& os);
  51. /**
  52. * Add a section of documentation. The cmDocumentationEntry pointer
  53. * should point at an array terminated by an all zero ({0,0,0})
  54. * entry. This can be used to generate custom help documents.
  55. */
  56. void AddSection(const char* name, const cmDocumentationEntry* d);
  57. /** Clear all previously added sections of help. */
  58. void ClearSections();
  59. private:
  60. void PrintSection(std::ostream& os,
  61. const cmDocumentationEntry* section,
  62. const char* name);
  63. void PrintSectionText(std::ostream& os,
  64. const cmDocumentationEntry* section,
  65. const char* name);
  66. void PrintSectionHTML(std::ostream& os,
  67. const cmDocumentationEntry* section,
  68. const char* name);
  69. void PrintSectionMan(std::ostream& os, const cmDocumentationEntry* section,
  70. const char* name);
  71. void PrintSectionUsage(std::ostream& os,
  72. const cmDocumentationEntry* section,
  73. const char* name);
  74. void PrintFormatted(std::ostream& os, const char* text);
  75. void PrintPreformatted(std::ostream& os, const char* text);
  76. void PrintPreformattedText(std::ostream& os, const char* text);
  77. void PrintPreformattedHTML(std::ostream& os, const char* text);
  78. void PrintPreformattedMan(std::ostream& os, const char* text);
  79. void PrintParagraph(std::ostream& os, const char* text);
  80. void PrintParagraphText(std::ostream& os, const char* text);
  81. void PrintParagraphHTML(std::ostream& os, const char* text);
  82. void PrintParagraphMan(std::ostream& os, const char* text);
  83. void PrintColumn(std::ostream& os, const char* text);
  84. void PrintHTMLEscapes(std::ostream& os, const char* text);
  85. void PrintCopyright(std::ostream& os);
  86. void PrintVersion(std::ostream& os);
  87. void PrintDocumentationUsage(std::ostream& os);
  88. void PrintDocumentationFull(std::ostream& os);
  89. void PrintDocumentationHTML(std::ostream& os);
  90. void PrintDocumentationMan(std::ostream& os);
  91. void CreateUsageDocumentation();
  92. void CreateFullDocumentation();
  93. void CreateManDocumentation();
  94. void SetSection(const cmDocumentationEntry* header,
  95. const cmDocumentationEntry* section,
  96. const cmDocumentationEntry* footer,
  97. std::vector<cmDocumentationEntry>&);
  98. std::vector<cmDocumentationEntry> NameSection;
  99. std::vector<cmDocumentationEntry> UsageSection;
  100. std::vector<cmDocumentationEntry> DescriptionSection;
  101. std::vector<cmDocumentationEntry> OptionsSection;
  102. std::vector<cmDocumentationEntry> CommandsSection;
  103. std::vector< const char* > Names;
  104. std::vector< const cmDocumentationEntry* > Sections;
  105. Form CurrentForm;
  106. const char* TextIndent;
  107. int TextWidth;
  108. };
  109. #endif