Skip to content

Commit f5ed826

Browse files
authored
Merge pull request doxygen#11347 from albert-github/feature/bug_683051
bug 683051 Template parameter cannot be commented inline
2 parents 307eb89 + 8a6c107 commit f5ed826

File tree

8 files changed

+94
-5
lines changed

8 files changed

+94
-5
lines changed

src/arguments.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,10 @@ bool ArgumentList::hasDocumentation() const
2323
return std::any_of(begin(),end(),[](const Argument &a){ return a.hasDocumentation(); });
2424
}
2525

26+
/*! the template argument list is documented if one of its
27+
* template arguments is documented
28+
*/
29+
bool ArgumentList::hasTemplateDocumentation() const
30+
{
31+
return std::any_of(begin(),end(),[](const Argument &a){ return a.hasTemplateDocumentation(); });
32+
}

src/arguments.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ struct Argument
3333
return !name.isEmpty() && !docs.isEmpty();
3434
}
3535

36+
bool hasTemplateDocumentation() const
37+
{
38+
return (!name.isEmpty() || !type.isEmpty()) && !docs.isEmpty();
39+
}
40+
3641
QCString attrib; /*!< Argument's attribute (IDL only) */
3742
QCString type; /*!< Argument's type */
3843
QCString canType; /*!< Cached value of canonical type (after type resolution). Empty initially. */
@@ -65,6 +70,8 @@ class ArgumentList
6570

6671
/*! Does any argument of this list have documentation? */
6772
bool hasDocumentation() const;
73+
/*! Does any template argument of this list have documentation? */
74+
bool hasTemplateDocumentation() const;
6875
/*! Does this list have zero or more parameters */
6976
bool hasParameters() const
7077
{

src/classdef.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,16 @@ void ClassDefImpl::writeDetailedDocumentationBody(OutputList &ol) const
16151615
// write type constraints
16161616
writeTypeConstraints(ol,this,m_typeConstraints);
16171617

1618+
ol.generateDoc(
1619+
docFile(),docLine(),
1620+
this,
1621+
nullptr, // memberDef
1622+
inlineTemplateArgListToDoc(m_tempArgs), // docStr
1623+
TRUE, // indexWords
1624+
FALSE, // isExample
1625+
QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)
1626+
);
1627+
16181628
// write examples
16191629
if (hasExamples())
16201630
{
@@ -1633,7 +1643,7 @@ bool ClassDefImpl::hasDetailedDescription() const
16331643
bool repeatBrief = Config_getBool(REPEAT_BRIEF);
16341644
bool sourceBrowser = Config_getBool(SOURCE_BROWSER);
16351645
return ((!briefDescription().isEmpty() && repeatBrief) ||
1636-
!documentation().isEmpty() ||
1646+
(!documentation().isEmpty() || m_tempArgs.hasTemplateDocumentation()) ||
16371647
(sourceBrowser && getStartBodyLine()!=-1 && getBodyDef()));
16381648
}
16391649

@@ -3555,15 +3565,15 @@ bool ClassDefImpl::isLinkableInProject() const
35553565
// !isAnonymous(),
35563566
// m_prot,
35573567
// !m_isLocal || extractLocal,
3558-
// hasDocumentation() || !hideUndoc,
3568+
// hasDocumentation() || m_tempArgs.hasTemplateDocumentation() || !hideUndoc,
35593569
// !m_isStatic || extractStatic,
35603570
// !isReference());
35613571
return
35623572
!isArtificial() && !isHidden() && /* not hidden */
35633573
!isAnonymous() && /* not anonymous */
35643574
protectionLevelVisible(m_prot) && /* private/internal */
35653575
(!m_isLocal || extractLocal) && /* local */
3566-
(hasDocumentation() || !hideUndoc) && /* documented */
3576+
(hasDocumentation() || m_tempArgs.hasTemplateDocumentation() || !hideUndoc) && /* documented */
35673577
(!m_isStatic || extractStatic) && /* static */
35683578
!isReference(); /* not an external reference */
35693579
}

src/memberdef.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,10 @@ bool MemberDefImpl::hasDetailedDescription() const
26912691
// has one or more documented arguments
26922692
(m_templateMaster ?
26932693
m_templateMaster->argumentList().hasDocumentation() :
2694-
m_defArgList.hasDocumentation());
2694+
m_defArgList.hasDocumentation()) ||
2695+
(m_templateMaster ?
2696+
m_templateMaster->templateArguments().hasTemplateDocumentation() :
2697+
m_tArgList.hasTemplateDocumentation());
26952698

26962699
// generate function guard
26972700
// ================== =======
@@ -3873,6 +3876,19 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml,
38733876
QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)
38743877
);
38753878

