Skip to content

Commit 70d1528

Browse files
committed
Refactoring: pack optional params of generateDoc/validatingParseDoc into a class
1 parent 0829265 commit 70d1528

25 files changed

+640
-344
lines changed

src/classdef.cpp

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,9 +1564,14 @@ void ClassDefImpl::writeBriefDescription(OutputList &ol,bool exampleFlag) const
15641564
ol.disableAllBut(OutputType::Man);
15651565
ol.writeString(" - ");
15661566
ol.popGeneratorState();
1567-
ol.generateDoc(briefFile(),briefLine(),this,nullptr,
1568-
briefDescription(),TRUE,FALSE,QCString(),
1569-
TRUE,FALSE);
1567+
ol.generateDoc(briefFile(),
1568+
briefLine(),
1569+
this,
1570+
nullptr,
1571+
briefDescription(),
1572+
DocOptions().
1573+
setIndexWords(true).
1574+
setSingleLine(true));
15701575
ol.pushGeneratorState();
15711576
ol.disable(OutputType::RTF);
15721577
ol.writeString(" \n");
@@ -1597,8 +1602,12 @@ void ClassDefImpl::writeDetailedDocumentationBody(OutputList &ol) const
15971602
// repeat brief description
15981603
if (!briefDescription().isEmpty() && repeatBrief)
15991604
{
1600-
ol.generateDoc(briefFile(),briefLine(),this,nullptr,briefDescription(),FALSE,FALSE,
1601-
QCString(),FALSE,FALSE);
1605+
ol.generateDoc(briefFile(),
1606+
briefLine(),
1607+
this,
1608+
nullptr,
1609+
briefDescription(),
1610+
DocOptions());
16021611
}
16031612
if (!briefDescription().isEmpty() && repeatBrief &&
16041613
!documentation().isEmpty())
@@ -1611,8 +1620,13 @@ void ClassDefImpl::writeDetailedDocumentationBody(OutputList &ol) const
16111620
// write documentation
16121621
if (!documentation().isEmpty())
16131622
{
1614-
ol.generateDoc(docFile(),docLine(),this,nullptr,documentation(),TRUE,FALSE,
1615-
QCString(),FALSE,FALSE);
1623+
ol.generateDoc(docFile(),
1624+
docLine(),
1625+
this,
1626+
nullptr,
1627+
documentation(),
1628+
DocOptions().
1629+
setIndexWords(true));
16161630
}
16171631
// write type constraints
16181632
writeTypeConstraints(ol,this,m_typeConstraints);
@@ -1622,10 +1636,8 @@ void ClassDefImpl::writeDetailedDocumentationBody(OutputList &ol) const
16221636
this,
16231637
nullptr, // memberDef
16241638
inlineTemplateArgListToDoc(m_tempArgs), // docStr
1625-
TRUE, // indexWords
1626-
FALSE, // isExample
1627-
QCString(),FALSE,FALSE
1628-
);
1639+
DocOptions().
1640+
setIndexWords(true));
16291641

