Skip to content

Commit b9ac9e4

Browse files
committed
issue doxygen#11373 Code examples in Python docstrings rendered in HTML with wrong indentation beyond 8 spaces
1 parent 2a4d39e commit b9ac9e4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/pyscanner.l

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct pyscannerYY_state
121121
TextStream decoratorCommentStr;
122122
int decoratorRound = 0;
123123
bool checkDupEntry = false;
124+
bool firstPass = true;
124125
};
125126

126127
//-----------------------------------------------------------------------------
@@ -1480,7 +1481,7 @@ ID [a-z_A-Z%]+{IDSYM}*
14801481

14811482

14821483
^{BB} { // leading whitespace, compensate for """! / '''!
1483-
if (yyextra->docBlockSpecial && yyleng >= yyextra->curIndent)
1484+
if (yyextra->firstPass && yyextra->docBlockSpecial && yyleng >= yyextra->curIndent)
14841485
yyextra->docBlock += yytext + yyextra->curIndent;
14851486
else
14861487
yyextra->docBlock += yytext;
@@ -2164,6 +2165,7 @@ static void parseCompounds(yyscan_t yyscanner,std::shared_ptr<Entry> rt)
21642165
yyextra->programStr = ce->program.str();
21652166
yyextra->inputString = yyextra->programStr.data();
21662167
yyextra->inputPosition = 0;
2168+
yyextra->firstPass = false;
21672169
pyscannerYYrestart( nullptr, yyscanner );
21682170
if (ce->section.isCompound())
21692171
{
@@ -2221,9 +2223,10 @@ static void parseMain(yyscan_t yyscanner, const QCString &fileName,const char *f
22212223
yyextra->current_root = rt;
22222224
yyextra->specialBlock = false;
22232225

2224-
yyextra->yyLineNr= 1 ;
2225-
yyextra->fileName = fileName;
2226+
yyextra->yyLineNr = 1 ;
2227+
yyextra->fileName = fileName;
22262228
yyextra->checkDupEntry = false;
2229+
yyextra->firstPass = true;
22272230
//setContext();
22282231
msg("Parsing file {}...\n",yyextra->fileName);
22292232

0 commit comments

Comments
 (0)