cmake/Source/cmRST.h

99 lines
2.8 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
2014-08-03 19:52:23 +02:00
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2014-08-03 19:52:23 +02:00
2016-10-30 18:24:19 +01:00
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
2014-08-03 19:52:23 +02:00
2020-02-01 23:06:01 +01:00
#include "cmsys/RegularExpression.hxx"
2014-08-03 19:52:23 +02:00
/** \class cmRST
* \brief Perform basic .rst processing for command-line help
*
* This class implements a subset of reStructuredText and Sphinx
* document processing. It is used to print command-line help.
*
* If you modify the capabilities of this class, be sure to update
* the Help/manual/cmake-developer.7.rst documentation and to update
* the Tests/CMakeLib/testRST.(rst|expect) test input and output.
*/
class cmRST
{
public:
2019-11-11 23:01:05 +01:00
cmRST(std::ostream& os, std::string docroot);
2014-08-03 19:52:23 +02:00
bool ProcessFile(std::string const& fname, bool isModule = false);
2016-07-09 11:21:54 +02:00
2014-08-03 19:52:23 +02:00
private:
enum IncludeType
{
IncludeNormal,
IncludeModule,
IncludeTocTree
};
enum MarkupType
{
MarkupNone,
MarkupNormal,
MarkupEmpty
};
enum DirectiveType
{
DirectiveNone,
DirectiveParsedLiteral,
DirectiveLiteralBlock,
DirectiveCodeBlock,
DirectiveReplace,
DirectiveTocTree
};
void ProcessRST(std::istream& is);
void ProcessModule(std::istream& is);
void Reset();
void ProcessLine(std::string const& line);
void NormalLine(std::string const& line);
void OutputLine(std::string const& line, bool inlineMarkup);
std::string ReplaceSubstitutions(std::string const& line);
void OutputMarkupLines(bool inlineMarkup);
bool ProcessInclude(std::string file, IncludeType type);
void ProcessDirectiveParsedLiteral();
void ProcessDirectiveLiteralBlock();
void ProcessDirectiveCodeBlock();
void ProcessDirectiveReplace();
void ProcessDirectiveTocTree();
static void UnindentLines(std::vector<std::string>& lines);
std::ostream& OS;
std::string DocRoot;
int IncludeDepth;
bool OutputLinePending;
bool LastLineEndedInColonColon;
MarkupType Markup;
DirectiveType Directive;
cmsys::RegularExpression CMakeDirective;
cmsys::RegularExpression CMakeModuleDirective;
cmsys::RegularExpression ParsedLiteralDirective;
cmsys::RegularExpression CodeBlockDirective;
cmsys::RegularExpression ReplaceDirective;
cmsys::RegularExpression IncludeDirective;
cmsys::RegularExpression TocTreeDirective;
cmsys::RegularExpression ProductionListDirective;
cmsys::RegularExpression NoteDirective;
cmsys::RegularExpression ModuleRST;
cmsys::RegularExpression CMakeRole;
2018-08-09 18:06:22 +02:00
cmsys::RegularExpression InlineLink;
cmsys::RegularExpression InlineLiteral;
2014-08-03 19:52:23 +02:00
cmsys::RegularExpression Substitution;
2016-07-09 11:21:54 +02:00
cmsys::RegularExpression TocTreeLink;
2014-08-03 19:52:23 +02:00
std::vector<std::string> MarkupLines;
std::string DocDir;
2015-04-27 22:25:09 +02:00
std::map<std::string, std::string> Replace;
std::set<std::string> Replaced;
2014-08-03 19:52:23 +02:00
std::string ReplaceName;
};