Skip to content

Commit 4e62f82

Browse files
committed
Merge branch 'albert-github-feature/issue_9437_defgroup'
2 parents 2e5aa57 + c426503 commit 4e62f82

File tree

2 files changed

+53
-8
lines changed

2 files changed

+53
-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: 18 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,18 @@ QCString Markdown::Private::processBlocks(std::string_view data,const size_t ind
34343434
return out;
34353435
}
34363436

3437+
static bool isOtherPage(std::string_view data)
3438+
{
3439+
#define OPC(x) if (literal_at(data,#x " ") || literal_at(data,#x "\n")) return true
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+
#undef OPC
3446+
3447+
return false;
3448+
}
34373449

34383450
static ExplicitPageResult isExplicitPage(const QCString &docs)
34393451
{
@@ -3471,13 +3483,10 @@ static ExplicitPageResult isExplicitPage(const QCString &docs)
34713483
return ExplicitPageResult::explicitMainPage;
34723484
}
34733485
}
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-
)
3486+
else if (i+1<size && (data[i]=='\\' || data[i]=='@') && isOtherPage(data.substr(i+1)))
34783487
{
3479-
AUTO_TRACE_EXIT("result=ExplicitPageResult::explicitDirPage");
3480-
return ExplicitPageResult::explicitDirPage;
3488+
AUTO_TRACE_EXIT("result=ExplicitPageResult::explicitOtherPage");
3489+
return ExplicitPageResult::explicitOtherPage;
34813490
}
34823491
}
34833492
AUTO_TRACE_EXIT("result=ExplicitPageResult::notExplicit");
@@ -3629,6 +3638,7 @@ void MarkdownOutlineParser::parseInput(const QCString &fileName,
36293638
current->docFile = fileName;
36303639
current->docLine = 1;
36313640
QCString docs = stripIndentation(fileBuf);
3641+
if (!docs.stripWhiteSpace().size()) return;
36323642
Debug::print(Debug::Markdown,0,"======== Markdown =========\n---- input ------- \n{}\n",fileBuf);
36333643
QCString id;
36343644
Markdown markdown(fileName,1,0);
@@ -3721,7 +3731,7 @@ void MarkdownOutlineParser::parseInput(const QCString &fileName,
37213731
break;
37223732
case ExplicitPageResult::explicitMainPage:
37233733
break;
3724-
case ExplicitPageResult::explicitDirPage:
3734+
case ExplicitPageResult::explicitOtherPage:
37253735
break;
37263736
}
37273737
int lineNr=1;

0 commit comments

Comments
 (0)