Skip to content

Commit 1a2d3b4

Browse files
committed
Merge branch 'feature/issue_9437_defgroup' of https://github.com/albert-github/doxygen into albert-github-feature/issue_9437_defgroup
2 parents 2e5aa57 + 34bf4d9 commit 1a2d3b4

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

src/commentcnv.l

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ MAILADDR ("mailto:")?[a-z_A-Z0-9\x80-\xff.+-]+"@"[a-z_A-Z0-9\x80-\xff-]+("."[a
176176
%x SkipString
177177
%x SkipVerbString
178178
%x SkipChar
179+
%x SkipLang
179180
%x SComment
180181
%x CComment
181182
%x CNComment
@@ -982,10 +983,44 @@ SLASHopt [/]*
982983
BEGIN(SkipString);
983984
}
984985
*/
986+
<CComment,CNComment>{CMD}"~"[a-z_A-Z-]* { // language switch command
987+
if (yyextra->lang!=SrcLangExt::Markdown) REJECT;
988+
QCString langId = QCString(yytext).mid(2);
989+
if (!langId.isEmpty() &&
990+
qstricmp(Config_getEnumAsString(OUTPUT_LANGUAGE),langId)!=0)
991+
{ // enable language specific section
992+
if (!Config_isAvailableEnum(OUTPUT_LANGUAGE,langId))
993+
{
994+
warn(yyextra->fileName,yyextra->lineNr,
995+
"non supported language '{}' specified in '{}'",langId,QCString(yytext).stripWhiteSpace());
996+
}
997+
BEGIN(SkipLang);
998+
}
999+
}
9851000
<CComment,CNComment>{CMD}{CMD} |
9861001
<CComment,CNComment>. {
9871002
copyToOutput(yyscanner,yytext,yyleng);
9881003
}
1004+
<SkipLang>{CMD}"~"[a-zA-Z-]* { /* language switch */
1005+
QCString langId(&yytext[2]);
1006+
if (!langId.isEmpty() && !Config_isAvailableEnum(OUTPUT_LANGUAGE,langId))
1007+
{
1008+
warn(yyextra->fileName,yyextra->lineNr,
1009+
"non supported language '{}' specified in '{}'",langId,QCString(yytext).stripWhiteSpace());
1010+
}
1011+
else if (langId.isEmpty() ||
1012+
qstricmp(Config_getEnumAsString(OUTPUT_LANGUAGE),langId)==0)
1013+
{ // enable language specific section
1014+
BEGIN(CComment);
1015+
}
1016+
}
1017+
<SkipLang>[^*@\\\n]* { /* any character not a *, @, backslash or new line */
1018+
}
1019+
<SkipLang>\n { /* new line in language block, needed for keeping track of line numbers */
1020+
copyToOutput(yyscanner,yytext,yyleng);
1021+
}
1022+
<SkipLang>. { /* any other character */
1023+
}
9891024
<SComment>^[ \t]*{CPPC}"/"{SLASHopt}/\n {
9901025
replaceComment(yyscanner,0);
9911026
}

src/markdown.cpp

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ enum class ExplicitPageResult
6767
{
6868
explicitPage, /**< docs start with a page command */
6969
explicitMainPage, /**< docs start with a mainpage command */
70-
explicitDirPage, /**< docs start with a dir command */
70+
explicitOtherPage, /**< docs start with a dir / defgroup / addtogroup command */
7171
notExplicit /**< docs doesn't start with either page or mainpage */
7272
};
7373

@@ -3434,6 +3434,31 @@ QCString Markdown::Private::processBlocks(std::string_view data,const size_t ind
34343434
return out;
34353435
}
34363436

3437+
#define OPC(x) #x " ",#x "\n"
3438+
static const StringVector otherPagingCmds =
3439+
{
3440+
OPC(dir), OPC(defgroup), OPC(addtogroup), OPC(weakgroup), OPC(ingroup),
3441+
OPC(fn), OPC(property), OPC(typedef), OPC(var), OPC(def),
3442+
OPC(enum), OPC(namespace), OPC(class), OPC(concept), OPC(module),
3443+
OPC(protocol), OPC(category), OPC(union), OPC(struct), OPC(interface),
3444+
OPC(idlexcept)
3445+
};
3446+
#undef OPC
3447+
3448+
static bool literal_at_local(std::string_view data,const char *str)
3449+
{
3450+
size_t len = strlen(str);
3451+
return len<=data.size() && data[0]==str[0] && qstrncmp(data.data()+1,str+1,len-1)==0;
3452+
}
3453+
3454+
static bool isOtherPage(std::string_view data)
3455+
{
3456+
for (const auto &str : otherPagingCmds)
3457+
{
3458+
if (literal_at_local(data,str.c_str())) return true;
3459+
}
3460+
return false;
3461+
}
34373462

34383463
static ExplicitPageResult isExplicitPage(const QCString &docs)
34393464
{
@@ -3471,13 +3496,10 @@ static ExplicitPageResult isExplicitPage(const QCString &docs)
34713496
return ExplicitPageResult::explicitMainPage;
34723497
}
34733498
}
3474-
else if (i+1<size &&
3475-
(data[i]=='\\' || data[i]=='@') &&
3476-
(literal_at(data.substr(i+1),"dir\n") || literal_at(data.substr(i+1),"dir "))
3477-
)
3499+
else if (i+1<size && (data[i]=='\\' || data[i]=='@') && isOtherPage(data.substr(i+1)))
34783500
{
3479-
AUTO_TRACE_EXIT("result=ExplicitPageResult::explicitDirPage");
3480-
return ExplicitPageResult::explicitDirPage;
3501+
AUTO_TRACE_EXIT("result=ExplicitPageResult::explicitOtherPage");
3502+
return ExplicitPageResult::explicitOtherPage;
34813503
}
34823504
}
34833505
AUTO_TRACE_EXIT("result=ExplicitPageResult::notExplicit");
@@ -3629,6 +3651,7 @@ void MarkdownOutlineParser::parseInput(const QCString &fileName,
36293651
current->docFile = fileName;
36303652
current->docLine = 1;
36313653
QCString docs = stripIndentation(fileBuf);
3654+
if (!docs.stripWhiteSpace().size()) return;
36323655
Debug::print(Debug::Markdown,0,"======== Markdown =========\n---- input ------- \n{}\n",fileBuf);
36333656
QCString id;
36343657
Markdown markdown(fileName,1,0);
@@ -3721,7 +3744,7 @@ void MarkdownOutlineParser::parseInput(const QCString &fileName,
37213744
break;
37223745
case ExplicitPageResult::explicitMainPage:
37233746
break;
3724-
case ExplicitPageResult::explicitDirPage:
3747+
case ExplicitPageResult::explicitOtherPage:
37253748
break;
37263749
}
37273750
int lineNr=1;

0 commit comments

Comments
 (0)