1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
12 #include "cmDocumentationFormatter.h"
13 #include "cmDocumentationSection.h"
15 struct cmDocumentationEntry;
17 /** Class to generate documentation. */
18 class cmDocumentation : public cmDocumentationEnums
24 * Check command line arguments for documentation options. Returns
25 * true if documentation options are found, and false otherwise.
26 * When true is returned, PrintRequestedDocumentation should be
27 * called. exitOpt can be used for things like cmake -E, so that
28 * all arguments after the -E are ignored and not searched for
31 bool CheckOptions(int argc, const char* const* argv,
32 const char* exitOpt = nullptr);
35 * Print help requested on the command line. Call after
36 * CheckOptions returns true. Returns true on success, and false
37 * otherwise. Failure can occur when output files specified on the
38 * command line cannot be written.
40 bool PrintRequestedDocumentation(std::ostream& os);
42 /** Print help of the given type. */
43 bool PrintDocumentation(Type ht, std::ostream& os);
45 void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
47 /** Set the program name for standard document generation. */
48 void SetName(const std::string& name);
50 /** Set a section of the documentation. Typical sections include Name,
51 Usage, Description, Options */
52 void SetSection(const char* sectionName, cmDocumentationSection section);
53 void SetSection(const char* sectionName,
54 std::vector<cmDocumentationEntry>& docs);
55 void SetSection(const char* sectionName, const char* docs[][2]);
56 void SetSections(std::map<std::string, cmDocumentationSection> sections);
58 /** Add the documentation to the beginning/end of the section */
59 void PrependSection(const char* sectionName, const char* docs[][2]);
60 void PrependSection(const char* sectionName,
61 std::vector<cmDocumentationEntry>& docs);
62 void PrependSection(const char* sectionName, cmDocumentationEntry& docs);
63 void AppendSection(const char* sectionName, const char* docs[][2]);
64 void AppendSection(const char* sectionName,
65 std::vector<cmDocumentationEntry>& docs);
66 void AppendSection(const char* sectionName, cmDocumentationEntry& docs);
68 /** Add common (to all tools) documentation section(s) */
69 void addCommonStandardDocSections();
71 /** Add the CMake standard documentation section(s) */
72 void addCMakeStandardDocSections();
74 /** Add the CTest standard documentation section(s) */
75 void addCTestStandardDocSections();
77 /** Add the CPack standard documentation section(s) */
78 void addCPackStandardDocSections();
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);
85 bool PrintVersion(std::ostream& os);
86 bool PrintUsage(std::ostream& os);
87 bool PrintHelp(std::ostream& os);
88 bool PrintHelpFull(std::ostream& os);
89 bool PrintHelpOneManual(std::ostream& os);
90 bool PrintHelpOneCommand(std::ostream& os);
91 bool PrintHelpOneModule(std::ostream& os);
92 bool PrintHelpOnePolicy(std::ostream& os);
93 bool PrintHelpOneProperty(std::ostream& os);
94 bool PrintHelpOneVariable(std::ostream& os);
95 bool PrintHelpListManuals(std::ostream& os);
96 bool PrintHelpListCommands(std::ostream& os);
97 bool PrintHelpListModules(std::ostream& os);
98 bool PrintHelpListProperties(std::ostream& os);
99 bool PrintHelpListVariables(std::ostream& os);
100 bool PrintHelpListPolicies(std::ostream& os);
101 bool PrintHelpListGenerators(std::ostream& os);
102 bool PrintOldCustomModules(std::ostream& os);
104 const char* GetNameString() const;
105 bool IsOption(const char* arg) const;
109 std::string NameString;
110 std::map<std::string, cmDocumentationSection> AllSections;
111 cmDocumentationSection& SectionAtName(const char* name);
113 std::string CurrentArgument;
115 struct RequestedHelpItem
117 cmDocumentationEnums::Type HelpType = None;
118 std::string Filename;
119 std::string Argument;
122 std::vector<RequestedHelpItem> RequestedHelpItems;
123 cmDocumentationFormatter Formatter;
125 static void WarnFormFromFilename(RequestedHelpItem& request, bool& result);