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 "cmProperty.h"
  14. #include "cmDocumentationFormatter.h"
  15. #include "cmDocumentationSection.h"
  16. #include "cmake.h"
  17. namespace cmsys
  18. {
  19. class Directory;
  20. }
  21. /** Class to generate documentation. */
  22. class cmDocumentation: public cmDocumentationEnums
  23. {
  24. public:
  25. cmDocumentation();
  26. ~cmDocumentation();
  27. /**
  28. * Check command line arguments for documentation options. Returns
  29. * true if documentation options are found, and false otherwise.
  30. * When true is returned, PrintRequestedDocumentation should be
  31. * called. exitOpt can be used for things like cmake -E, so that
  32. * all arguments after the -E are ignored and not searched for
  33. * help arguments.
  34. */
  35. bool CheckOptions(int argc, const char* const* argv,
  36. const char* exitOpt =0);
  37. /**
  38. * Print help requested on the command line. Call after
  39. * CheckOptions returns true. Returns true on success, and false
  40. * otherwise. Failure can occur when output files specified on the
  41. * command line cannot be written.
  42. */
  43. bool PrintRequestedDocumentation(std::ostream& os);
  44. /** Print help of the given type. */
  45. bool PrintDocumentation(Type ht, std::ostream& os);
  46. void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
  47. /** Set the program name for standard document generation. */
  48. void SetName(const std::string& name);
  49. /** Set a section of the documentation. Typical sections include Name,
  50. Usage, Description, Options */
  51. void SetSection(const char *sectionName,
  52. cmDocumentationSection *section);
  53. void SetSection(const char *sectionName,
  54. std::vector<cmDocumentationEntry> &docs);
  55. void SetSection(const char *sectionName,
  56. const char *docs[][2]);
  57. void SetSections(std::map<std::string,cmDocumentationSection *>
  58. &sections);
  59. /** Add the documentation to the beginning/end of the section */
  60. void PrependSection(const char *sectionName,
  61. const char *docs[][2]);
  62. void PrependSection(const char *sectionName,
  63. std::vector<cmDocumentationEntry> &docs);
  64. void PrependSection(const char *sectionName,
  65. cmDocumentationEntry &docs);
  66. void AppendSection(const char *sectionName,
  67. const char *docs[][2]);
  68. void AppendSection(const char *sectionName,
  69. std::vector<cmDocumentationEntry> &docs);
  70. void AppendSection(const char *sectionName,
  71. cmDocumentationEntry &docs);
  72. /** Add common (to all tools) documentation section(s) */
  73. void addCommonStandardDocSections();
  74. /** Add the CMake standard documentation section(s) */
  75. void addCMakeStandardDocSections();
  76. /** Add the CTest standard documentation section(s) */
  77. void addCTestStandardDocSections();
  78. /** Add the CPack standard documentation section(s) */
  79. void addCPackStandardDocSections();
  80. private:
  81. void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
  82. void PrintNames(std::ostream& os, std::string const& pattern);
  83. bool PrintFiles(std::ostream& os, std::string const& pattern);
  84. bool PrintVersion(std::ostream& os);
  85. bool PrintUsage(std::ostream& os);
  86. bool PrintHelp(std::ostream& os);
  87. bool PrintHelpFull(std::ostream& os);
  88. bool PrintHelpOneManual(std::ostream& os);
  89. bool PrintHelpOneCommand(std::ostream& os);
  90. bool PrintHelpOneModule(std::ostream& os);
  91. bool PrintHelpOnePolicy(std::ostream& os);
  92. bool PrintHelpOneProperty(std::ostream& os);
  93. bool PrintHelpOneVariable(std::ostream& os);
  94. bool PrintHelpListManuals(std::ostream& os);
  95. bool PrintHelpListCommands(std::ostream& os);
  96. bool PrintHelpListModules(std::ostream& os);
  97. bool PrintHelpListProperties(std::ostream& os);
  98. bool PrintHelpListVariables(std::ostream& os);
  99. bool PrintHelpListPolicies(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