16301642
// write examples
16311643
if (hasExamples())
@@ -2691,9 +2703,14 @@ void ClassDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const QCStrin
26912703
{
26922704
auto parser { createDocParser() };
26932705
auto ast { validatingParseDoc(*parser.get(),
2694-
briefFile(),briefLine(),this,nullptr,
2695-
briefDescription(),FALSE,FALSE,
2696-
QCString(),TRUE,FALSE) };
2706+
briefFile(),
2707+
briefLine(),
2708+
this,
2709+
nullptr,
2710+
briefDescription(),
2711+
DocOptions().
2712+
setSingleLine(true))
2713+
};
26972714
if (!ast->isEmpty())
26982715
{
26992716
ol.startMemberDescription(anchor());

src/conceptdef.cpp

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,16 @@ void ConceptDefImpl::writeBriefDescription(OutputList &ol) const
326326
if (hasBriefDescription())
327327
{
328328
auto parser { createDocParser() };
329-
auto ast { validatingParseDoc(
330-
*parser.get(),briefFile(),briefLine(),this,nullptr,
331-
briefDescription(),TRUE,FALSE,
332-
QCString(),TRUE,FALSE) };
329+
auto ast { validatingParseDoc(*parser.get(),
330+
briefFile(),
331+
briefLine(),
332+
this,
333+
nullptr,
334+
briefDescription(),
335+
DocOptions().
336+
setIndexWords(true).
337+
setSingleLine(true))
338+
};
333339
if (!ast->isEmpty())
334340
{
335341
ol.startParagraph();
@@ -468,8 +474,12 @@ void ConceptDefImpl::writeDetailedDescription(OutputList &ol,const QCString &tit
468474
// repeat brief description
469475
if (!briefDescription().isEmpty() && repeatBrief)
470476
{
471-
ol.generateDoc(briefFile(),briefLine(),this,nullptr,briefDescription(),FALSE,FALSE,
472-
QCString(),FALSE,FALSE);
477+
ol.generateDoc(briefFile(),
478+
briefLine(),
479+
this,
480+
nullptr,
481+
briefDescription(),
482+
DocOptions());
473483
}
474484
if (!briefDescription().isEmpty() && repeatBrief &&
475485
!documentation().isEmpty())
@@ -483,8 +493,13 @@ void ConceptDefImpl::writeDetailedDescription(OutputList &ol,const QCString &tit
483493
// write documentation
484494
if (!documentation().isEmpty())
485495
{
486-
ol.generateDoc(docFile(),docLine(),this,nullptr,documentation(),TRUE,FALSE,
487-
QCString(),FALSE,FALSE);
496+
ol.generateDoc(docFile(),
497+
docLine(),
498+
this,
499+
nullptr,
500+
documentation(),
501+
DocOptions().
502+
setIndexWords(true));
488503
}
489504

490505
writeSourceDef(ol);
@@ -682,10 +697,15 @@ void ConceptDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const QCStr
682697
if (!briefDescription().isEmpty() && Config_getBool(BRIEF_MEMBER_DESC))
683698
{
684699
auto parser { createDocParser() };
685-
auto ast { validatingParseDoc(
686-
*parser.get(),briefFile(),briefLine(),this,nullptr,
687-
briefDescription(),FALSE,FALSE,
688-
QCString(),TRUE,FALSE) };
700+
auto ast { validatingParseDoc(*parser.get(),
701+
briefFile(),
702+
briefLine(),
703+
this,
704+
nullptr,
705+
briefDescription(),
706+
DocOptions().
707+
setSingleLine(true))
708+
};
689709
if (!ast->isEmpty())
690710
{
691711
ol.startMemberDescription(anchor());

src/definition.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,8 +1462,14 @@ void DefinitionImpl::writeToc(OutputList &ol, const LocalToc &localToc) const
14621462
const Definition *scope = p->def->definitionType()==Definition::TypeMember ? p->def->getOuterScope() : p->def;
14631463
QCString docTitle = si->title();
14641464
if (docTitle.isEmpty()) docTitle = si->label();
1465-
ol.generateDoc(docFile(),getStartBodyLine(),scope,md,docTitle,TRUE,FALSE,
1466-
QCString(),TRUE,FALSE);
1465+
ol.generateDoc(docFile(),
1466+
getStartBodyLine(),
1467+
scope,
1468+
md,
1469+
docTitle,
1470+
DocOptions().
1471+
setIndexWords(true).
1472+
setSingleLine(true));
14671473
ol.endTocEntry(si);
14681474
}
14691475
}

src/dirdef.cpp

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,12 @@ void DirDefImpl::writeDetailedDescription(OutputList &ol,const QCString &title)
249249
// repeat brief description
250250
if (!briefDescription().isEmpty() && Config_getBool(REPEAT_BRIEF))
251251
{
252-
ol.generateDoc(briefFile(),briefLine(),this,nullptr,briefDescription(),FALSE,FALSE,
253-
QCString(),FALSE,FALSE);
252+
ol.generateDoc(briefFile(),
253+
briefLine(),
254+
this,
255+
nullptr,
256+
briefDescription(),
257+
DocOptions());
254258
}
255259
// separator between brief and details
256260
if (!briefDescription().isEmpty() && Config_getBool(REPEAT_BRIEF) &&
@@ -269,8 +273,13 @@ void DirDefImpl::writeDetailedDescription(OutputList &ol,const QCString &title)
269273
// write documentation
270274
if (!documentation().isEmpty())
271275
{
272-
ol.generateDoc(docFile(),docLine(),this,nullptr,documentation()+"\n",TRUE,FALSE,
273-
QCString(),FALSE,FALSE);
276+
ol.generateDoc(docFile(),
277+
docLine(),
278+
this,
279+
nullptr,
280+
documentation()+"\n",
281+
DocOptions().
282+
setIndexWords(true));
274283
}
275284
}
276285
}
@@ -281,9 +290,15 @@ void DirDefImpl::writeBriefDescription(OutputList &ol)
281290
if (hasBriefDescription())
282291
{
283292
auto parser { createDocParser() };
284-
auto ast { validatingParseDoc(
285-
*parser.get(), briefFile(),briefLine(),this,nullptr,briefDescription(),TRUE,FALSE,
286-
QCString(),FALSE,FALSE) };
293+
auto ast { validatingParseDoc(*parser.get(),
294+
briefFile(),
295+
briefLine(),
296+
this,
297+
nullptr,
298+
briefDescription(),
299+
DocOptions().
300+
setIndexWords(true))
301+
};
287302
if (!ast->isEmpty())
288303
{
289304
ol.startParagraph();
@@ -382,13 +397,14 @@ void DirDefImpl::writeSubDirList(OutputList &ol)
382397
if (!dd->briefDescription().isEmpty() && Config_getBool(BRIEF_MEMBER_DESC))
383398
{
384399
ol.startMemberDescription(dd->getOutputFileBase());
385-
ol.generateDoc(briefFile(),briefLine(),dd,nullptr,dd->briefDescription(),
386-
FALSE, // indexWords
387-
FALSE, // isExample
388-
QCString(), // exampleName
389-
TRUE, // single line
390-
TRUE // link from index
391-
);
400+
ol.generateDoc(briefFile(),
401+
briefLine(),
402+
dd,
403+
nullptr,
404+
dd->briefDescription(),
405+
DocOptions().
406+
setSingleLine(true).
407+
setLinkFromIndex(true));
392408
ol.endMemberDescription();
393409
}
394410
ol.endMemberDeclaration(dd->anchor(),QCString());
@@ -467,13 +483,14 @@ void DirDefImpl::writeFileList(OutputList &ol)
467483
if (!fd->briefDescription().isEmpty() && Config_getBool(BRIEF_MEMBER_DESC))
468484
{
469485
ol.startMemberDescription(fd->getOutputFileBase());
470-
ol.generateDoc(briefFile(),briefLine(),fd,nullptr,fd->briefDescription(),
471-
FALSE, // indexWords
472-
FALSE, // isExample
473-
QCString(), // exampleName
474-
TRUE, // single line
475-
TRUE // link from index
476-
);
486+
ol.generateDoc(briefFile(),
487+
briefLine(),
488+
fd,
489+
nullptr,
490+
fd->briefDescription(),
491+
DocOptions().
492+
setSingleLine(true).
493+
setLinkFromIndex(true));
477494
ol.endMemberDescription();
478495
}
479496
ol.endMemberDeclaration(fd->anchor(),QCString());

src/docoptions.h

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/******************************************************************************
2+
*
3+
* Copyright (C) 1997-2025 by Dimitri van Heesch.
4+
*
5+
* Permission to use, copy, modify, and distribute this software and its
6+
* documentation under the terms of the GNU General Public License is hereby
7+
* granted. No representations are made about the suitability of this software
8+
* for any purpose. It is provided "as is" without express or implied warranty.
9+
* See the GNU General Public License for more details.
10+
*
11+
* Documents produced by Doxygen are derivative works derived from the
12+
* input used in their production; they are not affected by this license.
13+
*
14+
*/
15+
16+
#ifndef DOCOPTIONS_H
17+
#define DOCOPTIONS_H
18+
19+
#include "config.h"
20+
#include "qcstring.h"
21+
22+
struct DocOptions
23+
{
24+
public:
25+
// === getters for optional params
26+
bool indexWords() const { return m_indexWords; }
27+
bool isExample() const { return m_isExample; }
28+
QCString exampleName() const { return m_exampleName; }
29+
bool singleLine() const { return m_singleLine; }
30+
bool linkFromIndex() const { return m_linkFromIndex; }
31+
bool markdownSupport() const { return m_markdownSupport; }
32+
bool autolinkSupport() const { return m_autolinkSupport; }
33+
34+
// === setters for optional params
35+
36+
/// Indicates whether or not words should be put in the search index.
37+
DocOptions &setIndexWords(bool b)
38+
{ m_indexWords=b; return *this; }
39+
40+
/// Associate this comment block with a given example
41+
DocOptions &setExample(const QCString &name)
42+
{ m_isExample=!name.isEmpty(); m_exampleName = name; return *this; }
43+
44+
/// Select if this is for a single line, so without starting a new paragraph at the end.
45+
DocOptions &setSingleLine(bool b)
46+
{ m_singleLine=b; return *this; }
47+
48+
/// Select if the documentation is generated from an
49+
/// index page. In this case context is not used to determine
50+
/// the relative path when making a link.
51+
DocOptions &setLinkFromIndex(bool b)
52+
{ m_linkFromIndex=b; return *this; }
53+
54+
/// Select if the input needs to take markdown markup into account.
55+
DocOptions &setMarkdownSupport(bool b)
56+
{ m_markdownSupport=b; return *this; }
57+
58+
/// Select if the input need to perform auto linking of words
59+
DocOptions &setAutolinkSupport(bool b)
60+
{ m_autolinkSupport=b; return *this; }
61+
62+
private:
63+
// optional params with defaults
64+
bool m_indexWords = false;
65+
bool m_isExample = false;
66+
QCString m_exampleName;
67+
bool m_singleLine = false;
68+
bool m_linkFromIndex = false;
69+
bool m_markdownSupport = Config_getBool(MARKDOWN_SUPPORT);
70+
bool m_autolinkSupport = Config_getBool(AUTOLINK_SUPPORT);
71+
};
72+
73+
#endif
74+

0 commit comments

Comments
 (0)