cmake/Source/cmDocumentation.h

127 lines
4.5 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-07-09 11:21:54 +02:00
2016-10-30 18:24:19 +01:00
#include <iosfwd>
#include <map>
#include <string>
#include <vector>
2020-02-01 23:06:01 +01:00
#include "cmDocumentationFormatter.h"
#include "cmDocumentationSection.h"
2016-10-30 18:24:19 +01:00
struct cmDocumentationEntry;
/** Class to generate documentation. */
2016-07-09 11:21:54 +02:00
class cmDocumentation : public cmDocumentationEnums
{
public:
cmDocumentation();
2012-08-04 10:26:08 +03:00
/**
* Check command line arguments for documentation options. Returns
* true if documentation options are found, and false otherwise.
* When true is returned, PrintRequestedDocumentation should be
2012-08-04 10:26:08 +03:00
* called. exitOpt can be used for things like cmake -E, so that
* all arguments after the -E are ignored and not searched for
* help arguments.
*/
2012-08-04 10:26:08 +03:00
bool CheckOptions(int argc, const char* const* argv,
2018-01-26 17:06:56 +01:00
const char* exitOpt = nullptr);
2012-08-04 10:26:08 +03:00
/**
* Print help requested on the command line. Call after
* CheckOptions returns true. Returns true on success, and false
* otherwise. Failure can occur when output files specified on the
* command line cannot be written.
*/
bool PrintRequestedDocumentation(std::ostream& os);
2012-08-04 10:26:08 +03:00
/** Print help of the given type. */
2014-08-03 19:52:23 +02:00
bool PrintDocumentation(Type ht, std::ostream& os);
2010-03-17 14:00:29 +02:00
void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
2012-08-04 10:26:08 +03:00
/** Set the program name for standard document generation. */
2015-04-27 22:25:09 +02:00
void SetName(const std::string& name);
/** Set a section of the documentation. Typical sections include Name,
2014-08-03 19:52:23 +02:00
Usage, Description, Options */
2019-11-11 23:01:05 +01:00
void SetSection(const char* sectionName, cmDocumentationSection section);
2016-07-09 11:21:54 +02:00
void SetSection(const char* sectionName,
std::vector<cmDocumentationEntry>& docs);
void SetSection(const char* sectionName, const char* docs[][2]);
2019-11-11 23:01:05 +01:00
void SetSections(std::map<std::string, cmDocumentationSection> sections);
/** Add the documentation to the beginning/end of the section */
2016-07-09 11:21:54 +02:00
void PrependSection(const char* sectionName, const char* docs[][2]);
void PrependSection(const char* sectionName,
std::vector<cmDocumentationEntry>& docs);
void PrependSection(const char* sectionName, cmDocumentationEntry& docs);
void AppendSection(const char* sectionName, const char* docs[][2]);
void AppendSection(const char* sectionName,
std::vector<cmDocumentationEntry>& docs);
void AppendSection(const char* sectionName, cmDocumentationEntry& docs);
2012-04-19 19:04:21 +03:00
/** Add common (to all tools) documentation section(s) */
void addCommonStandardDocSections();
/** Add the CMake standard documentation section(s) */
void addCMakeStandardDocSections();
/** Add the CTest standard documentation section(s) */
void addCTestStandardDocSections();
/** Add the CPack standard documentation section(s) */
void addCPackStandardDocSections();
private:
2014-08-03 19:52:23 +02:00
void GlobHelp(std::vector<std::string>& files, std::string const& pattern);
void PrintNames(std::ostream& os, std::string const& pattern);
bool PrintFiles(std::ostream& os, std::string const& pattern);
bool PrintVersion(std::ostream& os);
2015-04-27 22:25:09 +02:00
bool PrintUsage(std::ostream& os);
bool PrintHelp(std::ostream& os);
2014-08-03 19:52:23 +02:00
bool PrintHelpFull(std::ostream& os);
bool PrintHelpOneManual(std::ostream& os);
bool PrintHelpOneCommand(std::ostream& os);
bool PrintHelpOneModule(std::ostream& os);
bool PrintHelpOnePolicy(std::ostream& os);
bool PrintHelpOneProperty(std::ostream& os);
bool PrintHelpOneVariable(std::ostream& os);
bool PrintHelpListManuals(std::ostream& os);
bool PrintHelpListCommands(std::ostream& os);
bool PrintHelpListModules(std::ostream& os);
bool PrintHelpListProperties(std::ostream& os);
bool PrintHelpListVariables(std::ostream& os);
bool PrintHelpListPolicies(std::ostream& os);
2015-08-17 11:37:30 +02:00
bool PrintHelpListGenerators(std::ostream& os);
2014-08-03 19:52:23 +02:00
bool PrintOldCustomModules(std::ostream& os);
const char* GetNameString() const;
bool IsOption(const char* arg) const;
2010-03-17 14:00:29 +02:00
bool ShowGenerators;
std::string NameString;
2019-11-11 23:01:05 +01:00
std::map<std::string, cmDocumentationSection> AllSections;
cmDocumentationSection& SectionAtName(const char* name);
2012-08-04 10:26:08 +03:00
std::string CurrentArgument;
struct RequestedHelpItem
{
2019-11-11 23:01:05 +01:00
cmDocumentationEnums::Type HelpType = None;
std::string Filename;
std::string Argument;
};
std::vector<RequestedHelpItem> RequestedHelpItems;
2014-08-03 19:52:23 +02:00
cmDocumentationFormatter Formatter;
2014-08-03 19:52:23 +02:00
static void WarnFormFromFilename(RequestedHelpItem& request, bool& result);
};