3879+
const ArgumentList &docTemplateArgList = m_templateMaster ?
3880+
m_templateMaster->templateArguments() :
3881+
m_tArgList;
3882+
ol.generateDoc(
3883+
docFile(),docLine(),
3884+
scopedContainer,
3885+
this, // memberDef
3886+
inlineTemplateArgListToDoc(docTemplateArgList), // docStr
3887+
TRUE, // indexWords
3888+
FALSE, // isExample
3889+
QCString(),FALSE,FALSE,Config_getBool(MARKDOWN_SUPPORT)
3890+
);
3891+
38763892
_writeEnumValues(ol,scopedContainer,cfname,ciname,cname);
38773893
_writeReimplements(ol);
38783894
_writeReimplementedBy(ol);
@@ -4299,7 +4315,7 @@ bool MemberDefImpl::hasDocumentation() const
42994315
{
43004316
return DefinitionMixin::hasDocumentation() ||
43014317
(m_mtype==MemberType::Enumeration && m_docEnumValues) || // has enum values
4302-
(m_defArgList.hasDocumentation()); // has doc arguments
4318+
(m_defArgList.hasDocumentation()|| m_tArgList.hasTemplateDocumentation()); // has doc (template) arguments
43034319
}
43044320

43054321

src/scanner.l

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5035,6 +5035,7 @@ NONLopt [^\n]*
50355035
yyextra->fullArgString+=*yytext;
50365036
//printf("end template list '%s'\n",qPrint(*yyextra->copyArgString));
50375037
*yyextra->currentArgumentList = *stringToArgumentList(yyextra->language, yyextra->fullArgString);
5038+
handleParametersCommentBlocks(yyscanner,yyextra->current->tArgLists.back());
50385039
BEGIN( yyextra->currentArgumentContext );
50395040
}
50405041
<CopyArgRound>"(" {

src/util.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,33 @@ QCString inlineArgListToDoc(const ArgumentList &al)
11711171
return paramDocs;
11721172
}
11731173

1174+
QCString inlineTemplateArgListToDoc(const ArgumentList &al)
1175+
{
1176+
QCString paramDocs;
1177+
if (al.hasTemplateDocumentation())
1178+
{
1179+
for (const Argument &a : al)
1180+
{
1181+
if (!a.docs.isEmpty())
1182+
{
1183+
if (!a.name.isEmpty())
1184+
{
1185+
paramDocs+=" \\ilinebr @tparam "+a.name+" "+a.docs;
1186+
}
1187+
else if (!a.type.isEmpty())
1188+
{
1189+
QCString type = a.type;
1190+
type.stripPrefix("class ");
1191+
type.stripPrefix("typename ");
1192+
type = type.stripWhiteSpace();
1193+
paramDocs+=" \\ilinebr @tparam "+type+" "+a.docs;
1194+
}
1195+
}
1196+
}
1197+
}
1198+
return paramDocs;
1199+
}
1200+
11741201
QCString argListToString(const ArgumentList &al,bool useCanonicalType,bool showDefVals)
11751202
{
11761203
QCString result;

src/util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ inline bool isIdJS(int c)
215215
QCString removeRedundantWhiteSpace(const QCString &s);
216216

217217
QCString inlineArgListToDoc(const ArgumentList &al);
218+
QCString inlineTemplateArgListToDoc(const ArgumentList &al);
218219

219220
QCString argListToString(const ArgumentList &al,bool useCanonicalType=FALSE,bool showDefVals=TRUE);
220221

src/xmlgen.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
// debug inside output
6060
//#define XML_DB(x) QCString __t;__t.sprintf x;m_t << __t
6161

62+
static void writeXMLDocBlock(TextStream &t,
63+
const QCString &fileName,
64+
int lineNr,
65+
const Definition *scope,
66+
const MemberDef * md,
67+
const QCString &text);
6268
//------------------
6369

6470
inline void writeXMLString(TextStream &t,const QCString &s)
@@ -403,6 +409,20 @@ static void writeTemplateArgumentList(TextStream &t,
403409
linkifyText(TextGeneratorXMLImpl(t),scope,fileScope,nullptr,a.typeConstraint);
404410
t << "</typeconstraint>\n";
405411
}
412+
if (a.hasTemplateDocumentation())
413+
{
414+
t << indentStr << " <briefdescription>\n";
415+
t << indentStr << " ";
416+
if (scope)
417+
{
418+
writeXMLDocBlock(t,scope->briefFile(),scope->briefLine(),scope,nullptr,a.docs);
419+
}
420+
else
421+
{
422+
writeXMLDocBlock(t,fileScope->briefFile(),fileScope->briefLine(),fileScope,nullptr,a.docs);
423+
}
424+
t << indentStr << " </briefdescription>\n";
425+
}
406426
t << indentStr << " </param>\n";
407427
}
408428
t << indentStr << "</templateparamlist>\n";

0 commit comments

Comments
 (0)