Skip to content

Commit 3712edd

Browse files
committed
Debug output for layout file
Introduce (initial) debug possibility for the layout file (`doxygen -l layout). (Might also help to understand #11012)
1 parent 14fc65f commit 3712edd

File tree

4 files changed

+174
-75
lines changed

4 files changed

+174
-75
lines changed

src/debug.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static std::map< std::string, Debug::DebugMask > s_labels =
4848
{ "entries", Debug::Entries },
4949
{ "sections", Debug::Sections },
5050
{ "stderr", Debug::Stderr },
51+
{ "layout", Debug::Layout },
5152
{ "lex", Debug::Lex },
5253
{ "lex:code", Debug::Lex_code },
5354
{ "lex:commentcnv", Debug::Lex_commentcnv },

src/debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class Debug
4646
Entries = 0x02'0000ULL,
4747
Sections = 0x04'0000ULL,
4848
Stderr = 0x08'0000ULL,
49+
Layout = 0x10'0000ULL,
4950
Lex = 0x0000'FFFF'FF00'0000ULL, // all scanners combined
5051
Lex_code = 0x0000'0000'0100'0000ULL,
5152
Lex_commentcnv = 0x0000'0000'0200'0000ULL,

src/doxygen.cpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9506,6 +9506,66 @@ void printNavTree(Entry *root,int indent)
95069506
}
95079507
}
95089508
}
9509+
9510+
void printNavLayout(LayoutNavEntry *root,int indent)
9511+
{
9512+
if (Debug::isFlagSet(Debug::Layout))
9513+
{
9514+
QCString indentStr;
9515+
indentStr.fill(' ',indent);
9516+
Debug::print(Debug::Layout,0,"%skind=%s visible=%d title='%s'\n",
9517+
indentStr.isEmpty()?"":qPrint(indentStr),
9518+
qPrint(root->navToString()),
9519+
root->visible(),
9520+
qPrint(root->title())
9521+
);
9522+
for (const auto &e : root->children())
9523+
{
9524+
printNavLayout(e.get(),indent+2);
9525+
}
9526+
}
9527+
}
9528+
9529+
void printLayout()
9530+
{
9531+
bool extraIndent = false;
9532+
Debug::print(Debug::Layout,0,"Part: Navigation index\n");
9533+
for (const auto &e : LayoutDocManager::instance().rootNavEntry()->children())
9534+
{
9535+
printNavLayout(e.get(),2);
9536+
}
9537+
9538+
for (int i = 0; i < LayoutDocManager::NrParts; i++)
9539+
{
9540+
Debug::print(Debug::Layout,0,"\nPart: %s\n", qPrint(LayoutDocManager::partToString(i)));
9541+
for (const auto &lde : LayoutDocManager::instance().docEntries(static_cast<LayoutDocManager::LayoutPart>(i)))
9542+
{
9543+
if (const LayoutDocEntrySimple *ldes = dynamic_cast<const LayoutDocEntrySimple*>(lde.get()))
9544+
{
9545+
if (lde->kind() == LayoutDocEntry::MemberDeclEnd || lde->kind() == LayoutDocEntry::MemberDefEnd) extraIndent = false;
9546+
Debug::print(Debug::Layout,0," %skind: %s, visible=%d\n",
9547+
extraIndent? " " : "",qPrint(lde->entryToString()), ldes->visible());
9548+
if (lde->kind() == LayoutDocEntry::MemberDeclStart || lde->kind() == LayoutDocEntry::MemberDefStart) extraIndent = true;
9549+
}
9550+
else if (const LayoutDocEntryMemberDecl *lmdecl = dynamic_cast<const LayoutDocEntryMemberDecl*>(lde.get()))
9551+
{
9552+
Debug::print(Debug::Layout,0," %scomplex kind: %s, type: %s\n",
9553+
extraIndent? " " : "",qPrint(lde->entryToString()),qPrint(lmdecl->type.to_string()));
9554+
}
9555+
else if (const LayoutDocEntryMemberDef *lmdef = dynamic_cast<const LayoutDocEntryMemberDef*>(lde.get()))
9556+
{
9557+
Debug::print(Debug::Layout,0," %scomplex kind: %s, type: %s\n",
9558+
extraIndent? " " : "",qPrint(lde->entryToString()),qPrint(lmdef->type.to_string()));
9559+
}
9560+
else
9561+
{
9562+
// should not happen
9563+
Debug::print(Debug::Layout,0," %snot handled kind: %s\n",extraIndent? " " : "",qPrint(lde->entryToString()));
9564+
}
9565+
}
9566+
}
9567+
}
9568+
95099569
//----------------------------------------------------------------------------
95109570
// prints the Sections tree (for debugging)
95119571

@@ -12080,6 +12140,7 @@ void parseInput()
1208012140
{
1208112141
warn_uncond("failed to open layout file '%s' for reading! Using default settings.\n",qPrint(layoutFileName));
1208212142
}
12143+
printLayout();
1208312144

1208412145
/**************************************************************************
1208512146
* Read and preprocess input *

src/layout.h

Lines changed: 111 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -33,47 +33,54 @@ struct LayoutDocEntry
3333
{
3434
ABSTRACT_BASE_CLASS(LayoutDocEntry)
3535

36-
enum Kind {
37-
// Generic items for all pages
38-
MemberGroups,
39-
MemberDeclStart, MemberDeclEnd, MemberDecl,
40-
MemberDefStart, MemberDefEnd, MemberDef,
41-
BriefDesc, DetailedDesc,
42-
AuthorSection,
43-
44-
// Class specific items
45-
ClassIncludes, ClassInlineClasses,
46-
ClassInheritanceGraph, ClassNestedClasses,
47-
ClassCollaborationGraph, ClassAllMembersLink,
48-
ClassUsedFiles,
49-
50-
// Concept specific items
51-
ConceptDefinition,
52-
53-
// Namespace specific items
54-
NamespaceNestedNamespaces, NamespaceNestedConstantGroups,
55-
NamespaceClasses, NamespaceConcepts, NamespaceInterfaces, NamespaceStructs, NamespaceExceptions,
56-
NamespaceInlineClasses,
57-
58-
// File specific items
59-
FileClasses, FileConcepts, FileInterfaces, FileStructs, FileExceptions, FileConstantGroups, FileNamespaces,
60-
FileIncludes, FileIncludeGraph,
61-
FileIncludedByGraph, FileSourceLink,
62-
FileInlineClasses,
63-
64-
// C++20 Modules
65-
ModuleExports, ModuleClasses, ModuleConcepts, ModuleUsedFiles,
66-
67-
// Group specific items
68-
GroupClasses, GroupConcepts, GroupModules, GroupInlineClasses, GroupNamespaces,
69-
GroupDirs, GroupNestedGroups, GroupFiles,
70-
GroupGraph, GroupPageDocs,
71-
72-
// Directory specific items
73-
DirSubDirs, DirFiles, DirGraph
36+
#define ENTRY_SPECIFICATIONS \
37+
/* Generic items for all pages */ \
38+
ESPEC(MemberGroups) \
39+
ESPEC(MemberDeclStart) ESPEC(MemberDeclEnd) ESPEC(MemberDecl) \
40+
ESPEC(MemberDefStart) ESPEC(MemberDefEnd) ESPEC(MemberDef) \
41+
ESPEC(BriefDesc) ESPEC(DetailedDesc) \
42+
ESPEC(AuthorSection) \
43+
/* Class specific items */ \
44+
ESPEC(ClassIncludes) ESPEC(ClassInlineClasses) \
45+
ESPEC(ClassInheritanceGraph) ESPEC(ClassNestedClasses) \
46+
ESPEC(ClassCollaborationGraph) ESPEC(ClassAllMembersLink) \
47+
ESPEC(ClassUsedFiles) \
48+
/* Concept specific items */ \
49+
ESPEC(ConceptDefinition) \
50+
/* Namespace specific items */ \
51+
ESPEC(NamespaceNestedNamespaces) ESPEC(NamespaceNestedConstantGroups) \
52+
ESPEC(NamespaceClasses) ESPEC(NamespaceConcepts) ESPEC(NamespaceInterfaces) ESPEC(NamespaceStructs) ESPEC(NamespaceExceptions) \
53+
ESPEC(NamespaceInlineClasses) \
54+
/* File specific items */ \
55+
ESPEC(FileClasses) ESPEC(FileConcepts) ESPEC(FileInterfaces) ESPEC(FileStructs) ESPEC(FileExceptions) ESPEC(FileConstantGroups) ESPEC(FileNamespaces) \
56+
ESPEC(FileIncludes) ESPEC(FileIncludeGraph) \
57+
ESPEC(FileIncludedByGraph) ESPEC(FileSourceLink) \
58+
ESPEC(FileInlineClasses) \
59+
/* C++20 Modules */ \
60+
ESPEC(ModuleExports) ESPEC(ModuleClasses) ESPEC(ModuleConcepts) ESPEC(ModuleUsedFiles) \
61+
/* Group specific items */ \
62+
ESPEC(GroupClasses) ESPEC(GroupConcepts) ESPEC(GroupModules) ESPEC(GroupInlineClasses) ESPEC(GroupNamespaces) \
63+
ESPEC(GroupDirs) ESPEC(GroupNestedGroups) ESPEC(GroupFiles) \
64+
ESPEC(GroupGraph) ESPEC(GroupPageDocs) \
65+
/* Directory specific items */ \
66+
ESPEC(DirSubDirs) ESPEC(DirFiles) ESPEC(DirGraph)
7467

68+
enum Kind {
69+
#define ESPEC(x) x,
70+
ENTRY_SPECIFICATIONS
71+
#undef ESPEC
7572
};
7673
virtual Kind kind() const = 0;
74+
std::string entryToString()
75+
{
76+
switch (kind())
77+
{
78+
#define ESPEC(x) case x: return #x; break;
79+
ENTRY_SPECIFICATIONS
80+
#undef ESPEC
81+
default: return "unknown"; // to satisfy compiler
82+
}
83+
}
7784
};
7885

7986
/** @brief Represents of a piece of a documentation page without configurable parts */
@@ -131,42 +138,58 @@ using LayoutNavEntryList = std::vector< std::unique_ptr<LayoutNavEntry> >;
131138
/** @brief Base class for the layout of a navigation item at the top of the HTML pages. */
132139
struct LayoutNavEntry
133140
{
141+
#define NAV_SPECIFICATIONS \
142+
NSPEC(None, = -1) \
143+
NSPEC(MainPage,) \
144+
NSPEC(Pages,) \
145+
NSPEC(Modules,) \
146+
NSPEC(ModuleList,) \
147+
NSPEC(ModuleMembers,) \
148+
NSPEC(Topics,) \
149+
NSPEC(Namespaces,) \
150+
NSPEC(NamespaceList,) \
151+
NSPEC(NamespaceMembers,) \
152+
NSPEC(Concepts,) \
153+
NSPEC(Classes,) \
154+
NSPEC(ClassList,) \
155+
NSPEC(ClassIndex,) \
156+
NSPEC(ClassHierarchy,) \
157+
NSPEC(ClassMembers,) \
158+
NSPEC(Interfaces,) \
159+
NSPEC(InterfaceList,) \
160+
NSPEC(InterfaceIndex,) \
161+
NSPEC(InterfaceHierarchy,) \
162+
NSPEC(Structs,) \
163+
NSPEC(StructList,) \
164+
NSPEC(StructIndex,) \
165+
NSPEC(Exceptions,) \
166+
NSPEC(ExceptionList,) \
167+
NSPEC(ExceptionIndex,) \
168+
NSPEC(ExceptionHierarchy,) \
169+
NSPEC(Files,) \
170+
NSPEC(FileList,) \
171+
NSPEC(FileGlobals,) \
172+
NSPEC(Examples,) \
173+
NSPEC(User,) \
174+
NSPEC(UserGroup,)
175+
134176
public:
135177
enum Kind {
136-
None = -1,
137-
MainPage,
138-
Pages,
139-
Modules,
140-
ModuleList,
141-
ModuleMembers,
142-
Topics,
143-
Namespaces,
144-
NamespaceList,
145-
NamespaceMembers,
146-
Concepts,
147-
Classes,
148-
ClassList,
149-
ClassIndex,
150-
ClassHierarchy,
151-
ClassMembers,
152-
Interfaces,
153-
InterfaceList,
154-
InterfaceIndex,
155-
InterfaceHierarchy,
156-
Structs,
157-
StructList,
158-
StructIndex,
159-
Exceptions,
160-
ExceptionList,
161-
ExceptionIndex,
162-
ExceptionHierarchy,
163-
Files,
164-
FileList,
165-
FileGlobals,
166-
Examples,
167-
User,
168-
UserGroup
178+
#define NSPEC(x,y) x y,
179+
NAV_SPECIFICATIONS
180+
#undef NSPEC
169181
};
182+
std::string navToString()
183+
{
184+
switch (kind())
185+
{
186+
#define NSPEC(x,y) case x: return #x; break;
187+
NAV_SPECIFICATIONS
188+
#undef NSPEC
189+
default: return "unknown"; // to satisfy compiler
190+
}
191+
}
192+
170193
LayoutNavEntry(LayoutNavEntry *parent,Kind k,bool vs,const QCString &bf,
171194
const QCString &tl,const QCString &intro)
172195
: m_parent(parent), m_kind(k), m_visible(vs), m_baseFile(bf), m_title(tl), m_intro(intro) {}
@@ -201,20 +224,33 @@ struct LayoutNavEntry
201224
using LayoutDocEntryPtr = std::unique_ptr<LayoutDocEntry>;
202225
using LayoutDocEntryList = std::vector<LayoutDocEntryPtr>;
203226

227+
#define PART_SPECIFICATIONS \
228+
PSPEC(Undefined, = -1) \
229+
PSPEC(Class,) PSPEC(Concept,) PSPEC(Namespace,) PSPEC(File,) PSPEC(Group,) PSPEC(Directory,) PSPEC(Module,) \
230+
PSPEC(NrParts,)
204231
/** @brief Singleton providing access to the (user configurable) layout of the documentation */
205232
class LayoutDocManager
206233
{
207234
class Private;
208235
public:
209236
enum LayoutPart
210237
{
211-
Undefined = -1,
212-
Class, Concept, Namespace, File, Group, Directory, Module,
213-
NrParts
238+
#define PSPEC(x,y) x y,
239+
PART_SPECIFICATIONS
240+
#undef PSPEC
214241
};
215242
/** Returns a reference to this singleton. */
216243
static LayoutDocManager &instance();
217-
244+
static std::string partToString(int k)
245+
{
246+
switch (k)
247+
{
248+
#define PSPEC(x,y) case x: return #x; break;
249+
PART_SPECIFICATIONS
250+
#undef PSPEC
251+
default: return "unknown"; // to satisfy compiler
252+
}
253+
}
218254
/** Returns the list of LayoutDocEntry's in representation order for a given page identified by @a part. */
219255
const LayoutDocEntryList &docEntries(LayoutPart part) const;
220256

0 commit comments

Comments
 (0)