Skip to content

Commit 2d705fc

Browse files
committed
issue doxygen#9437 Avoid empty Markdown page get generated
- more flexible (and easier to extend) way to check the commands that shouldn't result in an empty page - some more commands added
1 parent 5f0eb3a commit 2d705fc

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/markdown.cpp

+26-6
Original file line numberDiff line numberDiff line change
@@ -3446,6 +3446,31 @@ QCString Markdown::Private::processBlocks(std::string_view data,const size_t ind
34463446
return out;
34473447
}
34483448

3449+
#define OPC(x) #x " ",#x "\n"
3450+
static const StringVector otherPagingCmds =
3451+
{
3452+
OPC(dir), OPC(defgroup), OPC(addtogroup), OPC(weakgroup), OPC(ingroup),
3453+
OPC(fn), OPC(property), OPC(typedef), OPC(var), OPC(def),
3454+
OPC(enum), OPC(namespace), OPC(class), OPC(concept), OPC(module),
3455+
OPC(protocol), OPC(category), OPC(union), OPC(struct), OPC(interface),
3456+
OPC(idlexcept)
3457+
};
3458+
#undef OPC
3459+
3460+
static bool literal_at_local(std::string_view data,const char *str)
3461+
{
3462+
size_t len = strlen(str);
3463+
return len<=data.size() && data[0]==str[0] && qstrncmp(data.data()+1,str+1,len-1)==0;
3464+
}
3465+
3466+
static bool isOtherPage(std::string_view data)
3467+
{
3468+
for (const auto &str : otherPagingCmds)
3469+
{
3470+
if (literal_at_local(data,str.c_str())) return true;
3471+
}
3472+
return false;
3473+
}
34493474

34503475
static ExplicitPageResult isExplicitPage(const QCString &docs)
34513476
{
@@ -3483,12 +3508,7 @@ static ExplicitPageResult isExplicitPage(const QCString &docs)
34833508
return ExplicitPageResult::explicitMainPage;
34843509
}
34853510
}
3486-
else if (i+1<size &&
3487-
(data[i]=='\\' || data[i]=='@') &&
3488-
(literal_at(data.substr(i+1),"dir\n") || literal_at(data.substr(i+1),"dir ") ||
3489-
literal_at(data.substr(i+1),"defgroup\n") || literal_at(data.substr(i+1),"defgroup ") ||
3490-
literal_at(data.substr(i+1),"addtogroup\n") || literal_at(data.substr(i+1),"addtogroup "))
3491-
)
3511+
else if (i+1<size && (data[i]=='\\' || data[i]=='@') && isOtherPage(data.substr(i+1)))
34923512
{
34933513
AUTO_TRACE_EXIT("result=ExplicitPageResult::explicitOtherPage");
34943514
return ExplicitPageResult::explicitOtherPage;

0 commit comments

Comments
 (0)