Skip to content

Commit ae33339

Browse files
committed
issue doxygen#11831 @ref not supported in <summary> tag
Added possibility to use the `\ref` command in the `<summary>` tag
1 parent 41d5bbb commit ae33339

File tree

6 files changed

+55
-29
lines changed

6 files changed

+55
-29
lines changed

src/docnode.cpp

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,12 @@ void DocHtmlSummary::parse()
14361436
{
14371437
break;
14381438
}
1439+
else if (((tok.value()==TokenRetval::TK_COMMAND_AT) || (tok.value()==TokenRetval::TK_COMMAND_BS)) &&
1440+
(Mappers::cmdMapper->map(parser()->context.token->name)== CommandType::CMD_REF))
1441+
{
1442+
parser()->handleRef(thisVariant(),children(),
1443+
tok.value()==TokenRetval::TK_COMMAND_AT ? '@' : '\\',parser()->context.token->name);
1444+
}
14391445
else if (!parser()->defaultHandleToken(thisVariant(),tok,children()))
14401446
{
14411447
parser()->errorHandleDefaultToken(thisVariant(),tok,children(),"summary section");
@@ -3961,33 +3967,6 @@ void DocPara::handleLink(const QCString &cmdName,bool isJavaLink)
39613967
}
39623968
}
39633969

3964-
void DocPara::handleRef(char cmdChar,const QCString &cmdName)
3965-
{
3966-
AUTO_TRACE("cmdName={}",cmdName);
3967-
QCString saveCmdName = cmdName;
3968-
Token tok=parser()->tokenizer.lex();
3969-
if (!tok.is(TokenRetval::TK_WHITESPACE))
3970-
{
3971-
warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"expected whitespace after '{:c}{}' command",
3972-
cmdChar,qPrint(saveCmdName));
3973-
return;
3974-
}
3975-
parser()->tokenizer.setStateRef();
3976-
tok=parser()->tokenizer.lex(); // get the reference id
3977-
if (!tok.is(TokenRetval::TK_WORD))
3978-
{
3979-
warn_doc_error(parser()->context.fileName,parser()->tokenizer.getLineNr(),"unexpected token {} as the argument of '{:c}{}'",
3980-
tok.to_string(),cmdChar,saveCmdName);
3981-
goto endref;
3982-
}
3983-
children().append<DocRef>(parser(),thisVariant(),
3984-
parser()->context.token->name,
3985-
parser()->context.context);
3986-
children().get_last<DocRef>()->parse();
3987-
endref:
3988-
parser()->tokenizer.setStatePara();
3989-
}
3990-
39913970
void DocPara::handleInclude(const QCString &cmdName,DocInclude::Type t)
39923971
{
39933972
AUTO_TRACE("cmdName={}",cmdName);
@@ -4884,7 +4863,7 @@ Token DocPara::handleCommand(char cmdChar, const QCString &cmdName)
48844863
break;
48854864
case CommandType::CMD_REF: // fall through
48864865
case CommandType::CMD_SUBPAGE:
4887-
handleRef(cmdChar,cmdName);
4866+
parser()->handleRef(thisVariant(),children(),cmdChar,cmdName);
48884867
break;
48894868
case CommandType::CMD_SECREFLIST:
48904869
{

src/docnode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,6 @@ class DocPara : public DocCompoundNode
11001100
void handleCite(char cmdChar,const QCString &cmdName);
11011101
void handleDoxyConfig(char cmdChar,const QCString &cmdName);
11021102
void handleEmoji(char cmdChar,const QCString &cmdName);
1103-
void handleRef(char cmdChar,const QCString &cmdName);
11041103
void handleSection(char cmdChar,const QCString &cmdName);
11051104
void handleInheritDoc();
11061105
void handleVhdlFlow();

src/docparser.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,6 +1199,35 @@ void DocParser::handleImage(DocNodeVariant *parent, DocNodeList &children)
11991199
children.get_last<DocImage>()->parse();
12001200
}
12011201

1202+
void DocParser::handleRef(DocNodeVariant *parent, DocNodeList &children, char cmdChar, const QCString &cmdName)
1203+
{
1204+
AUTO_TRACE("cmdName={}",cmdName);
1205+
QCString saveCmdName = cmdName;
1206+
int saveState = tokenizer.getState();
1207+
Token tok=tokenizer.lex();
1208+
if (!tok.is(TokenRetval::TK_WHITESPACE))
1209+
{
1210+
warn_doc_error(context.fileName,tokenizer.getLineNr(),"expected whitespace after '{:c}{}' command",
1211+
cmdChar,qPrint(saveCmdName));
1212+
return;
1213+
}
1214+
tokenizer.setStateRef();
1215+
tok=tokenizer.lex(); // get the reference id
1216+
if (!tok.is(TokenRetval::TK_WORD))
1217+
{
1218+
warn_doc_error(context.fileName,tokenizer.getLineNr(),"unexpected token {} as the argument of '{:c}{}'",
1219+
tok.to_string(),cmdChar,saveCmdName);
1220+
goto endref;
1221+
}
1222+
children.append<DocRef>(this,parent,
1223+
context.token->name,
1224+
context.context);
1225+
children.get_last<DocRef>()->parse();
1226+
endref:
1227+
tokenizer.setState(saveState);
1228+
}
1229+
1230+
12021231

12031232
/* Helper function that deals with the most common tokens allowed in
12041233
* title like sections.

src/docparser_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class DocParser : public IDocParser
136136
void handleAnchor(DocNodeVariant *parent,DocNodeList &children);
137137
void handlePrefix(DocNodeVariant *parent,DocNodeList &children);
138138
void handleImage(DocNodeVariant *parent, DocNodeList &children);
139+
void handleRef(DocNodeVariant *parent, DocNodeList &children, char cmdChar, const QCString &cmdName);
139140
void readTextFileByName(const QCString &file,QCString &text);
140141

141142
std::stack< DocParserContext > contextStack;

src/doctokenizer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ class DocTokenizer
194194
void pushState();
195195
void popState();
196196

197+
int getState();
198+
void setState(int newState);
199+
197200
// operations on the scanner
198201
void findSections(const QCString &input,const Definition *d,
199202
const QCString &fileName);

src/doctokenizer.l

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,4 +2227,19 @@ void DocTokenizer::popState()
22272227
yyextra->stateStack.pop();
22282228
}
22292229
2230+
int DocTokenizer::getState()
2231+
{
2232+
yyscan_t yyscanner = p->yyscanner;
2233+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2234+
return YYSTATE;
2235+
}
2236+
2237+
void DocTokenizer::setState(int newState)
2238+
{
2239+
yyscan_t yyscanner = p->yyscanner;
2240+
struct yyguts_t *yyg = (struct yyguts_t*)yyscanner;
2241+
BEGIN(newState);
2242+
}
2243+
2244+
22302245
#include "doctokenizer.l.h"

0 commit comments

Comments
 (0)