cmDocumentation.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef _cmDocumentation_h
  11. #define _cmDocumentation_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmDocumentationFormatter.h"
  14. #include "cmDocumentationSection.h"
  15. #include "cmake.h"
  16. namespace cmsys
  17. {
  18. class Directory;
  19. }
  20. /** Class to generate documentation. */
  21. class cmDocumentation: public cmDocumentationEnums
  22. {
  23. public:
  24. cmDocumentation();
  25. ~cmDocumentation();
  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. exitOpt can be used for things like cmake -E, so that
  31. * all arguments after the -E are ignored and not searched for
  32. * help arguments.
  33. */
  34. bool CheckOptions(int argc, const char* const* argv,
  35. const char* exitOpt =0);
  36. /**
  37. * Print help requested on the command line. Call after
  38. * CheckOptions returns true. Returns true on success, and false
  39. * otherwise. Failure can occur when output files specified on the
  40. * command line cannot be written.
  41. */
  42. bool PrintRequestedDocumentation(std::ostream& os);
  43. /** Print help of the given type. */
  44. bool PrintDocumentation(Type ht, std::ostream& os);
  45. void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
  46. /** Set the program name for standard document generation. */
  47. void SetName(const std::string& name);
  48. /** Set a section of the documentation. Typical sections include Name,
  49. Usage, Description, Options */
  50. void SetSection(const char *sectionName,
  51. cmDocumentationSection *section);
  52. void SetSection(const char *sectionName,
  53. std::vector<cmDocumentationEntry> &docs);
  54. void SetSection(const char *sectionName,
  55. const char *docs[][2]);
  56. void SetSections(std::map<std::string,cmDocumentationSection *>
  57. &sections);
  58. /** Add the documentation to the beginning/end of the section */
  59. void PrependSection(const char *sectionName,
  60. const char *docs[][2]);
  61. void PrependSection(const char *sectionName,
  62. std::vector<cmDocumentationEntry> &docs);
  63. void PrependSection(const char *sectionName,
  64. cmDocumentationEntry &docs);
  65. void AppendSection(const char *sectionName,
  66. const char *docs[][2]);
  67. void AppendSection(const char *sectionName,
  68. std::vector<cmDocumentationEntry> &docs);
  69. void AppendSection(const char *sectionName,
  70. cmDocumentationEntry &docs);
  71. /** Add common (to all tools) documentation section(s) */
  72. void addCommonStandardDocSections();
  73. /** Add the CMake standard documentation section(s) */
  74. void addCMakeStandardDocSections();
  75. /** Add the CTest standard documentation section(s) */
  76. void addCTestStandardDocSections();
  77. /** Add the CPack standard documentation section(s) */
  78. void addCPackStandardDocSections();
  79. private:
  80. void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
  81. void PrintNames(std::ostream& os, std::string const& pattern);
  82. bool PrintFiles(std::ostream& os, std::string const& pattern);
  83. bool PrintVersion(std::ostream& os);
  84. bool PrintUsage(std::ostream& os);
  85. bool PrintHelp(std::ostream& os);
  86. bool PrintHelpFull(std::ostream& os);
  87. bool PrintHelpOneManual(std::ostream& os);
  88. bool PrintHelpOneCommand(std::ostream& os);
  89. bool PrintHelpOneModule(std::ostream& os);
  90. bool PrintHelpOnePolicy(std::ostream& os);
  91. bool PrintHelpOneProperty(std::ostream& os);
  92. bool PrintHelpOneVariable(std::ostream& os);
  93. bool PrintHelpListManuals(std::ostream& os);
  94. bool PrintHelpListCommands(std::ostream& os);
  95. bool PrintHelpListModules(std::ostream& os);
  96. bool PrintHelpListProperties(std::ostream& os);
  97. bool PrintHelpListVariables(std::ostream& os);
  98. bool PrintHelpListPolicies(std::ostream& os);
  99. bool PrintHelpListGenerators(std::ostream& os);
  100. bool PrintOldCustomModules(std::ostream& os);
  101. const char* GetNameString() const;
  102. bool IsOption(const char* arg) const;
  103. bool ShowGenerators;
  104. std::string NameString;
  105. std::map<std::string,cmDocumentationSection*> AllSections;
  106. std::string CurrentArgument;
  107. struct RequestedHelpItem
  108. {
  109. RequestedHelpItem(): HelpType(None) {}
  110. cmDocumentationEnums::Type HelpType;
  111. std::string Filename;
  112. std::string Argument;
  113. };
  114. std::vector<RequestedHelpItem> RequestedHelpItems;
  115. cmDocumentationFormatter Formatter;
  116. static void WarnFormFromFilename(RequestedHelpItem& request, bool& result);
  117. };
  118. #endif