Skip to content

Commit

Permalink
Make HTML_CODE_FOLDING independent of other unrelated options
Browse files Browse the repository at this point in the history
  • Loading branch information
doxygen committed Jul 17, 2023
1 parent 9159c6c commit 13c194c
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/docbookgen.h
Expand Up @@ -251,7 +251,7 @@ class DocbookGenerator : public OutputGenerator
void writeSplitBar(const QCString &){DB_GEN_EMPTY};
void writeNavigationPath(const QCString &){DB_GEN_NEW};
void writeLogo(){DB_GEN_NEW};
void writeQuickLinks(bool,HighlightedItem,const QCString &){DB_GEN_EMPTY};
void writeQuickLinks(bool,HighlightedItem,const QCString &,bool){DB_GEN_EMPTY};
void writeSummaryLink(const QCString &,const QCString &,const QCString &,bool){DB_GEN_EMPTY};
void startContents(){DB_GEN_EMPTY};
void endContents(){DB_GEN_EMPTY};
Expand Down
8 changes: 5 additions & 3 deletions src/filedef.cpp
Expand Up @@ -1058,7 +1058,8 @@ void FileDefImpl::writeSourceHeader(OutputList &ol)
{
startFile(ol,getSourceFileBase(),QCString(),pageTitle,HighlightedItem::FileVisible,
!generateTreeView,
!isDocFile && genSourceFile ? QCString() : getOutputFileBase());
!isDocFile && genSourceFile ? QCString() : getOutputFileBase(),
0,true);
if (!generateTreeView)
{
getDirDef()->writeNavigationPath(ol);
Expand All @@ -1070,8 +1071,9 @@ void FileDefImpl::writeSourceHeader(OutputList &ol)
}
else
{
startFile(ol,getSourceFileBase(),QCString(),pageTitle,HighlightedItem::FileVisible,FALSE,
!isDocFile && genSourceFile ? QCString() : getOutputFileBase());
startFile(ol,getSourceFileBase(),QCString(),pageTitle,HighlightedItem::FileVisible,false,
!isDocFile && genSourceFile ? QCString() : getOutputFileBase(),
0,true);
startTitle(ol,getSourceFileBase());
ol.parseText(title);
endTitle(ol,getSourceFileBase(),QCString());
Expand Down
34 changes: 15 additions & 19 deletions src/htmlgen.cpp
Expand Up @@ -2750,7 +2750,8 @@ static void renderQuickLinksAsTabs(TextStream &t,const QCString &relPath,
static void writeDefaultQuickLinks(TextStream &t,bool compact,
HighlightedItem hli,
const QCString &file,
const QCString &relPath)
const QCString &relPath,
bool needsFolding)
{
bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
bool searchEngine = Config_getBool(SEARCHENGINE);
Expand Down Expand Up @@ -2822,32 +2823,19 @@ static void writeDefaultQuickLinks(TextStream &t,bool compact,
<< (serverBasedSearch?"true":"false") << ",'"
<< searchPage << "','"
<< theTranslator->trSearch() << "');\n";
QCString initCodeFold;
if (Config_getBool(HTML_CODE_FOLDING))
{
initCodeFold=QCString("init_codefold(") + (relPath.isEmpty() ? "0" : "1") + ");";
}
if (Config_getBool(SEARCHENGINE))
{
if (!serverBasedSearch)
{
t << " $(document).ready(function() { init_search(); " << initCodeFold << "});\n";
t << " $(document).ready(function() { init_search(); });\n";
}
else
{
t << " $(document).ready(function() {\n"
<< " if ($('.searchresults').length > 0) { searchBox.DOMSearchField().focus(); }\n";
if (!initCodeFold.isEmpty())
{
t << " " << initCodeFold << "\n";
}
t << " });\n";
}
}
else if (initCodeFold.isEmpty())
{
t << " $(document).ready(function() { " << initCodeFold << "});\n";
}
t << "});\n";
t << "/* @license-end */\n";
t << "</script>\n";
Expand Down Expand Up @@ -2881,6 +2869,14 @@ static void writeDefaultQuickLinks(TextStream &t,bool compact,
{
renderQuickLinksAsTree(t,relPath,root);
}
if (needsFolding && Config_getBool(HTML_CODE_FOLDING))
{
t << "<script type=\"text/javascript\">\n";
t << "/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */\n";
t << "$(document).ready(function() { init_codefold(" << (relPath.isEmpty() ? "0" : "1") << "); });\n";
t << "/* @license-end */\n";
t << "</script>\n";
}
}

void HtmlGenerator::endQuickIndices()
Expand Down Expand Up @@ -2954,9 +2950,9 @@ void HtmlGenerator::endPageDoc()
m_t << "</div><!-- PageDoc -->\n";
}

void HtmlGenerator::writeQuickLinks(bool compact,HighlightedItem hli,const QCString &file)
void HtmlGenerator::writeQuickLinks(bool compact,HighlightedItem hli,const QCString &file,bool needsFolding)
{
writeDefaultQuickLinks(m_t,compact,hli,file,m_relPath);
writeDefaultQuickLinks(m_t,compact,hli,file,m_relPath,needsFolding);
}

// PHP based search script
Expand Down Expand Up @@ -3016,7 +3012,7 @@ void HtmlGenerator::writeSearchPage()
t << "</script>\n";
if (!Config_getBool(DISABLE_INDEX))
{
writeDefaultQuickLinks(t,TRUE,HighlightedItem::Search,QCString(),QCString());
writeDefaultQuickLinks(t,true,HighlightedItem::Search,QCString(),QCString(),false);
}
else
{
Expand Down Expand Up @@ -3072,7 +3068,7 @@ void HtmlGenerator::writeExternalSearchPage()
t << "</script>\n";
if (!Config_getBool(DISABLE_INDEX))
{
writeDefaultQuickLinks(t,TRUE,HighlightedItem::Search,QCString(),QCString());
writeDefaultQuickLinks(t,true,HighlightedItem::Search,QCString(),QCString(),false);
if (!Config_getBool(HTML_DYNAMIC_MENUS)) // for dynamic menus, menu.js creates this part
{
t << " <input type=\"text\" id=\"MSearchField\" name=\"query\" value=\"\" placeholder=\"" << theTranslator->trSearch() <<
Expand Down
2 changes: 1 addition & 1 deletion src/htmlgen.h
Expand Up @@ -224,7 +224,7 @@ class HtmlGenerator : public OutputGenerator
void writeSplitBar(const QCString &name);
void writeNavigationPath(const QCString &s);
void writeLogo();
void writeQuickLinks(bool compact,HighlightedItem hli,const QCString &file);
void writeQuickLinks(bool compact,HighlightedItem hli,const QCString &file,bool needsFolding);
void writeSummaryLink(const QCString &file,const QCString &anchor,const QCString &title,bool first);
void startContents();
void endContents();
Expand Down
14 changes: 7 additions & 7 deletions src/index.cpp
Expand Up @@ -356,14 +356,14 @@ void endTitle(OutputList &ol,const QCString &fileName,const QCString &name)

void startFile(OutputList &ol,const QCString &name,const QCString &manName,
const QCString &title,HighlightedItem hli,bool additionalIndices,
const QCString &altSidebarName, int hierarchyLevel)
const QCString &altSidebarName, int hierarchyLevel,bool needsFolding)
{
bool disableIndex = Config_getBool(DISABLE_INDEX);
ol.startFile(name,manName,title,hierarchyLevel);
ol.startQuickIndices();
if (!disableIndex)
{
ol.writeQuickLinks(TRUE,hli,name);
ol.writeQuickLinks(TRUE,hli,name,needsFolding);
}
if (!additionalIndices)
{
Expand Down Expand Up @@ -3011,7 +3011,7 @@ static void writeClassMemberIndexFiltered(OutputList &ol, ClassMemberHighlight::
ol.startQuickIndices();
if (!disableIndex)
{
ol.writeQuickLinks(TRUE,HighlightedItem::Functions,QCString());
ol.writeQuickLinks(true,HighlightedItem::Functions,QCString(),false);

if (!Config_getBool(HTML_DYNAMIC_MENUS))
{
Expand Down Expand Up @@ -3180,7 +3180,7 @@ static void writeFileMemberIndexFiltered(OutputList &ol, FileMemberHighlight::En
ol.startQuickIndices();
if (!disableIndex)
{
ol.writeQuickLinks(TRUE,HighlightedItem::Globals,QCString());
ol.writeQuickLinks(true,HighlightedItem::Globals,QCString(),false);
if (!Config_getBool(HTML_DYNAMIC_MENUS))
{
startQuickIndexList(ol);
Expand Down Expand Up @@ -3345,7 +3345,7 @@ static void writeNamespaceMemberIndexFiltered(OutputList &ol,
ol.startQuickIndices();
if (!disableIndex)
{
ol.writeQuickLinks(TRUE,HighlightedItem::NamespaceMembers,QCString());
ol.writeQuickLinks(true,HighlightedItem::NamespaceMembers,QCString(),false);
if (!Config_getBool(HTML_DYNAMIC_MENUS))
{
startQuickIndexList(ol);
Expand Down Expand Up @@ -4340,7 +4340,7 @@ static void writeIndex(OutputList &ol)
ol.startQuickIndices();
if (!Config_getBool(DISABLE_INDEX))
{
ol.writeQuickLinks(TRUE,HighlightedItem::Main,QCString());
ol.writeQuickLinks(true,HighlightedItem::Main,QCString(),false);
}
ol.endQuickIndices();
ol.writeSplitBar(indexName);
Expand Down Expand Up @@ -4389,7 +4389,7 @@ static void writeIndex(OutputList &ol)
ol.startContents();
if (Config_getBool(DISABLE_INDEX) && Doxygen::mainPage==0)
{
ol.writeQuickLinks(FALSE,HighlightedItem::Main,QCString());
ol.writeQuickLinks(false,HighlightedItem::Main,QCString(),false);
}

if (Doxygen::mainPage)
Expand Down
2 changes: 1 addition & 1 deletion src/index.h
Expand Up @@ -200,7 +200,7 @@ void startTitle(OutputList &ol,const QCString &fileName,const DefinitionMutable
void endTitle(OutputList &ol,const QCString &fileName,const QCString &name);
void startFile(OutputList &ol,const QCString &name,const QCString &manName,
const QCString &title,HighlightedItem hli=HighlightedItem::None,
bool additionalIndices=FALSE,const QCString &altSidebarName=QCString(), int hierarchyLevel=0);
bool additionalIndices=FALSE,const QCString &altSidebarName=QCString(), int hierarchyLevel=0, bool needsFolding=false);
void endFile(OutputList &ol,bool skipNavIndex=FALSE,bool skipEndContents=FALSE,
const QCString &navPath=QCString());
void endFileWithNavPath(OutputList &ol,const Definition *d);
Expand Down
2 changes: 1 addition & 1 deletion src/latexgen.h
Expand Up @@ -226,7 +226,7 @@ class LatexGenerator : public OutputGenerator
void writeSplitBar(const QCString &) {}
void writeNavigationPath(const QCString &) {}
void writeLogo() {}
void writeQuickLinks(bool,HighlightedItem,const QCString &) {}
void writeQuickLinks(bool,HighlightedItem,const QCString &,bool) {}
void writeSummaryLink(const QCString &,const QCString &,const QCString &,bool) {}
void startContents() {}
void endContents() {}
Expand Down
2 changes: 1 addition & 1 deletion src/mangen.h
Expand Up @@ -196,7 +196,7 @@ class ManGenerator : public OutputGenerator
void writeSplitBar(const QCString &) {}
void writeNavigationPath(const QCString &) {}
void writeLogo() {}
void writeQuickLinks(bool,HighlightedItem,const QCString &) {}
void writeQuickLinks(bool,HighlightedItem,const QCString &,bool) {}
void writeSummaryLink(const QCString &,const QCString &,const QCString &,bool) {}
void startContents() {}
void endContents() {}
Expand Down
4 changes: 2 additions & 2 deletions src/outputlist.h
Expand Up @@ -752,8 +752,8 @@ class OutputList
{ foreach<OutputGenIntf::writeNavigationPath>(s); }
void writeLogo()
{ foreach<OutputGenIntf::writeLogo>(); }
void writeQuickLinks(bool compact,HighlightedItem hli,const QCString &file)
{ foreach<OutputGenIntf::writeQuickLinks>(compact,hli,file); }
void writeQuickLinks(bool compact,HighlightedItem hli,const QCString &file,bool needsFolding)
{ foreach<OutputGenIntf::writeQuickLinks>(compact,hli,file,needsFolding); }
void writeSummaryLink(const QCString &file,const QCString &anchor,const QCString &title,bool first)
{ foreach<OutputGenIntf::writeSummaryLink>(file,anchor,title,first); }
void startContents()
Expand Down
2 changes: 1 addition & 1 deletion src/rtfgen.h
Expand Up @@ -206,7 +206,7 @@ class RTFGenerator : public OutputGenerator
void writeSplitBar(const QCString &) {}
void writeNavigationPath(const QCString &) {}
void writeLogo() {}
void writeQuickLinks(bool,HighlightedItem,const QCString &) {}
void writeQuickLinks(bool,HighlightedItem,const QCString &,bool) {}
void writeSummaryLink(const QCString &,const QCString &,const QCString &,bool) {}
void startContents() {}
void endContents() {}
Expand Down

0 comments on commit 13c194c

Please sign in to comment.