Skip to content

Commit 7cd735a

Browse files
committed
Merge branch 'master' of github.com:doxygen/doxygen
2 parents 3cb3c36 + 44ad700 commit 7cd735a

File tree

4 files changed

+254
-39
lines changed

4 files changed

+254
-39
lines changed

src/commentscan.l

Lines changed: 75 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef yyguts_t *yyscan_t;
5959
#include "parserintf.h"
6060
#include "reflist.h"
6161
#include "section.h"
62+
#include "regex.h"
6263
#include "util.h"
6364
#include "reflist.h"
6465
#include "trace.h"
@@ -469,6 +470,7 @@ struct commentscanYY_state
469470
QCString anchorTitle;
470471
QCString htmlAnchorStr;
471472
bool htmlAnchor = false;
473+
bool CScode = false;
472474
};
473475

474476

@@ -529,12 +531,14 @@ IMG [iI][mM][gG]
529531
HR [hH][rR]
530532
PARA [pP][aA][rR][aA]
531533
CODE [cC][oO][dD][eE]
534+
ENDCODE "/"{CODE}
532535
CAPTION [cC][aA][pP][tT][iI][oO][nN]
533536
CENTER [cC][eE][nN][tT][eE][rR]
534537
DIV [dD][iI][vV]
535538
DETAILS [dD][eE][tT][aA][iI][lL][sS]
536539
DETAILEDHTML {CENTER}|{DIV}|{PRE}|{UL}|{TABLE}|{OL}|{DL}|{P}|[Hh][1-6]|{IMG}|{HR}|{PARA}
537540
DETAILEDHTMLOPT {CODE}
541+
DETAILEDHTMLOPTEND {ENDCODE}
538542
SUMMARY [sS][uU][mM][mM][aA][rR][yY]
539543
REMARKS [rR][eE][mM][aA][rR][kK][sS]
540544
AHTML [aA]{BN}*
@@ -668,7 +672,35 @@ STopt [^\n@\\]*
668672
// continue with the same input
669673
REJECT;
670674
}
671-
<Comment>"<"{DETAILEDHTMLOPT}{ATTR}">" { // HTML command that ends a brief description
675+
<Comment>"<"{DETAILEDHTMLOPT}">" { // HTML <code> command that ends a brief description
676+
// without attributes
677+
if (yyextra->current->lang==SrcLangExt_CSharp)
678+
{
679+
yyextra->CScode=true;
680+
setOutput(yyscanner,OutputDoc);
681+
addOutput(yyscanner,"@code{cs}");
682+
}
683+
else
684+
{
685+
// continue with the same input
686+
REJECT;
687+
}
688+
}
689+
<Comment>"<"{DETAILEDHTMLOPTEND}">" { // HTML command that ends a brief description
690+
if (yyextra->CScode)
691+
{
692+
addOutput(yyscanner,"@endcode");
693+
yyextra->CScode=false;
694+
}
695+
else
696+
{
697+
yyextra->CScode=false;
698+
// continue with the same input
699+
REJECT;
700+
}
701+
}
702+
<Comment>"<"{DETAILEDHTMLOPT}{ATTR}">" { // HTML <code> command that ends a brief description
703+
// with attributes, so cannot be CS.
672704
if (yyextra->current->lang==SrcLangExt_CSharp)
673705
{
674706
setOutput(yyscanner,OutputDoc);
@@ -1065,7 +1097,7 @@ STopt [^\n@\\]*
10651097
yyextra->briefEndsAtDot=FALSE;
10661098
}
10671099
}
1068-
<Comment>{DOCNL} { // newline
1100+
<Comment>{DOCNL} { // newline
10691101
addOutput(yyscanner,yytext);
10701102
if (*yytext == '\n') yyextra->lineNr++;
10711103
}
@@ -3847,29 +3879,52 @@ static inline void setOutput(yyscan_t yyscanner,OutputContext ctx)
38473879
yyextra->pOutputString = &yyextra->current->doc;
38483880
break;
38493881
case OutputBrief:
3850-
if (oldContext!=yyextra->inContext)
38513882
{
3852-
if (yyextra->current->brief.isEmpty()) yyextra->current->briefLine = yyextra->lineNr;
3853-
if (yyextra->current->briefFile.isEmpty())
3883+
if (oldContext!=yyextra->inContext)
38543884
{
3855-
yyextra->current->briefFile = yyextra->fileName;
3856-
yyextra->current->briefLine = yyextra->lineNr;
3885+
if (yyextra->current->brief.isEmpty()) yyextra->current->briefLine = yyextra->lineNr;
3886+
if (yyextra->current->briefFile.isEmpty())
3887+
{
3888+
yyextra->current->briefFile = yyextra->fileName;
3889+
yyextra->current->briefLine = yyextra->lineNr;
3890+
}
38573891
}
3858-
}
3859-
if (yyextra->current->brief.stripWhiteSpace().isEmpty()) // we only want one brief
3860-
// description even if multiple
3861-
// are given...
3862-
{
3863-
yyextra->pOutputString = &yyextra->current->brief;
3864-
}
3865-
else
3866-
{
3867-
if (!yyextra->current->doc.isEmpty()) // when appending parts add a new line
3892+
bool foundMatch = false;
3893+
if (yyextra->current->brief.stripWhiteSpace().isEmpty()) // we only want one brief
3894+
// description even if multiple
3895+
// are given...
3896+
{
3897+
foundMatch = true;
3898+
}
3899+
else
3900+
{
3901+
static const reg::Ex nonBrief(R"( *[\\@]ifile *\"[^\"]*\" *[\\@]ilinebr *[\\@]iline *(\d+) *[\\@]ilinebr *([\n]?))");
3902+
std::string str = yyextra->current->brief.str();
3903+
reg::Match match;
3904+
if (reg::match(str,match,nonBrief)) // match found
3905+
{
3906+
if (QCString(match[2].str()) == "\n")
3907+
{
3908+
yyextra->current->brief = yyextra->current->brief.left(yyextra->current->brief.length()-1);
3909+
// set warning line correct
3910+
yyextra->current->brief += "\\iline " + QCString().setNum(1 + static_cast<int>(std::stoul(match[1].str()))) + " \\ilinebr ";
3911+
}
3912+
foundMatch = true;
3913+
}
3914+
}
3915+
if (foundMatch)
3916+
{
3917+
yyextra->pOutputString = &yyextra->current->brief;
3918+
}
3919+
else
38683920
{
3869-
yyextra->current->doc += "\n";
3921+
if (!yyextra->current->doc.isEmpty()) // when appending parts add a new line
3922+
{
3923+
yyextra->current->doc += "\n";
3924+
}
3925+
yyextra->pOutputString = &yyextra->current->doc;
3926+
yyextra->inContext = OutputDoc; // need to switch to detailed docs, see bug 631380
38703927
}
3871-
yyextra->pOutputString = &yyextra->current->doc;
3872-
yyextra->inContext = OutputDoc; // need to switch to detailed docs, see bug 631380
38733928
}
38743929
break;
38753930
case OutputXRef:

0 commit comments

Comments
 (0)