Doxygen
Loading...
Searching...
No Matches
layout.h
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Copyright (C) 1997-2024 by Dimitri van Heesch.
4 *
5 * Permission to use, copy, modify, and distribute this software and its
6 * documentation under the terms of the GNU General Public License is hereby
7 * granted. No representations are made about the suitability of this software
8 * for any purpose. It is provided "as is" without express or implied warranty.
9 * See the GNU General Public License for more details.
10 *
11 * Documents produced by Doxygen are derivative works derived from the
12 * input used in their production; they are not affected by this license.
13 *
14 */
15
16#ifndef LAYOUT_H
17#define LAYOUT_H
18
19#include <memory>
20#include <vector>
21#include <utility>
22
23#include "types.h"
24#include "construct.h"
25
26class LayoutParser;
27struct LayoutNavEntry;
28class MemberList;
29
30/** @brief Base class representing a piece of a documentation page */
32{
34
35#define ENTRY_SPECIFICATIONS \
36 /* Generic items for all pages */ \
37 ESPEC(MemberGroups) \
38 ESPEC(MemberDeclStart) ESPEC(MemberDeclEnd) ESPEC(MemberDecl) \
39 ESPEC(MemberDefStart) ESPEC(MemberDefEnd) ESPEC(MemberDef) \
40 ESPEC(BriefDesc) ESPEC(DetailedDesc) \
41 ESPEC(AuthorSection) \
42 /* Class specific items */ \
43 ESPEC(ClassIncludes) ESPEC(ClassInlineClasses) \
44 ESPEC(ClassInheritanceGraph) ESPEC(ClassNestedClasses) \
45 ESPEC(ClassCollaborationGraph) ESPEC(ClassAllMembersLink) \
46 ESPEC(ClassUsedFiles) \
47 /* Concept specific items */ \
48 ESPEC(ConceptDefinition) \
49 /* Namespace specific items */ \
50 ESPEC(NamespaceNestedNamespaces) ESPEC(NamespaceNestedConstantGroups) \
51 ESPEC(NamespaceClasses) ESPEC(NamespaceConcepts) ESPEC(NamespaceInterfaces) ESPEC(NamespaceStructs) ESPEC(NamespaceExceptions) \
52 ESPEC(NamespaceInlineClasses) \
53 /* File specific items */ \
54 ESPEC(FileClasses) ESPEC(FileConcepts) ESPEC(FileInterfaces) ESPEC(FileStructs) ESPEC(FileExceptions) ESPEC(FileConstantGroups) ESPEC(FileNamespaces) \
55 ESPEC(FileIncludes) ESPEC(FileIncludeGraph) \
56 ESPEC(FileIncludedByGraph) ESPEC(FileSourceLink) \
57 ESPEC(FileInlineClasses) \
58 /* C++20 Modules */ \
59 ESPEC(ModuleExports) ESPEC(ModuleClasses) ESPEC(ModuleConcepts) ESPEC(ModuleUsedFiles) \
60 /* Group specific items */ \
61 ESPEC(GroupClasses) ESPEC(GroupConcepts) ESPEC(GroupModules) ESPEC(GroupInlineClasses) ESPEC(GroupNamespaces) \
62 ESPEC(GroupDirs) ESPEC(GroupNestedGroups) ESPEC(GroupFiles) \
63 ESPEC(GroupGraph) ESPEC(GroupPageDocs) \
64 /* Directory specific items */ \
65 ESPEC(DirSubDirs) ESPEC(DirFiles) ESPEC(DirGraph)
66
67 enum Kind {
68#define ESPEC(x) x,
70#undef ESPEC
71 };
72 virtual Kind kind() const = 0;
73 std::string entryToString() const
74 {
75 switch (kind())
76 {
77#define ESPEC(x) case x: return #x; break;
79#undef ESPEC
80 default: return "unknown"; // to satisfy compiler
81 }
82 }
83 virtual std::string id() const = 0;
84 virtual bool visible() const = 0;
85};
86
87/** @brief Represents of a piece of a documentation page without configurable parts */
89{
90 public:
91 LayoutDocEntrySimple(Kind k,const std::string &id, bool v) : m_kind(k), m_id(id), m_visible(v) {}
92 Kind kind() const override { return m_kind; }
93 bool visible() const override { return m_visible; }
94 std::string id() const override { return m_id; }
95 private:
97 std::string m_id;
99};
100
102{
103 LayoutDocEntrySection(Kind k,const std::string &id,const QCString &tl,bool v) :
104 LayoutDocEntrySimple(k,id,v), m_title(tl) {}
105 QCString title(SrcLangExt lang) const;
106private:
108};
109
110/** @brief Represents of a member declaration list with configurable title and subtitle. */
112{
113 LayoutDocEntryMemberDecl(MemberListType tp,const std::string &id,
114 const QCString &tl,const QCString &ss, bool v)
115 : type(tp), m_id(id), m_title(tl), m_subscript(ss), m_visible(v) {}
116
117 Kind kind() const override { return MemberDecl; }
119 QCString title(SrcLangExt lang) const;
120 QCString subtitle(SrcLangExt lang) const;
121 bool visible() const override { return m_visible; }
122 std::string id() const override { return m_id; }
123private:
124 std::string m_id;
128};
129
130/** @brief Represents of a member definition list with configurable title. */
132{
133 LayoutDocEntryMemberDef(MemberListType tp,const std::string &id, const QCString &tl,bool v)
134 : type(tp), m_id(id), m_title(tl), m_visible(v) {}
135
136 Kind kind() const override { return MemberDef; }
138 QCString title(SrcLangExt lang) const;
139 bool visible() const override { return m_visible; }
140 std::string id() const override { return m_id; }
141private:
142 std::string m_id;
145};
146
147using LayoutDocEntryPtr = std::unique_ptr<LayoutDocEntry>;
148using LayoutDocEntryList = std::vector<LayoutDocEntryPtr>;
149
150//-------------------------------------------------------------------------------------------------
151
152using LayoutNavEntryList = std::vector< std::unique_ptr<LayoutNavEntry> >;
153
154/** @brief Base class for the layout of a navigation item at the top of the HTML pages. */
156{
157#define NAV_SPECIFICATIONS \
158 NSPEC(None, = -1) \
159 NSPEC(MainPage,) \
160 NSPEC(Pages,) \
161 NSPEC(Modules,) \
162 NSPEC(ModuleList,) \
163 NSPEC(ModuleMembers,) \
164 NSPEC(Topics,) \
165 NSPEC(Namespaces,) \
166 NSPEC(NamespaceList,) \
167 NSPEC(NamespaceMembers,) \
168 NSPEC(Concepts,) \
169 NSPEC(Classes,) \
170 NSPEC(ClassList,) \
171 NSPEC(ClassIndex,) \
172 NSPEC(ClassHierarchy,) \
173 NSPEC(ClassMembers,) \
174 NSPEC(Interfaces,) \
175 NSPEC(InterfaceList,) \
176 NSPEC(InterfaceIndex,) \
177 NSPEC(InterfaceHierarchy,) \
178 NSPEC(Structs,) \
179 NSPEC(StructList,) \
180 NSPEC(StructIndex,) \
181 NSPEC(Exceptions,) \
182 NSPEC(ExceptionList,) \
183 NSPEC(ExceptionIndex,) \
184 NSPEC(ExceptionHierarchy,) \
185 NSPEC(Files,) \
186 NSPEC(FileList,) \
187 NSPEC(FileGlobals,) \
188 NSPEC(Examples,) \
189 NSPEC(User,) \
190 NSPEC(UserGroup,)
191
192 public:
193 enum Kind {
194#define NSPEC(x,y) x y,
196#undef NSPEC
197 };
198 std::string navToString() const
199 {
200 switch (kind())
201 {
202#define NSPEC(x,y) case x: return #x; break;
204#undef NSPEC
205 default: return "unknown"; // to satisfy compiler
206 }
207 }
208
210 const QCString &tl,const QCString &intro)
211 : m_parent(parent), m_kind(k), m_visible(vs), m_baseFile(bf), m_title(tl), m_intro(intro) {}
212 LayoutNavEntry *parent() const { return m_parent; }
213 Kind kind() const { return m_kind; }
214 QCString baseFile() const { return m_baseFile; }
215 std::string id() const { return navToString()+":"+m_baseFile.str(); }
216 QCString title() const { return m_title; }
217 QCString intro() const { return m_intro; }
218 QCString url() const;
219 const LayoutNavEntryList &children() const { return m_children; }
221 void setVisible(bool v) { m_visible = v; }
222 bool visible() const { return m_visible; }
223 void clear() { m_children.clear(); }
224 void insertChild(size_t pos,std::unique_ptr<LayoutNavEntry> &&e);
225 void appendChild(std::unique_ptr<LayoutNavEntry> &&e);
228 void swap(LayoutNavEntry &other)
229 {
230 std::swap(m_parent,other.m_parent);
231 std::swap(m_kind,other.m_kind);
232 std::swap(m_visible,other.m_visible);
233 std::swap(m_baseFile,other.m_baseFile);
234 std::swap(m_title,other.m_title);
235 std::swap(m_intro,other.m_intro);
236 std::swap(m_children,other.m_children);
237 // reparent children
238 for (auto &child : m_children)
239 {
240 child->m_parent = this;
241 }
242 }
243
244 private:
245 LayoutNavEntry() : m_parent(nullptr), m_kind(None), m_visible(true) {}
253 friend class LayoutDocManager;
254};
255
256#define PART_SPECIFICATIONS \
257 PSPEC(Undefined, = -1) \
258 PSPEC(Class,) PSPEC(Concept,) PSPEC(Namespace,) PSPEC(File,) PSPEC(Group,) PSPEC(Directory,) PSPEC(Module,) \
259 PSPEC(NrParts,)
260/** @brief Singleton providing access to the (user configurable) layout of the documentation */
262{
263 class Private;
264 public:
266 {
267#define PSPEC(x,y) x y,
269#undef PSPEC
270 };
271 /** Returns a reference to this singleton. */
272 static LayoutDocManager &instance();
273 static std::string partToString(int k)
274 {
275 switch (k)
276 {
277#define PSPEC(x,y) case x: return #x; break;
279#undef PSPEC
280 default: return "unknown"; // to satisfy compiler
281 }
282 }
283 /** Returns the list of LayoutDocEntry's in representation order for a given page identified by @a part. */
284 const LayoutDocEntryList &docEntries(LayoutPart part) const;
285
286 /** returns the (invisible) root of the navigation tree. */
288 /** append a new node as a child to root. */
290 LayoutNavEntry::Kind k,bool vs,const QCString &bf,const QCString &tl,const QCString &intro);
291
292 /** Parses a user provided layout */
293 void parse(const QCString &fileName, const char* data = nullptr);
294 void init();
295 int majorVersion() const;
296 int minorVersion() const;
297 private:
299 void mergeNavEntries(LayoutDocManager &manager);
300 void mergeDocEntries(const QCString &fileName,LayoutDocManager &manager);
305 std::unique_ptr<Private> d;
306 friend class LayoutParser;
307};
308
309void writeDefaultLayoutFile(const QCString &fileName);
310void printLayout();
311
312#endif
313
Singleton providing access to the (user configurable) layout of the documentation.
Definition layout.h:262
void mergeNavEntries(LayoutDocManager &manager)
Definition layout.cpp:1633
static std::string partToString(int k)
Definition layout.h:273
std::unique_ptr< Private > d
Definition layout.h:305
LayoutNavEntry * createChildNavEntry(LayoutNavEntry *root, LayoutNavEntry::Kind k, bool vs, const QCString &bf, const QCString &tl, const QCString &intro)
append a new node as a child to root.
Definition layout.cpp:1451
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition layout.cpp:1435
void mergeDocEntries(const QCString &fileName, LayoutDocManager &manager)
Definition layout.cpp:1721
int majorVersion() const
Definition layout.cpp:1529
void parse(const QCString &fileName, const char *data=nullptr)
Parses a user provided layout.
Definition layout.cpp:1468
int minorVersion() const
Definition layout.cpp:1534
friend class LayoutParser
Definition layout.h:306
void addEntry(LayoutPart p, LayoutDocEntryPtr &&e)
Definition layout.cpp:1462
LayoutNavEntry * rootNavEntry() const
returns the (invisible) root of the navigation tree.
Definition layout.cpp:1446
void removeInvisibleDocEntries()
Definition layout.cpp:1509
const LayoutDocEntryList & docEntries(LayoutPart part) const
Returns the list of LayoutDocEntry's in representation order for a given page identified by part.
Definition layout.cpp:1441
A model of a class/file/namespace member symbol.
Definition memberdef.h:48
A list of MemberDef objects as shown in documentation sections.
Definition memberlist.h:109
Wrapper class for the MemberListType type.
Definition types.h:184
This is an alternative implementation of QCString.
Definition qcstring.h:101
#define NON_COPYABLE(cls)
Macro to help implementing the rule of 5 for a non-copyable & movable class.
Definition construct.h:37
#define ABSTRACT_BASE_CLASS(cls)
Macro to implement rule of 5 for an abstract base class.
Definition construct.h:20
constexpr DocNodeVariant * parent(DocNodeVariant *n)
returns the parent node of a given node n or nullptr if the node has no parent.
Definition docnode.h:1324
void writeDefaultLayoutFile(const QCString &fileName)
Definition layout.cpp:1732
std::unique_ptr< LayoutDocEntry > LayoutDocEntryPtr
Definition layout.h:147
std::vector< std::unique_ptr< LayoutNavEntry > > LayoutNavEntryList
Definition layout.h:152
std::vector< LayoutDocEntryPtr > LayoutDocEntryList
Definition layout.h:148
void printLayout()
Definition layout.cpp:1820
Base class representing a piece of a documentation page.
Definition layout.h:32
std::string entryToString() const
Definition layout.h:73
virtual Kind kind() const =0
virtual std::string id() const =0
virtual bool visible() const =0
Kind
Definition layout.h:67
@ ENTRY_SPECIFICATIONS
Definition layout.h:69
LayoutDocEntryMemberDecl(MemberListType tp, const std::string &id, const QCString &tl, const QCString &ss, bool v)
Definition layout.h:113
QCString title(SrcLangExt lang) const
Definition layout.cpp:1786
std::string m_id
Definition layout.h:124
bool m_visible
Definition layout.h:127
std::string id() const override
Definition layout.h:122
MemberListType type
Definition layout.h:118
Kind kind() const override
Definition layout.h:117
QCString subtitle(SrcLangExt lang) const
Definition layout.cpp:1791
QCString m_subscript
Definition layout.h:126
bool visible() const override
Definition layout.h:121
QCString m_title
Definition layout.h:125
QCString m_title
Definition layout.h:143
std::string id() const override
Definition layout.h:140
MemberListType type
Definition layout.h:137
bool m_visible
Definition layout.h:144
Kind kind() const override
Definition layout.h:136
std::string m_id
Definition layout.h:142
bool visible() const override
Definition layout.h:139
QCString title(SrcLangExt lang) const
Definition layout.cpp:1798
LayoutDocEntryMemberDef(MemberListType tp, const std::string &id, const QCString &tl, bool v)
Definition layout.h:133
QCString title(SrcLangExt lang) const
Definition layout.cpp:1779
LayoutDocEntrySection(Kind k, const std::string &id, const QCString &tl, bool v)
Definition layout.h:103
QCString m_title
Definition layout.h:107
Kind kind() const override
Definition layout.h:92
bool m_visible
Definition layout.h:98
Kind m_kind
Definition layout.h:96
bool visible() const override
Definition layout.h:93
LayoutDocEntrySimple(Kind k, const std::string &id, bool v)
Definition layout.h:91
std::string id() const override
Definition layout.h:94
std::string m_id
Definition layout.h:97
Base class for the layout of a navigation item at the top of the HTML pages.
Definition layout.h:156
QCString title() const
Definition layout.h:216
QCString m_intro
Definition layout.h:251
bool m_visible
Definition layout.h:248
void setVisible(bool v)
Definition layout.h:221
LayoutNavEntryList m_children
Definition layout.h:252
QCString url() const
Definition layout.cpp:151
const LayoutNavEntryList & children() const
Definition layout.h:219
LayoutNavEntryList & children()
Definition layout.h:220
std::string id() const
Definition layout.h:215
void updateVisibility(LayoutNavEntry *parent)
Definition layout.cpp:116
void appendChild(std::unique_ptr< LayoutNavEntry > &&e)
Definition layout.cpp:121
void insertChild(size_t pos, std::unique_ptr< LayoutNavEntry > &&e)
Definition layout.cpp:127
LayoutNavEntry * parent() const
Definition layout.h:212
LayoutNavEntry()
Definition layout.h:245
QCString m_baseFile
Definition layout.h:249
Kind m_kind
Definition layout.h:247
void swap(LayoutNavEntry &other)
Definition layout.h:228
QCString intro() const
Definition layout.h:217
QCString baseFile() const
Definition layout.h:214
LayoutNavEntry * find(LayoutNavEntry::Kind k, const QCString &file=QCString()) const
Definition layout.cpp:133
Kind kind() const
Definition layout.h:213
void clear()
Definition layout.h:223
bool visible() const
Definition layout.h:222
Kind
Definition layout.h:193
@ NAV_SPECIFICATIONS
Definition layout.h:195
LayoutNavEntry * m_parent
Definition layout.h:246
LayoutNavEntry(LayoutNavEntry *parent, Kind k, bool vs, const QCString &bf, const QCString &tl, const QCString &intro)
Definition layout.h:209
friend class LayoutDocManager
Definition layout.h:253
QCString m_title
Definition layout.h:250
std::string navToString() const
Definition layout.h:198
This file contains a number of basic enums and types.
SrcLangExt
Language as given by extension.
Definition types.h:42