Skip to content

Commit ae216ab

Browse files
committed
issue doxygen#11755 Behavior of \tableofcontents is different in V.1.14.0 and prior version
Only write out the TOC items in case requested / needed
1 parent f3f4b67 commit ae216ab

File tree

10 files changed

+68
-1
lines changed

10 files changed

+68
-1
lines changed

src/definition.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,8 +1462,9 @@ 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(),
1465+
ol.generateDocTocEntry(docFile(),
14661466
getStartBodyLine(),
1467+
si,
14671468
scope,
14681469
md,
14691470
docTitle,

src/docbookgen.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,28 @@ void DocbookGenerator::endTocEntry(const SectionInfo *si)
14771477
}
14781478
}
14791479

1480+
void DocbookGenerator::generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
1481+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
1482+
const DocOptions &options,int id)
1483+
{
1484+
SectionType type = si->type();
1485+
int nextLevel = type.level();
1486+
if (type.isSection() && nextLevel<=m_tocState.maxLevel)
1487+
{
1488+
if (docStr.isEmpty()) return;
1489+
auto parser { createDocParser() };
1490+
auto ast { validatingParseDoc(*parser.get(),
1491+
fileName,
1492+
startLine,
1493+
ctx,
1494+
md,
1495+
docStr,
1496+
options)
1497+
};
1498+
if (ast) writeDoc(ast.get(),ctx,md,id);
1499+
}
1500+
}
1501+
14801502
//-------------------------------------------------------------------------------------------------
14811503

14821504
static constexpr auto hex="0123456789ABCDEF";

src/docbookgen.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ class DocbookGenerator : public OutputGenerator, public OutputGenIntf
316316
void endLocalToc() override;
317317
void startTocEntry(const SectionInfo *si) override;
318318
void endTocEntry(const SectionInfo *si) override;
319+
void generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
320+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
321+
const DocOptions &options,int id) override;
322+
319323

320324
void startPlainFile(const QCString &name) override { OutputGenerator::startPlainFile(name); }
321325
void endPlainFile() override { OutputGenerator::endPlainFile(); }

src/htmlgen.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3731,3 +3731,24 @@ void HtmlGenerator::endTocEntry(const SectionInfo *si)
37313731
}
37323732
}
37333733

3734+
void HtmlGenerator::generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
3735+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
3736+
const DocOptions &options,int id)
3737+
{
3738+
SectionType type = si->type();
3739+
int nextLevel = type.level();
3740+
if (type.isSection() && nextLevel<=m_tocState.maxLevel)
3741+
{
3742+
if (docStr.isEmpty()) return;
3743+
auto parser { createDocParser() };
3744+
auto ast { validatingParseDoc(*parser.get(),
3745+
fileName,
3746+
startLine,
3747+
ctx,
3748+
md,
3749+
docStr,
3750+
options)
3751+
};
3752+
if (ast) writeDoc(ast.get(),ctx,md,id);
3753+
}
3754+
}

src/htmlgen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ class HtmlGenerator : public OutputGenerator, public OutputGenIntf
330330
void endLocalToc() override;
331331
void startTocEntry(const SectionInfo *si) override;
332332
void endTocEntry(const SectionInfo *si) override;
333+
void generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
334+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
335+
const DocOptions &options,int id) override;
333336

334337
void startPlainFile(const QCString &name) override { OutputGenerator::startPlainFile(name); }
335338
void endPlainFile() override { OutputGenerator::endPlainFile(); }

src/latexgen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,9 @@ class LatexGenerator : public OutputGenerator, public OutputGenIntf
315315
void endLocalToc() override {}
316316
void startTocEntry(const SectionInfo *) override {}
317317
void endTocEntry(const SectionInfo *) override {}
318+
void generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
319+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
320+
const DocOptions &options,int id) override {}
318321

319322
void startPlainFile(const QCString &name) override { OutputGenerator::startPlainFile(name); }
320323
void endPlainFile() override { OutputGenerator::endPlainFile(); }

src/mangen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ class ManGenerator : public OutputGenerator, public OutputGenIntf
285285
void endLocalToc() override {}
286286
void startTocEntry(const SectionInfo *) override {}
287287
void endTocEntry(const SectionInfo *) override {}
288+
void generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
289+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
290+
const DocOptions &options,int id) override {}
288291

289292
void startPlainFile(const QCString &name) override { OutputGenerator::startPlainFile(name); }
290293
void endPlainFile() override { OutputGenerator::endPlainFile(); }

src/outputgen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@ class OutputGenIntf
320320
virtual void endLocalToc() = 0;
321321
virtual void startTocEntry(const SectionInfo *si) = 0;
322322
virtual void endTocEntry(const SectionInfo *si) = 0;
323+
virtual void generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
324+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
325+
const DocOptions &options,int id) = 0;
323326
virtual void cleanup() = 0;
324327
virtual void startPlainFile(const QCString &name) = 0;
325328
virtual void endPlainFile() = 0;

src/outputlist.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,10 @@ class OutputList
749749
{ foreach(&OutputGenIntf::startTocEntry,si); }
750750
void endTocEntry(const SectionInfo *si)
751751
{ foreach(&OutputGenIntf::endTocEntry,si); }
752+
void generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
753+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
754+
const DocOptions &options)
755+
{ foreach(&OutputGenIntf::generateDocTocEntry,fileName,startLine,si,ctx,md,docStr,options,m_id); }
752756
void cleanup()
753757
{ foreach(&OutputGenIntf::cleanup); }
754758
void startPlainFile(const QCString &name)

src/rtfgen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ class RTFGenerator : public OutputGenerator, public OutputGenIntf
302302
void endLocalToc() override {}
303303
void startTocEntry(const SectionInfo *) override {}
304304
void endTocEntry(const SectionInfo *) override {}
305+
void generateDocTocEntry(const QCString &fileName,int startLine,const SectionInfo *si,
306+
const Definition *ctx,const MemberDef *md,const QCString &docStr,
307+
const DocOptions &options,int id) override {}
305308

306309
void startPlainFile(const QCString &name) override { OutputGenerator::startPlainFile(name); }
307310
void endPlainFile() override { OutputGenerator::endPlainFile(); }

0 commit comments

Comments
 (0)