forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocWriter.h
More file actions
226 lines (188 loc) · 8.82 KB
/
DocWriter.h
File metadata and controls
226 lines (188 loc) · 8.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
//
// DocWriter.h
//
// $Id: //poco/1.4/PocoDoc/src/DocWriter.h#2 $
//
// Definition of the DocWriter class.
//
// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef PocoDoc_DocWriter_INCLUDED
#define PocoDoc_DocWriter_INCLUDED
#include "Poco/CppParser/NameSpace.h"
#include "Poco/Logger.h"
#include <vector>
#include <set>
#include <ostream>
namespace Poco {
namespace CppParser {
class Symbol;
class Struct;
class Function;
class TypeDef;
class Enum;
class Variable;
} } // namespace Poco::CppParser
class DocWriter
/// Given a symbol table obtained from a CppParser, this
/// class writes reference documentation in HTML format
/// to a directory.
{
public:
DocWriter(const Poco::CppParser::NameSpace::SymbolTable& symbols, const std::string& path, bool prettifyCode = true, bool noFrames = false);
/// Creates the DocWriter.
~DocWriter();
/// Destroys the DocWriter.
void write();
/// Writes all documentation files.
void writeEclipseTOC();
/// Write Eclipse Table-Of-Contents XML files.
void addPage(const std::string& path);
/// Adds a page.
protected:
enum TextState
{
TEXT_PARAGRAPH,
TEXT_LIST,
TEXT_OLIST,
TEXT_LITERAL,
TEXT_WHITESPACE
};
struct Page
{
std::string path;
std::string fileName;
std::string title;
std::string category;
};
enum
{
MAX_TITLE_LEVEL = 3,
PAGE_INDEX_COLUMNS = 2,
NAMESPACE_INDEX_COLUMNS = 4
};
struct TOCEntry
{
std::string title;
int level;
int id;
};
typedef std::vector<TOCEntry> TOC;
typedef std::map<std::string, Poco::CppParser::Function*> MethodMap;
typedef std::map<std::string, std::string> StringMap;
typedef std::map<std::string, Page> PageMap;
void writePages();
void writePage(Page& page);
void scanTOC(const std::string& text, TOC& toc);
void writeTOC(std::ostream& ostr, const TOC& toc);
void writeCategoryIndex(const std::string& category, const std::string& fileName);
void writeCategoryIndex(std::ostream& ostr, const std::string& category, const std::string& target);
void writePageIndex(std::ostream& ostr);
void writeNameSpaceIndex(std::ostream& ostr);
void writeClass(const Poco::CppParser::Struct* pStruct);
void writeNameSpace(const Poco::CppParser::NameSpace* pNameSpace);
void writeNavigation();
void writePackage(const std::string& file, const std::string& library, const std::string& package);
std::string pathFor(const std::string& file);
static std::string fileNameFor(const Poco::CppParser::Symbol* pNameSpace);
static std::string baseNameFor(const Poco::CppParser::Symbol* pNameSpace);
static std::string uriFor(const Poco::CppParser::Symbol* pSymbol);
static std::string makeFileName(const std::string& str);
static std::string headerFor(const Poco::CppParser::Symbol* pSymbol);
static std::string titleFor(const Poco::CppParser::Symbol* pSymbol);
void writeHeader(std::ostream& ostr, const std::string& title, const std::string& extraScript = "");
void writeNavigationFrame(std::ostream& ostr, const std::string& group, const std::string& item);
static void writeFooter(std::ostream& ostr);
void writeCopyright(std::ostream& ostr);
static void writeTitle(std::ostream& ostr, const std::string& category, const std::string& title);
static void writeTitle(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace, const std::string& title);
static void writeSubTitle(std::ostream& ostr, const std::string& title);
static void beginBody(std::ostream& ostr);
static void endBody(std::ostream& ostr);
static void beginContent(std::ostream& ostr);
static void endContent(std::ostream& ostr);
void writeDescription(std::ostream& ostr, const std::string& text);
void writeDescriptionLine(std::ostream& ostr, const std::string& text, TextState& state);
void writeSummary(std::ostream& ostr, const std::string& text, const std::string& uri);
static std::string htmlize(const std::string& str);
static std::string htmlize(char c);
static TextState analyzeLine(const std::string& line);
static std::string htmlizeName(const std::string& name);
void writeText(std::ostream& ostr, const std::string& text);
void writeText(std::ostream& ostr, std::string::const_iterator begin, const std::string::const_iterator& end);
void writeDecl(std::ostream& ostr, const std::string& decl);
void writeDecl(std::ostream& ostr, std::string::const_iterator begin, const std::string::const_iterator& end);
bool writeSymbol(std::ostream& ostr, std::string& token, std::string::const_iterator& begin, const std::string::const_iterator& end);
bool writeSpecial(std::ostream& ostr, std::string& token, std::string::const_iterator& begin, const std::string::const_iterator& end);
void nextToken(std::string::const_iterator& it, const std::string::const_iterator& end, std::string& token);
void writeListItem(std::ostream& ostr, const std::string& text);
void writeOrderedListItem(std::ostream& ostr, const std::string& text);
void writeLiteral(std::ostream& ostr, const std::string& text);
void writeFileInfo(std::ostream& ostr, const Poco::CppParser::Symbol* pSymbol);
void writeInheritance(std::ostream& ostr, const Poco::CppParser::Struct* pStruct);
void writeMethodSummary(std::ostream& ostr, const Poco::CppParser::Struct* pStruct);
void writeNestedClasses(std::ostream& ostr, const Poco::CppParser::Struct* pStruct);
void writeNameSpacesSummary(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeNameSpaces(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeClassesSummary(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeClasses(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeClassSummary(std::ostream& ostr, const Poco::CppParser::Struct* pStruct);
void writeTypesSummary(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeTypes(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeType(std::ostream& ostr, const Poco::CppParser::TypeDef* pType);
void writeEnums(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeEnum(std::ostream& ostr, const Poco::CppParser::Enum* pEnum);
void writeConstructors(std::ostream& ostr, const Poco::CppParser::Struct* pStruct);
void writeDestructor(std::ostream& ostr, const Poco::CppParser::Struct* pStruct);
void writeMethods(std::ostream& ostr, const Poco::CppParser::Struct* pNameSpace);
void writeFunctionsSummary(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeFunctions(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeFunction(std::ostream& ostr, const Poco::CppParser::Function* pFunc);
void writeVariables(std::ostream& ostr, const Poco::CppParser::NameSpace* pNameSpace);
void writeVariable(std::ostream& ostr, const Poco::CppParser::Variable* pVar);
static void writeNameListItem(std::ostream& ostr, const std::string& name, const Poco::CppParser::Symbol* pSymbol, const Poco::CppParser::NameSpace* pNameSpace, bool& first);
static void writeLink(std::ostream& ostr, const std::string& uri, const std::string& text);
static void writeLink(std::ostream& ostr, const Poco::CppParser::Symbol* pSymbol, const std::string& text);
static void writeLink(std::ostream& ostr, const std::string& uri, const std::string& text, const std::string& linkClass);
void writeTargetLink(std::ostream& ostr, const std::string& uri, const std::string& text, const std::string& target);
static void writeImageLink(std::ostream& ostr, const std::string& uri, const std::string& image, const std::string& alt);
static void writeImage(std::ostream& ostr, const std::string& uri, const std::string& caption);
static void writeIcon(std::ostream& ostr, const std::string& icon);
static void writeAnchor(std::ostream& ostr, const std::string& text, const Poco::CppParser::Symbol* pSymbol);
static void writeDeprecated(std::ostream& ostr, const std::string& what);
void libraries(std::set<std::string>& libs);
void packages(const std::string& lib, std::set<std::string>& packages);
Poco::CppParser::NameSpace* rootNameSpace() const;
static const std::string& tr(const std::string& id);
static void loadStrings(const std::string& language);
static void loadString(const std::string& id, const std::string& def, const std::string& language);
static Poco::Logger& logger();
static const std::string RFC_URI;
private:
bool _prettifyCode;
bool _noFrames;
bool _htmlMode;
bool _literalMode;
const Poco::CppParser::NameSpace::SymbolTable& _symbols;
std::string _path;
const Poco::CppParser::NameSpace* _pNameSpace;
PageMap _pages;
bool _pendingLine;
int _indent;
int _titleId;
static std::string _language;
static StringMap _strings;
static Poco::Logger* _pLogger;
};
//
// inlines
//
inline Poco::Logger& DocWriter::logger()
{
poco_check_ptr (_pLogger);
return *_pLogger;
}
#endif // PocoDoc_DocWriter_INCLUDED