Doxygen
Loading...
Searching...
No Matches
htmlgen.cpp File Reference
#include <stdlib.h>
#include <assert.h>
#include <mutex>
#include "message.h"
#include "htmlgen.h"
#include "config.h"
#include "util.h"
#include "doxygen.h"
#include "diagram.h"
#include "version.h"
#include "dot.h"
#include "dotcallgraph.h"
#include "dotclassgraph.h"
#include "dotdirdeps.h"
#include "dotgfxhierarchytable.h"
#include "dotgroupcollaboration.h"
#include "dotincldepgraph.h"
#include "language.h"
#include "htmlhelp.h"
#include "docparser.h"
#include "docnode.h"
#include "htmldocvisitor.h"
#include "searchindex.h"
#include "pagedef.h"
#include "debug.h"
#include "dirdef.h"
#include "vhdldocgen.h"
#include "layout.h"
#include "image.h"
#include "ftvhelp.h"
#include "resourcemgr.h"
#include "tooltip.h"
#include "growbuf.h"
#include "fileinfo.h"
#include "dir.h"
#include "utf8.h"
#include "textstream.h"
#include "indexlist.h"
#include "datetime.h"
#include "portable.h"
#include "outputlist.h"
#include "stringutil.h"
Include dependency graph for htmlgen.cpp:

Go to the source code of this file.

Macros

#define DBG_HTML(x)

Functions

static void writeClientSearchBox (TextStream &t, const QCString &relPath)
static void writeServerSearchBox (TextStream &t, const QCString &relPath, bool highlightSearch)
static QCString getConvertLatexMacro ()
 Convert a set of LaTeX commands \(re)newcommand to a form readable by MathJax LaTeX syntax:
static QCString getSearchBox (bool serverSide, QCString relPath, bool highlightSearch)
static QCString substituteHtmlKeywords (const QCString &file, const QCString &str, const QCString &title, const QCString &relPath, const QCString &navPath=QCString())
static void fillColorStyleMap (const QCString &definitions, StringUnorderedMap &map)
static void fillColorStyleMaps ()
static QCString replaceVariables (const QCString &input)
static bool hasDateReplacement (const QCString &str)
static void writeDefaultStyleSheet (TextStream &t)
static void startSectionHeader (TextStream &t, const QCString &relPath, int sectionCount)
static void endSectionHeader (TextStream &t)
static void startSectionSummary (TextStream &t, int sectionCount)
static void endSectionSummary (TextStream &t)
static void startSectionContent (TextStream &t, int sectionCount)
static void endSectionContent (TextStream &t)
static void startQuickIndexList (TextStream &t, bool topLevel=TRUE)
static void endQuickIndexList (TextStream &t)
static void startQuickIndexItem (TextStream &t, const QCString &l, bool hl, bool, const QCString &relPath)
static void endQuickIndexItem (TextStream &t, const QCString &l)
static bool quickLinkVisible (LayoutNavEntry::Kind kind)
static void renderQuickLinksAsTree (TextStream &t, const QCString &relPath, LayoutNavEntry *root)
static void renderQuickLinksAsTabs (TextStream &t, const QCString &relPath, LayoutNavEntry *hlEntry, LayoutNavEntry::Kind kind, bool highlightParent, bool highlightSearch)
static void writeDefaultQuickLinks (TextStream &t, HighlightedItem hli, const QCString &file, const QCString &relPath, bool extraTabs)

Variables

static QCString g_header
static QCString g_header_file
static QCString g_footer_file
static QCString g_footer
static QCString g_mathjax_code
static QCString g_latex_macro
static bool g_build_date = false
static constexpr auto hex ="0123456789ABCDEF"
static const SelectionMarkerInfo htmlMarkerInfo = { '<', "<!--BEGIN ",10,"<!--END ",8,"-->",3 }
static StringUnorderedMap g_lightMap
static StringUnorderedMap g_darkMap
static std::mutex g_indexLock

Macro Definition Documentation

◆ DBG_HTML

#define DBG_HTML ( x)

Definition at line 62 of file htmlgen.cpp.

Referenced by HtmlGenerator::endIndent(), HtmlGenerator::endInlineMemberDoc(), HtmlGenerator::endInlineMemberName(), HtmlGenerator::endInlineMemberType(), HtmlGenerator::endLabels(), HtmlGenerator::endMemberDescription(), HtmlGenerator::endMemberDoc(), HtmlGenerator::endMemberDocList(), HtmlGenerator::endMemberDocName(), HtmlGenerator::endMemberDocPrefixItem(), HtmlGenerator::endMemberDocSimple(), HtmlGenerator::endMemberHeader(), HtmlGenerator::endMemberList(), HtmlGenerator::endMemberSections(), HtmlGenerator::endMemberSubtitle(), HtmlGenerator::endParameterExtra(), HtmlGenerator::endParameterList(), HtmlGenerator::endParameterName(), HtmlGenerator::endParameterType(), HtmlGenerator::exceptionEntry(), HtmlGenerator::insertMemberAlign(), HtmlGenerator::startIndent(), HtmlGenerator::startInlineMemberDoc(), HtmlGenerator::startInlineMemberName(), HtmlGenerator::startInlineMemberType(), HtmlGenerator::startLabels(), HtmlGenerator::startMemberDescription(), HtmlGenerator::startMemberDoc(), HtmlGenerator::startMemberDocList(), HtmlGenerator::startMemberDocName(), HtmlGenerator::startMemberDocPrefixItem(), HtmlGenerator::startMemberDocSimple(), HtmlGenerator::startMemberHeader(), HtmlGenerator::startMemberItem(), HtmlGenerator::startMemberList(), HtmlGenerator::startMemberSections(), HtmlGenerator::startMemberSubtitle(), HtmlGenerator::startParameterExtra(), HtmlGenerator::startParameterList(), HtmlGenerator::startParameterName(), HtmlGenerator::startParameterType(), HtmlGenerator::writeInheritedSectionTitle(), and HtmlGenerator::writeLabel().

Function Documentation

◆ endQuickIndexItem()

void endQuickIndexItem ( TextStream & t,
const QCString & l )
static

Definition at line 2736 of file htmlgen.cpp.

2737{
2738 t << "</span>";
2739 if (!l.isEmpty()) t << "</a>";
2740 t << "</li>\n";
2741}
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150

References QCString::isEmpty().

Referenced by renderQuickLinksAsTabs().

◆ endQuickIndexList()

void endQuickIndexList ( TextStream & t)
static

Definition at line 2709 of file htmlgen.cpp.

2710{
2711 if (!Config_getBool(DISABLE_INDEX))
2712 {
2713 t << " </ul>\n";
2714 t << " </div>\n";
2715 }
2716 else
2717 {
2718 t << "</ul>\n";
2719 }
2720}
#define Config_getBool(name)
Definition config.h:33

References Config_getBool.

Referenced by renderQuickLinksAsTabs(), and renderQuickLinksAsTree().

◆ endSectionContent()

void endSectionContent ( TextStream & t)
static

Definition at line 2019 of file htmlgen.cpp.

2020{
2021 //t << "<!-- endSectionContent -->";
2022 t << "</div>\n";
2023}

Referenced by HtmlGenerator::endCallGraph(), HtmlGenerator::endClassDiagram(), HtmlGenerator::endDirDepGraph(), HtmlGenerator::endDotGraph(), HtmlGenerator::endGroupCollaboration(), and HtmlGenerator::endInclDepGraph().

◆ endSectionHeader()

void endSectionHeader ( TextStream & t)
static

◆ endSectionSummary()

void endSectionSummary ( TextStream & t)
static

Definition at line 1993 of file htmlgen.cpp.

1994{
1995 //t << "<!-- endSectionSummary -->";
1996 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
1997 if (dynamicSections)
1998 {
1999 t << "</div>\n";
2000 }
2001}

References Config_getBool.

Referenced by HtmlGenerator::endCallGraph(), HtmlGenerator::endClassDiagram(), HtmlGenerator::endDirDepGraph(), HtmlGenerator::endDotGraph(), HtmlGenerator::endGroupCollaboration(), and HtmlGenerator::endInclDepGraph().

◆ fillColorStyleMap()

void fillColorStyleMap ( const QCString & definitions,
StringUnorderedMap & map )
static

Definition at line 632 of file htmlgen.cpp.

633{
634 int p=0,i=0;
635 while ((i=definitions.find('\n',p))!=-1)
636 {
637 QCString line = definitions.mid(p,i-p);
638 if (line.startsWith("--"))
639 {
640 int separator = line.find(':');
641 assert(separator!=-1);
642 std::string key = line.left(separator).str();
643 int semi = line.findRev(';');
644 assert(semi!=-1);
645 std::string value = line.mid(separator+1,semi-separator-1).stripWhiteSpace().str();
646 map.emplace(key,value);
647 //printf("var(%s)=%s\n",qPrint(key),qPrint(value));
648 }
649 p=i+1;
650 }
651}
This is an alternative implementation of QCString.
Definition qcstring.h:101
int find(char c, int index=0, bool cs=TRUE) const
Definition qcstring.cpp:43
bool startsWith(const char *s) const
Definition qcstring.h:492
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:226
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:245
const std::string & str() const
Definition qcstring.h:537
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:91
QCString left(size_t len) const
Definition qcstring.h:214

References QCString::find(), QCString::findRev(), QCString::left(), QCString::mid(), QCString::startsWith(), QCString::str(), and QCString::stripWhiteSpace().

Referenced by fillColorStyleMaps().

◆ fillColorStyleMaps()

void fillColorStyleMaps ( )
static

Definition at line 653 of file htmlgen.cpp.

654{
656 auto colorStyle = Config_getEnum(HTML_COLORSTYLE);
657 if (colorStyle==HTML_COLORSTYLE_t::LIGHT)
658 {
659 fillColorStyleMap(replaceColorMarkers(mgr.getAsString("lightmode_settings.css")),g_lightMap);
660 }
661 else if (colorStyle==HTML_COLORSTYLE_t::DARK)
662 {
663 fillColorStyleMap(replaceColorMarkers(mgr.getAsString("darkmode_settings.css")),g_darkMap);
664 }
665}
Singleton for managing resources compiled into an executable.
Definition resourcemgr.h:37
static ResourceMgr & instance()
Returns the one and only instance of this class.
QCString getAsString(const QCString &name) const
Gets the resource data as a C string.
#define Config_getEnum(name)
Definition config.h:35
static void fillColorStyleMap(const QCString &definitions, StringUnorderedMap &map)
Definition htmlgen.cpp:632
static StringUnorderedMap g_lightMap
Definition htmlgen.cpp:629
static StringUnorderedMap g_darkMap
Definition htmlgen.cpp:630
QCString replaceColorMarkers(const QCString &str)
Replaces any markers of the form ##AA in input string str by new markers of the form #AABBCC,...
Definition util.cpp:6319

References Config_getEnum, fillColorStyleMap(), g_darkMap, g_lightMap, ResourceMgr::getAsString(), ResourceMgr::instance(), and replaceColorMarkers().

Referenced by HtmlGenerator::init(), and HtmlGenerator::writeStyleSheetFile().

◆ getConvertLatexMacro()

QCString getConvertLatexMacro ( )
static

Convert a set of LaTeX commands \(re)newcommand to a form readable by MathJax LaTeX syntax:

\newcommand{\cmd}{replacement}
or
\renewcommand{\cmd}{replacement}

MathJax syntax:

cmd: "{replacement}"

LaTeX syntax:

\newcommand{\cmd}[nr]{replacement}
or
\renewcommand{\cmd}[nr]{replacement}

MathJax syntax:

cmd: ["{replacement}",nr]

Definition at line 150 of file htmlgen.cpp.

151{
152 QCString macrofile = Config_getString(FORMULA_MACROFILE);
153 if (macrofile.isEmpty()) return "";
154 QCString s = fileToString(macrofile);
155 macrofile = FileInfo(macrofile.str()).absFilePath();
156 size_t size = s.length();
157 GrowBuf out(size);
158 const char *data = s.data();
159 int line = 1;
160 int cnt = 0;
161 size_t i = 0;
162 QCString nr;
163 while (i < size)
164 {
165 nr = "";
166 // skip initial white space, but count lines
167 while (i < size && (data[i] == ' ' || data[i] == '\t' || data[i] == '\n'))
168 {
169 if (data[i] == '\n') line++;
170 i++;
171 }
172 if (i >= size) break;
173 // check for \newcommand or \renewcommand
174 if (data[i] != '\\')
175 {
176 warn(macrofile,line, "file contains non valid code, expected '\\' got '{:c}'",data[i]);
177 return "";
178 }
179 i++;
180 if (literal_at(data+i,"newcommand"))
181 {
182 i += strlen("newcommand");
183 }
184 else if (literal_at(data+i,"renewcommand"))
185 {
186 i += strlen("renewcommand");
187 }
188 else
189 {
190 warn(macrofile,line, "file contains non valid code, expected 'newcommand' or 'renewcommand'");
191 return "";
192 }
193 // handle {cmd}
194 if (data[i] != '{')
195 {
196 warn(macrofile,line, "file contains non valid code, expected '{{' got '{:c}'",data[i]);
197 return "";
198 }
199 i++;
200 if (data[i] != '\\')
201 {
202 warn(macrofile,line, "file contains non valid code, expected '\\' got '{:c}'",data[i]);
203 return "";
204 }
205 i++;
206 // run till }, i.e. cmd
207 out.addStr(" ");
208 while (i < size && (data[i] != '}')) out.addChar(data[i++]);
209 if (i >= size)
210 {
211 warn(macrofile,line, "file contains non valid code, no closing '}}' for command");
212 return "";
213 }
214 out.addChar(':');
215 out.addChar(' ');
216 i++;
217
218 if (data[i] == '[')
219 {
220 // handle [nr]
221 // run till ]
222 out.addChar('[');
223 i++;
224 while (i < size && (data[i] != ']')) nr += data[i++];
225 if (i >= size)
226 {
227 warn(macrofile,line, "file contains non valid code, no closing ']'");
228 return "";
229 }
230 i++;
231 }
232 else if (data[i] != '{')
233 {
234 warn(macrofile,line, "file contains non valid code, expected '[' or '{{' got '{:c}'",data[i]);
235 return "";
236 }
237 // handle {replacement}
238 // retest as the '[' part might have advanced so we can have a new '{'
239 if (data[i] != '{')
240 {
241 warn(macrofile,line, "file contains non valid code, expected '{{' got '{:c}'",data[i]);
242 return "";
243 }
244 out.addChar('"');
245 out.addChar('{');
246 i++;
247 // run till }
248 cnt = 1;
249 while (i < size && cnt)
250 {
251 switch(data[i])
252 {
253 case '\\':
254 out.addChar('\\'); // need to escape it for MathJax js code
255 out.addChar('\\');
256 i++;
257 if (data[i] == '\\') // we have an escaped backslash
258 {
259 out.addChar('\\');
260 out.addChar('\\');
261 i++;
262 }
263 else if (data[i] != '"') out.addChar(data[i++]); // double quote handled separately
264 break;
265 case '{':
266 cnt++;
267 out.addChar(data[i++]);
268 break;
269 case '}':
270 cnt--;
271 if (cnt) out.addChar(data[i]);
272 i++;
273 break;
274 case '"':
275 out.addChar('\\'); // need to escape it for MathJax js code
276 out.addChar(data[i++]);
277 break;
278 case '\n':
279 line++;
280 out.addChar(data[i++]);
281 break;
282 default:
283 out.addChar(data[i++]);
284 break;
285 }
286 }
287 if (i > size)
288 {
289 warn(macrofile,line, "file contains non valid code, no closing '}}' for replacement");
290 return "";
291 }
292 out.addChar('}');
293 out.addChar('"');
294 if (!nr.isEmpty())
295 {
296 out.addChar(',');
297 out.addStr(nr);
298 }
299 if (!nr.isEmpty())
300 {
301 out.addChar(']');
302 }
303 out.addChar(',');
304 out.addChar('\n');
305 }
306 out.addChar(0);
307 return out.get();
308}
Minimal replacement for QFileInfo.
Definition fileinfo.h:23
std::string absFilePath() const
Definition fileinfo.cpp:101
Class representing a string buffer optimized for growing.
Definition growbuf.h:28
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
#define Config_getString(name)
Definition config.h:32
#define warn(file, line, fmt,...)
Definition message.h:97
bool literal_at(const char *data, const char(&str)[N])
returns TRUE iff data points to a substring that matches string literal str
Definition stringutil.h:98
QCString fileToString(const QCString &name, bool filter, bool isSourceCode)
Definition util.cpp:1442

References FileInfo::absFilePath(), GrowBuf::addChar(), GrowBuf::addStr(), Config_getString, QCString::data(), fileToString(), GrowBuf::get(), QCString::isEmpty(), QCString::length(), literal_at(), QCString::str(), and warn.

Referenced by HtmlGenerator::getMathJaxMacros(), and HtmlGenerator::init().

◆ getSearchBox()

QCString getSearchBox ( bool serverSide,
QCString relPath,
bool highlightSearch )
static

Definition at line 310 of file htmlgen.cpp.

311{
312 TextStream t;
313 if (serverSide)
314 {
315 writeServerSearchBox(t, relPath, highlightSearch);
316 }
317 else
318 {
319 writeClientSearchBox(t, relPath);
320 }
321 return t.str();
322}
Text streaming class that buffers data.
Definition textstream.h:36
std::string str() const
Return the contents of the buffer as a std::string object.
Definition textstream.h:229
static void writeServerSearchBox(TextStream &t, const QCString &relPath, bool highlightSearch)
Definition htmlgen.cpp:99
static void writeClientSearchBox(TextStream &t, const QCString &relPath)
Definition htmlgen.cpp:77

References TextStream::str(), writeClientSearchBox(), and writeServerSearchBox().

Referenced by substituteHtmlKeywords().

◆ hasDateReplacement()

bool hasDateReplacement ( const QCString & str)
static

Definition at line 1151 of file htmlgen.cpp.

1152{
1153 return (str.contains("$datetime",false) ||
1154 str.contains("$date",false) ||
1155 str.contains("$time",false) ||
1156 str.contains("$year",false)
1157 );
1158}
int contains(char c, bool cs=TRUE) const
Definition qcstring.cpp:143

References QCString::contains().

Referenced by HtmlGenerator::init().

◆ quickLinkVisible()

bool quickLinkVisible ( LayoutNavEntry::Kind kind)
static

Definition at line 2743 of file htmlgen.cpp.

2744{
2745 const auto &index = Index::instance();
2746 bool showNamespaces = Config_getBool(SHOW_NAMESPACES);
2747 bool showFiles = Config_getBool(SHOW_FILES);
2748 switch (kind)
2749 {
2750 case LayoutNavEntry::MainPage: return TRUE;
2751 case LayoutNavEntry::User: return TRUE;
2752 case LayoutNavEntry::UserGroup: return TRUE;
2753 case LayoutNavEntry::Pages: return index.numIndexedPages()>0;
2754 case LayoutNavEntry::Topics: return index.numDocumentedGroups()>0;
2755 case LayoutNavEntry::Modules: return index.numDocumentedModules()>0;
2756 case LayoutNavEntry::ModuleList: return index.numDocumentedModules()>0;
2757 case LayoutNavEntry::ModuleMembers: return index.numDocumentedModuleMembers(ModuleMemberHighlight::All)>0;
2758 case LayoutNavEntry::Namespaces: return showNamespaces && index.numDocumentedNamespaces()>0;
2759 case LayoutNavEntry::NamespaceList: return showNamespaces && index.numDocumentedNamespaces()>0;
2760 case LayoutNavEntry::NamespaceMembers: return showNamespaces && index.numDocumentedNamespaceMembers(NamespaceMemberHighlight::All)>0;
2761 case LayoutNavEntry::Concepts: return index.numDocumentedConcepts()>0;
2762 case LayoutNavEntry::Classes: return index.numAnnotatedClasses()>0;
2763 case LayoutNavEntry::ClassList: return index.numAnnotatedClasses()>0;
2764 case LayoutNavEntry::ClassIndex: return index.numAnnotatedClasses()>0;
2765 case LayoutNavEntry::ClassHierarchy: return index.numHierarchyClasses()>0;
2766 case LayoutNavEntry::ClassMembers: return index.numDocumentedClassMembers(ClassMemberHighlight::All)>0;
2767 case LayoutNavEntry::Files: return showFiles && index.numDocumentedFiles()>0;
2768 case LayoutNavEntry::FileList: return showFiles && index.numDocumentedFiles()>0;
2769 case LayoutNavEntry::FileGlobals: return showFiles && index.numDocumentedFileMembers(FileMemberHighlight::All)>0;
2770 case LayoutNavEntry::Examples: return !Doxygen::exampleLinkedMap->empty();
2771 case LayoutNavEntry::Interfaces: return index.numAnnotatedInterfaces()>0;
2772 case LayoutNavEntry::InterfaceList: return index.numAnnotatedInterfaces()>0;
2773 case LayoutNavEntry::InterfaceIndex: return index.numAnnotatedInterfaces()>0;
2774 case LayoutNavEntry::InterfaceHierarchy: return index.numHierarchyInterfaces()>0;
2775 case LayoutNavEntry::Structs: return index.numAnnotatedStructs()>0;
2776 case LayoutNavEntry::StructList: return index.numAnnotatedStructs()>0;
2777 case LayoutNavEntry::StructIndex: return index.numAnnotatedStructs()>0;
2778 case LayoutNavEntry::Exceptions: return index.numAnnotatedExceptions()>0;
2779 case LayoutNavEntry::ExceptionList: return index.numAnnotatedExceptions()>0;
2780 case LayoutNavEntry::ExceptionIndex: return index.numAnnotatedExceptions()>0;
2781 case LayoutNavEntry::ExceptionHierarchy: return index.numHierarchyExceptions()>0;
2782 case LayoutNavEntry::None: // should never happen, means not properly initialized
2783 assert(kind != LayoutNavEntry::None);
2784 return FALSE;
2785 }
2786 return FALSE;
2787}
static PageLinkedMap * exampleLinkedMap
Definition doxygen.h:99
static Index & instance()
Definition index.cpp:106
#define TRUE
Definition qcstring.h:37
#define FALSE
Definition qcstring.h:34

References ClassMemberHighlight::All, FileMemberHighlight::All, ModuleMemberHighlight::All, NamespaceMemberHighlight::All, Config_getBool, Doxygen::exampleLinkedMap, FALSE, Index::instance(), and TRUE.

Referenced by renderQuickLinksAsJs(), renderQuickLinksAsTabs(), and renderQuickLinksAsTree().

◆ renderQuickLinksAsTabs()

void renderQuickLinksAsTabs ( TextStream & t,
const QCString & relPath,
LayoutNavEntry * hlEntry,
LayoutNavEntry::Kind kind,
bool highlightParent,
bool highlightSearch )
static

Definition at line 2818 of file htmlgen.cpp.

2821{
2822 if (hlEntry->parent()) // first draw the tabs for the parent of hlEntry
2823 {
2824 renderQuickLinksAsTabs(t,relPath,hlEntry->parent(),kind,highlightParent,highlightSearch);
2825 }
2826 if (hlEntry->parent() && !hlEntry->parent()->children().empty()) // draw tabs for row containing hlEntry
2827 {
2828 bool topLevel = hlEntry->parent()->parent()==nullptr;
2829 int count=0;
2830 for (const auto &entry : hlEntry->parent()->children())
2831 {
2832 if (entry->visible() && quickLinkVisible(entry->kind())) count++;
2833 }
2834 if (count>0) // at least one item is visible
2835 {
2836 startQuickIndexList(t,topLevel);
2837 for (const auto &entry : hlEntry->parent()->children())
2838 {
2839 if (entry->visible() && quickLinkVisible(entry->kind()))
2840 {
2841 QCString url = entry->url();
2842 startQuickIndexItem(t,url,
2843 entry.get()==hlEntry &&
2844 (!entry->children().empty() ||
2845 (entry->kind()==kind && !highlightParent)
2846 ),
2847 TRUE,relPath);
2848 t << fixSpaces(entry->title());
2849 endQuickIndexItem(t,url);
2850 }
2851 }
2852 if (hlEntry->parent()==LayoutDocManager::instance().rootNavEntry()) // first row is special as it contains the search box
2853 {
2854 bool searchEngine = Config_getBool(SEARCHENGINE);
2855 bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
2856 bool disableIndex = Config_getBool(DISABLE_INDEX);
2857 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
2858 bool fullSidebar = Config_getBool(FULL_SIDEBAR);
2859 // case where DISABLE_INDEX=NO & GENERATE_TREEVIEW=YES & FULL_SIDEBAR=YES has search box in the side panel
2860 if (searchEngine)
2861 {
2862 t << " <li>\n";
2863 if (disableIndex || !generateTreeView || !fullSidebar)
2864 {
2865 if (!serverBasedSearch) // pure client side search
2866 {
2867 writeClientSearchBox(t,relPath);
2868 t << " </li>\n";
2869 }
2870 else // server based search
2871 {
2872 writeServerSearchBox(t,relPath,highlightSearch);
2873 if (!highlightSearch)
2874 {
2875 t << " </li>\n";
2876 }
2877 }
2878 }
2879 else
2880 {
2881 t << " </li>\n";
2882 }
2883 }
2884 if (!highlightSearch || Config_getBool(FULL_SIDEBAR))
2885 // on the search page the index will be ended by the page itself if the search box is part of the navigation bar
2886 {
2888 }
2889 }
2890 else // normal case for other rows than first one
2891 {
2893 }
2894 }
2895 }
2896}
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition layout.cpp:1435
static void endQuickIndexList(TextStream &t)
Definition htmlgen.cpp:2709
static void startQuickIndexList(TextStream &t, bool topLevel=TRUE)
Definition htmlgen.cpp:2689
static void startQuickIndexItem(TextStream &t, const QCString &l, bool hl, bool, const QCString &relPath)
Definition htmlgen.cpp:2722
static void renderQuickLinksAsTabs(TextStream &t, const QCString &relPath, LayoutNavEntry *hlEntry, LayoutNavEntry::Kind kind, bool highlightParent, bool highlightSearch)
Definition htmlgen.cpp:2818
static void endQuickIndexItem(TextStream &t, const QCString &l)
Definition htmlgen.cpp:2736
static bool quickLinkVisible(LayoutNavEntry::Kind kind)
Definition htmlgen.cpp:2743
const LayoutNavEntryList & children() const
Definition layout.h:219
LayoutNavEntry * parent() const
Definition layout.h:212
QCString fixSpaces(const QCString &s)
Definition util.h:472

References LayoutNavEntry::children(), Config_getBool, endQuickIndexItem(), endQuickIndexList(), fixSpaces(), LayoutDocManager::instance(), LayoutNavEntry::parent(), quickLinkVisible(), renderQuickLinksAsTabs(), startQuickIndexItem(), startQuickIndexList(), TRUE, writeClientSearchBox(), and writeServerSearchBox().

Referenced by renderQuickLinksAsTabs(), and writeDefaultQuickLinks().

◆ renderQuickLinksAsTree()

void renderQuickLinksAsTree ( TextStream & t,
const QCString & relPath,
LayoutNavEntry * root )
static

Definition at line 2789 of file htmlgen.cpp.

2791{
2792 int count=0;
2793 for (const auto &entry : root->children())
2794 {
2795 if (entry->visible() && quickLinkVisible(entry->kind())) count++;
2796 }
2797 if (count>0) // at least one item is visible
2798 {
2800 for (const auto &entry : root->children())
2801 {
2802 if (entry->visible() && quickLinkVisible(entry->kind()))
2803 {
2804 QCString url = entry->url();
2805 t << "<li><a href=\"" << relPath << url << "\"><span>";
2806 t << fixSpaces(entry->title());
2807 t << "</span></a>\n";
2808 // recursive into child list
2809 renderQuickLinksAsTree(t,relPath,entry.get());
2810 t << "</li>";
2811 }
2812 }
2814 }
2815}
static void renderQuickLinksAsTree(TextStream &t, const QCString &relPath, LayoutNavEntry *root)
Definition htmlgen.cpp:2789

References LayoutNavEntry::children(), endQuickIndexList(), fixSpaces(), quickLinkVisible(), renderQuickLinksAsTree(), and startQuickIndexList().

Referenced by renderQuickLinksAsTree(), and writeDefaultQuickLinks().

◆ replaceVariables()

QCString replaceVariables ( const QCString & input)
static

Definition at line 667 of file htmlgen.cpp.

668{
669 auto doReplacements = [&input](const StringUnorderedMap &mapping) -> QCString
670 {
671 GrowBuf output;
672 int p=0,i=0;
673 while ((i=input.find("var(",p))!=-1)
674 {
675 output.addStr(input.data()+p,i-p);
676 int j=input.find(")",i+4);
677 assert(j!=-1);
678 auto it = mapping.find(input.mid(i+4,j-i-4).str()); // find variable
679 if (it==mapping.end())
680 { // should be found
681 err("failed to find value variable {}. It is not longer defined in doxygen.css\n",input.mid(i+4,j-i-4));
682 }
683 else
684 {
685 //printf("replace '%s' by '%s'\n",qPrint(input.mid(i+4,j-i-4)),qPrint(it->second));
686 output.addStr(it->second); // add it value
687 }
688 p=j+1;
689 }
690 output.addStr(input.data()+p,input.length()-p);
691 output.addChar(0);
692 return output.get();
693 };
694
695 auto colorStyle = Config_getEnum(HTML_COLORSTYLE);
696 if (colorStyle==HTML_COLORSTYLE_t::LIGHT)
697 {
698 return doReplacements(g_lightMap);
699 }
700 else if (colorStyle==HTML_COLORSTYLE_t::DARK)
701 {
702 return doReplacements(g_darkMap);
703 }
704 else
705 {
706 return input;
707 }
708}
void addChar(char c)
Definition growbuf.h:69
void addStr(const QCString &s)
Definition growbuf.h:72
char * get()
Definition growbuf.h:114
std::unordered_map< std::string, std::string > StringUnorderedMap
Definition containers.h:28
#define err(fmt,...)
Definition message.h:127

References GrowBuf::addChar(), GrowBuf::addStr(), Config_getEnum, QCString::data(), err, QCString::find(), g_darkMap, g_lightMap, GrowBuf::get(), QCString::length(), QCString::mid(), and QCString::str().

Referenced by HtmlGenerator::getNavTreeCss(), HtmlGenerator::init(), writeDefaultStyleSheet(), and HtmlGenerator::writeSearchData().

◆ startQuickIndexItem()

void startQuickIndexItem ( TextStream & t,
const QCString & l,
bool hl,
bool ,
const QCString & relPath )
static

Definition at line 2722 of file htmlgen.cpp.

2725{
2726 t << " <li";
2727 if (hl)
2728 {
2729 t << " class=\"current\"";
2730 }
2731 t << ">";
2732 if (!l.isEmpty()) t << "<a href=\"" << correctURL(l,relPath) << "\">";
2733 t << "<span>";
2734}
QCString correctURL(const QCString &url, const QCString &relPath)
Corrects URL url according to the relative path relPath.
Definition util.cpp:6438

References correctURL(), and QCString::isEmpty().

Referenced by renderQuickLinksAsTabs().

◆ startQuickIndexList()

void startQuickIndexList ( TextStream & t,
bool topLevel = TRUE )
static

Definition at line 2689 of file htmlgen.cpp.

2690{
2691 if (!Config_getBool(DISABLE_INDEX))
2692 {
2693 if (topLevel)
2694 {
2695 t << " <div id=\"navrow1\" class=\"tabs\">\n";
2696 }
2697 else
2698 {
2699 t << " <div id=\"navrow2\" class=\"tabs2\">\n";
2700 }
2701 t << " <ul class=\"tablist\">\n";
2702 }
2703 else
2704 {
2705 t << "<ul>";
2706 }
2707}

References Config_getBool, and TRUE.

Referenced by renderQuickLinksAsTabs(), and renderQuickLinksAsTree().

◆ startSectionContent()

void startSectionContent ( TextStream & t,
int sectionCount )
static

Definition at line 2003 of file htmlgen.cpp.

2004{
2005 //t << "<!-- startSectionContent -->";
2006 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
2007 if (dynamicSections)
2008 {
2009 t << "<div id=\"dynsection-" << sectionCount << "-content\" "
2010 "class=\"dyncontent\" "
2011 "style=\"display:none;\">\n";
2012 }
2013 else
2014 {
2015 t << "<div class=\"dyncontent\">\n";
2016 }
2017}

References Config_getBool.

Referenced by HtmlGenerator::endCallGraph(), HtmlGenerator::endClassDiagram(), HtmlGenerator::endDirDepGraph(), HtmlGenerator::endDotGraph(), HtmlGenerator::endGroupCollaboration(), and HtmlGenerator::endInclDepGraph().

◆ startSectionHeader()

void startSectionHeader ( TextStream & t,
const QCString & relPath,
int sectionCount )
static

Definition at line 1956 of file htmlgen.cpp.

1958{
1959 //t << "<!-- startSectionHeader -->";
1960 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
1961 if (dynamicSections)
1962 {
1963 t << "<div id=\"dynsection-" << sectionCount << "\" "
1964 "onclick=\"return dynsection.toggleVisibility(this)\" "
1965 "class=\"dynheader closed\" "
1966 "style=\"cursor:pointer;\">"
1967 "<span class=\"dynarrow\"><span class=\"arrowhead closed\"></span></span>";
1968 }
1969 else
1970 {
1971 t << "<div class=\"dynheader\">\n";
1972 }
1973}

References Config_getBool.

Referenced by HtmlGenerator::startCallGraph(), HtmlGenerator::startClassDiagram(), HtmlGenerator::startDirDepGraph(), HtmlGenerator::startDotGraph(), HtmlGenerator::startGroupCollaboration(), and HtmlGenerator::startInclDepGraph().

◆ startSectionSummary()

void startSectionSummary ( TextStream & t,
int sectionCount )
static

Definition at line 1981 of file htmlgen.cpp.

1982{
1983 //t << "<!-- startSectionSummary -->";
1984 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
1985 if (dynamicSections)
1986 {
1987 t << "<div id=\"dynsection-" << sectionCount << "-summary\" "
1988 "class=\"dynsummary\" "
1989 "style=\"display:block;\">\n";
1990 }
1991}

References Config_getBool.

Referenced by HtmlGenerator::endCallGraph(), HtmlGenerator::endClassDiagram(), HtmlGenerator::endDirDepGraph(), HtmlGenerator::endDotGraph(), HtmlGenerator::endGroupCollaboration(), and HtmlGenerator::endInclDepGraph().

◆ substituteHtmlKeywords()

QCString substituteHtmlKeywords ( const QCString & file,
const QCString & str,
const QCString & title,
const QCString & relPath,
const QCString & navPath = QCString() )
static

Definition at line 324 of file htmlgen.cpp.

329{
330 // Build CSS/JavaScript tags depending on treeview, search engine settings
331 QCString cssFile;
332 QCString generatedBy;
333 QCString treeViewCssJs;
334 QCString searchCssJs;
335 QCString searchBox;
336 QCString mathJaxJs;
337 QCString extraCssText;
338
339 QCString projectName = Config_getString(PROJECT_NAME);
340 bool treeView = Config_getBool(GENERATE_TREEVIEW);
341 bool searchEngine = Config_getBool(SEARCHENGINE);
342 bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
343 bool mathJax = Config_getBool(USE_MATHJAX);
344 QCString mathJaxFormat = Config_getEnumAsString(MATHJAX_FORMAT);
345 bool disableIndex = Config_getBool(DISABLE_INDEX);
346 bool hasProjectName = !projectName.isEmpty();
347 bool hasProjectNumber = !Config_getString(PROJECT_NUMBER).isEmpty();
348 bool hasProjectBrief = !Config_getString(PROJECT_BRIEF).isEmpty();
349 bool hasProjectLogo = !Config_getString(PROJECT_LOGO).isEmpty();
350 bool hasProjectIcon = !Config_getString(PROJECT_ICON).isEmpty();
351 bool hasFullSideBar = Config_getBool(FULL_SIDEBAR) && /*disableIndex &&*/ treeView;
352 bool hasCopyClipboard = Config_getBool(HTML_COPY_CLIPBOARD);
353 bool hasCookie = treeView || searchEngine || Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::TOGGLE;
354 static bool titleArea = (hasProjectName || hasProjectBrief || hasProjectLogo || (disableIndex && searchEngine));
355
356 cssFile = Config_getString(HTML_STYLESHEET);
357 if (cssFile.isEmpty())
358 {
359 cssFile = "doxygen.css";
360 }
361 else
362 {
363 if (!cssFile.startsWith("http:") && !cssFile.startsWith("https:"))
364 {
365 FileInfo cssfi(cssFile.str());
366 if (cssfi.exists())
367 {
368 cssFile = cssfi.fileName();
369 }
370 else
371 {
372 cssFile = "doxygen.css";
373 }
374 }
375 }
376
377 extraCssText = "";
378 const StringVector &extraCssFile = Config_getList(HTML_EXTRA_STYLESHEET);
379 for (const auto &fileName : extraCssFile)
380 {
381 if (!fileName.empty())
382 {
383 QCString htmlStyleSheet = fileName.c_str();
384 if (htmlStyleSheet.startsWith("http:") || htmlStyleSheet.startsWith("https:"))
385 {
386 extraCssText += "<link href=\""+htmlStyleSheet+"\" rel=\"stylesheet\" type=\"text/css\"/>\n";
387 }
388 else
389 {
390 FileInfo fi(fileName);
391 if (fi.exists())
392 {
393 extraCssText += "<link href=\"$relpath^"+stripPath(fileName.c_str())+"\" rel=\"stylesheet\" type=\"text/css\"/>\n";
394 }
395 }
396 }
397 }
398
399 switch (Config_getEnum(TIMESTAMP))
400 {
401 case TIMESTAMP_t::NO:
402 generatedBy = theTranslator->trGeneratedBy();
403 break;
404 default:
405 generatedBy = theTranslator->trGeneratedAt("<span class=\"timestamp\"></span>",
406 convertToHtml(Config_getString(PROJECT_NAME)));
407 break;
408 }
409 if (treeView)
410 {
411 treeViewCssJs = "<link href=\"$relpath^navtree.css\" rel=\"stylesheet\" type=\"text/css\"/>\n"
412 "<script type=\"text/javascript\" src=\"$relpath^navtreedata.js\"></script>\n"
413 "<script type=\"text/javascript\" src=\"$relpath^navtree.js\"></script>\n";
414 }
415
416 if (searchEngine)
417 {
418 searchCssJs = "<link href=\"$relpath^search/search.css\" rel=\"stylesheet\" type=\"text/css\"/>\n";
419 if (!serverBasedSearch)
420 {
421 searchCssJs += "<script type=\"text/javascript\" src=\"$relpath^search/searchdata.js\"></script>\n";
422 }
423 searchCssJs += "<script type=\"text/javascript\" src=\"$relpath^search/search.js\"></script>\n";
424
425 if (!serverBasedSearch)
426 {
427 if (disableIndex || !Config_getBool(HTML_DYNAMIC_MENUS) || Config_getBool(FULL_SIDEBAR))
428 {
429 searchCssJs += "<script type=\"text/javascript\">\n"
430 " $(function() { init_search(); });\n"
431 "</script>";
432 }
433 }
434 else
435 {
436 if (disableIndex || !Config_getBool(HTML_DYNAMIC_MENUS))
437 {
438 searchCssJs += "<script type=\"text/javascript\">\n"
439 " $(function() {\n"
440 " if ($('.searchresults').length > 0) { searchBox.DOMSearchField().focus(); }\n"
441 " });\n"
442 "</script>\n";
443 }
444
445 // OPENSEARCH_PROVIDER {
446 searchCssJs += "<link rel=\"search\" href=\"" + relPath +
447 "search_opensearch.php?v=opensearch.xml\" "
448 "type=\"application/opensearchdescription+xml\" title=\"" +
449 (hasProjectName ? projectName : QCString("Doxygen")) +
450 "\"/>";
451 // OPENSEARCH_PROVIDER }
452 }
453 searchBox = getSearchBox(serverBasedSearch, relPath, FALSE);
454 }
455
456 if (mathJax)
457 {
458 auto mathJaxVersion = Config_getEnum(MATHJAX_VERSION);
459 QCString path = Config_getString(MATHJAX_RELPATH);
460 if (path.isEmpty() || path.startsWith("..")) // relative path
461 {
462 path.prepend(relPath);
463 }
464
465 switch (mathJaxVersion)
466 {
467 case MATHJAX_VERSION_t::MathJax_3:
468 {
469 mathJaxJs += // "<script src=\"https://polyfill.io/v3/polyfill.min.js?features=es6\"></script>\n" // needed for IE11 only, see #10354
470 "<script type=\"text/javascript\">\n"
471 "window.MathJax = {\n"
472 " options: {\n"
473 " ignoreHtmlClass: 'tex2jax_ignore',\n"
474 " processHtmlClass: 'tex2jax_process'\n"
475 " }";
476 const StringVector &mathJaxExtensions = Config_getList(MATHJAX_EXTENSIONS);
477 if (!mathJaxExtensions.empty() || !g_latex_macro.isEmpty())
478 {
479 mathJaxJs+= ",\n";
480 if (!mathJaxExtensions.empty())
481 {
482 bool first = true;
483 mathJaxJs+= " loader: {\n"
484 " load: [";
485 for (const auto &s : mathJaxExtensions)
486 {
487 if (!first) mathJaxJs+= ",";
488 mathJaxJs+= "'[tex]/"+QCString(s.c_str())+"'";
489 first = false;
490 }
491 mathJaxJs+= "]\n"
492 " },\n";
493 }
494 mathJaxJs+= " tex: {\n"
495 " macros: {";
496 if (!g_latex_macro.isEmpty())
497 {
498 mathJaxJs += g_latex_macro+" ";
499 }
500 mathJaxJs+="},\n"
501 " packages: ['base','configmacros'";
502 if (!g_latex_macro.isEmpty())
503 {
504 mathJaxJs+= ",'newcommand'";
505 }
506 for (const auto &s : mathJaxExtensions)
507 {
508 mathJaxJs+= ",'"+QCString(s.c_str())+"'";
509 }
510 mathJaxJs += "]\n"
511 " }\n";
512 }
513 else
514 {
515 mathJaxJs += "\n";
516 }
517 mathJaxJs += "};\n";
518 // MATHJAX_CODEFILE
519 if (!g_mathjax_code.isEmpty())
520 {
521 mathJaxJs += g_mathjax_code;
522 mathJaxJs += "\n";
523 }
524 mathJaxJs += "</script>\n";
525 mathJaxJs += "<script type=\"text/javascript\" id=\"MathJax-script\" async=\"async\" src=\"" +
526 path + "es5/tex-" + mathJaxFormat.lower() + ".js\">";
527 mathJaxJs+="</script>\n";
528 }
529 break;
530 case MATHJAX_VERSION_t::MathJax_2:
531 {
532 mathJaxJs = "<script type=\"text/x-mathjax-config\">\n"
533 "MathJax.Hub.Config({\n"
534 " extensions: [\"tex2jax.js\"";
535 const StringVector &mathJaxExtensions = Config_getList(MATHJAX_EXTENSIONS);
536 for (const auto &s : mathJaxExtensions)
537 {
538 mathJaxJs+= ", \""+QCString(s.c_str())+".js\"";
539 }
540 if (mathJaxFormat.isEmpty())
541 {
542 mathJaxFormat = "HTML-CSS";
543 }
544 mathJaxJs += "],\n"
545 " jax: [\"input/TeX\",\"output/"+mathJaxFormat+"\"],\n";
546 if (!g_latex_macro.isEmpty())
547 {
548 mathJaxJs += " TeX: { Macros: {\n";
549 mathJaxJs += g_latex_macro;
550 mathJaxJs += "\n"
551 " } }\n";
552 }
553 mathJaxJs += "});\n";
554 if (!g_mathjax_code.isEmpty())
555 {
556 mathJaxJs += g_mathjax_code;
557 mathJaxJs += "\n";
558 }
559 mathJaxJs += "</script>\n";
560 mathJaxJs += "<script type=\"text/javascript\" async=\"async\" src=\"" + path + "MathJax.js\"></script>\n";
561 }
562 break;
563 }
564 }
565
566 QCString darkModeJs;
567 if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::TOGGLE)
568 {
569 darkModeJs="<script type=\"text/javascript\" src=\"$relpath^darkmode_toggle.js\"></script>\n";
570 }
571
572 if (hasCookie) // extend the $treeview tag to avoid breaking old files used with HTML_HEADER
573 {
574 treeViewCssJs+="<script type=\"text/javascript\" src=\"$relpath^cookie.js\"></script>\n";
575 }
576
577 // first substitute generic keywords
578 QCString result = substituteKeywords(file,str,title,
579 convertToHtml(Config_getString(PROJECT_NAME)),
580 convertToHtml(Config_getString(PROJECT_NUMBER)),
581 convertToHtml(Config_getString(PROJECT_BRIEF)));
582
583 // then do the HTML specific keywords
584 result = substituteKeywords(file,result,
585 {
586 // keyword value getter
587 { "$datetime", [&]() { return "<span class=\"datetime\"></span>"; } },
588 { "$date", [&]() { return "<span class=\"date\"></span>"; } },
589 { "$time", [&]() { return "<span class=\"time\"></span>"; } },
590 { "$year", [&]() { return "<span class=\"year\"></span>"; } },
591 { "$navpath", [&]() { return navPath; } },
592 { "$stylesheet", [&]() { return cssFile; } },
593 { "$treeview", [&]() { return treeViewCssJs; } },
594 { "$searchbox", [&]() { return searchBox; } },
595 { "$search", [&]() { return searchCssJs; } },
596 { "$mathjax", [&]() { return mathJaxJs; } },
597 { "$darkmode", [&]() { return darkModeJs; } },
598 { "$generatedby", [&]() { return generatedBy; } },
599 { "$extrastylesheet",[&]() { return extraCssText; } },
600 { "$relpath$", [&]() { return relPath; } } //<-- obsolete: for backwards compatibility only
601 });
602
603 result = substitute(result,"$relpath^",relPath); //<-- must be done after the previous substitutions
604
605 // remove conditional blocks
606 result = selectBlocks(result,
607 {
608 // keyword, is enabled
609 { "FULL_SIDEBAR", hasFullSideBar },
610 { "DISABLE_INDEX", disableIndex },
611 { "GENERATE_TREEVIEW", treeView },
612 { "SEARCHENGINE", searchEngine },
613 { "TITLEAREA", titleArea },
614 { "PROJECT_NAME", hasProjectName },
615 { "PROJECT_NUMBER", hasProjectNumber },
616 { "PROJECT_BRIEF", hasProjectBrief },
617 { "PROJECT_LOGO", hasProjectLogo },
618 { "PROJECT_ICON", hasProjectIcon },
619 { "COPY_CLIPBOARD", hasCopyClipboard },
621
622 result = removeEmptyLines(result);
623
624 return result;
625}
QCString & prepend(const char *s)
Definition qcstring.h:407
QCString lower() const
Definition qcstring.h:234
#define Config_getList(name)
Definition config.h:38
#define Config_getEnumAsString(name)
Definition config.h:36
std::vector< std::string > StringVector
Definition containers.h:33
static QCString g_mathjax_code
Definition htmlgen.cpp:68
static const SelectionMarkerInfo htmlMarkerInfo
Definition htmlgen.cpp:73
static QCString getSearchBox(bool serverSide, QCString relPath, bool highlightSearch)
Definition htmlgen.cpp:310
static QCString g_latex_macro
Definition htmlgen.cpp:69
Translator * theTranslator
Definition language.cpp:71
QCString substitute(const QCString &s, const QCString &src, const QCString &dst)
substitute all occurrences of src in s by dst
Definition qcstring.cpp:477
QCString convertToHtml(const QCString &s, bool keepEntities)
Definition util.cpp:4476
QCString stripPath(const QCString &s)
Definition util.cpp:5461
QCString removeEmptyLines(const QCString &s)
Definition util.cpp:7097
QCString selectBlocks(const QCString &s, const SelectionBlockList &blockList, const SelectionMarkerInfo &markerInfo)
remove disabled blocks and all block markers from s and return the result as a string
Definition util.cpp:6920
QCString substituteKeywords(const QCString &file, const QCString &s, const KeywordSubstitutionList &keywords)
Definition util.cpp:3572

References Config_getBool, Config_getEnum, Config_getEnumAsString, Config_getList, Config_getString, convertToHtml(), FileInfo::exists(), FALSE, FileInfo::fileName(), g_latex_macro, g_mathjax_code, getSearchBox(), htmlMarkerInfo, QCString::isEmpty(), QCString::lower(), QCString::prepend(), removeEmptyLines(), selectBlocks(), QCString::startsWith(), QCString::str(), stripPath(), substitute(), substituteKeywords(), and theTranslator.

Referenced by HtmlGenerator::init(), HtmlGenerator::startFile(), HtmlGenerator::writeExternalSearchPage(), HtmlGenerator::writePageFooter(), and HtmlGenerator::writeSearchPage().

◆ writeClientSearchBox()

void writeClientSearchBox ( TextStream & t,
const QCString & relPath )
static

Definition at line 77 of file htmlgen.cpp.

78{
79 t << " <div id=\"MSearchBox\" class=\"MSearchBoxInactive\">\n";
80 t << " <span class=\"left\">\n";
81 t << " <span id=\"MSearchSelect\" class=\"search-icon\" ";
82 t << "onmouseover=\"return searchBox.OnSearchSelectShow()\" ";
83 t << "onmouseout=\"return searchBox.OnSearchSelectHide()\">";
84 t << "<span class=\"search-icon-dropdown\"></span></span>\n";
85 t << " <input type=\"text\" id=\"MSearchField\" value=\"\" placeholder=\""
86 << theTranslator->trSearch() << "\" accesskey=\"S\"\n";
87 t << " onfocus=\"searchBox.OnSearchFieldFocus(true)\" \n";
88 t << " onblur=\"searchBox.OnSearchFieldFocus(false)\" \n";
89 t << " onkeyup=\"searchBox.OnSearchFieldChange(event)\"/>\n";
90 t << " </span><span class=\"right\">\n";
91 t << " <a id=\"MSearchClose\" href=\"javascript:searchBox.CloseResultsWindow()\">"
92 << "<div id=\"MSearchCloseImg\" class=\"close-icon\"></div></a>\n";
93 t << " </span>\n";
94 t << " </div>\n";
95}

References theTranslator.

Referenced by getSearchBox(), and renderQuickLinksAsTabs().

◆ writeDefaultQuickLinks()

void writeDefaultQuickLinks ( TextStream & t,
HighlightedItem hli,
const QCString & file,
const QCString & relPath,
bool extraTabs )
static

Definition at line 2898 of file htmlgen.cpp.

2903{
2904 bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
2905 bool searchEngine = Config_getBool(SEARCHENGINE);
2906 bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
2907 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
2908 bool fullSidebar = Config_getBool(FULL_SIDEBAR);
2909 bool disableIndex = Config_getBool(DISABLE_INDEX);
2910 bool dynamicMenus = Config_getBool(HTML_DYNAMIC_MENUS);
2912 LayoutNavEntry::Kind kind = LayoutNavEntry::None;
2913 LayoutNavEntry::Kind altKind = LayoutNavEntry::None; // fall back for the old layout file
2914 bool highlightParent=false;
2915 switch (hli) // map HLI enums to LayoutNavEntry::Kind enums
2916 {
2917 case HighlightedItem::Main: kind = LayoutNavEntry::MainPage; break;
2918 case HighlightedItem::Topics: kind = LayoutNavEntry::Topics; break;
2919 case HighlightedItem::Modules: kind = LayoutNavEntry::ModuleList; altKind = LayoutNavEntry::Modules; break;
2920 case HighlightedItem::Namespaces: kind = LayoutNavEntry::NamespaceList; altKind = LayoutNavEntry::Namespaces; break;
2921 case HighlightedItem::ClassHierarchy: kind = LayoutNavEntry::ClassHierarchy; break;
2922 case HighlightedItem::InterfaceHierarchy: kind = LayoutNavEntry::InterfaceHierarchy; break;
2923 case HighlightedItem::ExceptionHierarchy: kind = LayoutNavEntry::ExceptionHierarchy; break;
2924 case HighlightedItem::Classes: kind = LayoutNavEntry::ClassIndex; altKind = LayoutNavEntry::Classes; break;
2925 case HighlightedItem::Concepts: kind = LayoutNavEntry::Concepts; break;
2926 case HighlightedItem::Interfaces: kind = LayoutNavEntry::InterfaceIndex; altKind = LayoutNavEntry::Interfaces; break;
2927 case HighlightedItem::Structs: kind = LayoutNavEntry::StructIndex; altKind = LayoutNavEntry::Structs; break;
2928 case HighlightedItem::Exceptions: kind = LayoutNavEntry::ExceptionIndex; altKind = LayoutNavEntry::Exceptions; break;
2929 case HighlightedItem::AnnotatedClasses: kind = LayoutNavEntry::ClassList; altKind = LayoutNavEntry::Classes; break;
2930 case HighlightedItem::AnnotatedInterfaces: kind = LayoutNavEntry::InterfaceList; altKind = LayoutNavEntry::Interfaces; break;
2931 case HighlightedItem::AnnotatedStructs: kind = LayoutNavEntry::StructList; altKind = LayoutNavEntry::Structs; break;
2932 case HighlightedItem::AnnotatedExceptions: kind = LayoutNavEntry::ExceptionList; altKind = LayoutNavEntry::Exceptions; break;
2933 case HighlightedItem::Files: kind = LayoutNavEntry::FileList; altKind = LayoutNavEntry::Files; break;
2934 case HighlightedItem::NamespaceMembers: kind = LayoutNavEntry::NamespaceMembers; break;
2935 case HighlightedItem::ModuleMembers: kind = LayoutNavEntry::ModuleMembers; break;
2936 case HighlightedItem::Functions: kind = LayoutNavEntry::ClassMembers; break;
2937 case HighlightedItem::Globals: kind = LayoutNavEntry::FileGlobals; break;
2938 case HighlightedItem::Pages: kind = LayoutNavEntry::Pages; break;
2939 case HighlightedItem::Examples: kind = LayoutNavEntry::Examples; break;
2940 case HighlightedItem::UserGroup: kind = LayoutNavEntry::UserGroup; break;
2941 case HighlightedItem::ClassVisible: kind = LayoutNavEntry::ClassList; altKind = LayoutNavEntry::Classes;
2942 highlightParent = true; break;
2943 case HighlightedItem::ConceptVisible: kind = LayoutNavEntry::Concepts;
2944 highlightParent = true; break;
2945 case HighlightedItem::ModuleVisible: kind = LayoutNavEntry::ModuleList; altKind = LayoutNavEntry::Modules;
2946 highlightParent = true; break;
2947 case HighlightedItem::InterfaceVisible: kind = LayoutNavEntry::InterfaceList; altKind = LayoutNavEntry::Interfaces;
2948 highlightParent = true; break;
2949 case HighlightedItem::StructVisible: kind = LayoutNavEntry::StructList; altKind = LayoutNavEntry::Structs;
2950 highlightParent = true; break;
2951 case HighlightedItem::ExceptionVisible: kind = LayoutNavEntry::ExceptionList; altKind = LayoutNavEntry::Exceptions;
2952 highlightParent = true; break;
2953 case HighlightedItem::NamespaceVisible: kind = LayoutNavEntry::NamespaceList; altKind = LayoutNavEntry::Namespaces;
2954 highlightParent = true; break;
2955 case HighlightedItem::FileVisible: kind = LayoutNavEntry::FileList; altKind = LayoutNavEntry::Files;
2956 highlightParent = true; break;
2957 case HighlightedItem::None: break;
2958 case HighlightedItem::Search: break;
2959 }
2960
2961 if (!disableIndex && dynamicMenus)
2962 {
2963 QCString searchPage;
2964 if (externalSearch)
2965 {
2966 searchPage = "search" + Doxygen::htmlFileExtension;
2967 }
2968 else
2969 {
2970 searchPage = "search.php";
2971 }
2972 t << "<script type=\"text/javascript\" src=\"" << relPath << "menudata.js\"></script>\n";
2973 t << "<script type=\"text/javascript\" src=\"" << relPath << "menu.js\"></script>\n";
2974 t << "<script type=\"text/javascript\">\n";
2975 t << "$(function() {\n";
2976 t << " initMenu('" << relPath << "',"
2977 << (searchEngine && !(generateTreeView && fullSidebar)?"true":"false") << ","
2978 << (serverBasedSearch?"true":"false") << ",'"
2979 << searchPage << "','"
2980 << theTranslator->trSearch() << "',"
2981 << (generateTreeView?"true":"false")
2982 << ");\n";
2983 if (searchEngine)
2984 {
2985 if (!serverBasedSearch)
2986 {
2987 if (!disableIndex && dynamicMenus && !fullSidebar)
2988 {
2989 t << " $(function() { init_search(); });\n";
2990 }
2991 }
2992 else
2993 {
2994 t << " $(function() {\n"
2995 << " if ($('.searchresults').length > 0) { searchBox.DOMSearchField().focus(); }\n";
2996 t << " });\n";
2997 }
2998 }
2999 t << "});\n";
3000 t << "</script>\n";
3001 t << "<div id=\"main-nav\"></div>\n";
3002 }
3003 else if (!disableIndex) // && !Config_getBool(HTML_DYNAMIC_MENUS)
3004 {
3005 // find highlighted index item
3006 LayoutNavEntry *hlEntry = root->find(kind,kind==LayoutNavEntry::UserGroup ? file : QCString());
3007 if (!hlEntry && altKind!=LayoutNavEntry::None) { hlEntry=root->find(altKind); kind=altKind; }
3008 if (!hlEntry) // highlighted item not found in the index! -> just show the level 1 index...
3009 {
3010 highlightParent=TRUE;
3011 hlEntry = root->children().front().get();
3012 if (hlEntry==nullptr)
3013 {
3014 return; // argl, empty index!
3015 }
3016 }
3017 if (kind==LayoutNavEntry::UserGroup)
3018 {
3019 LayoutNavEntry *e = hlEntry->children().front().get();
3020 if (e)
3021 {
3022 hlEntry = e;
3023 }
3024 }
3025 t << "<div id=\"main-nav\">\n";
3026 renderQuickLinksAsTabs(t,relPath,hlEntry,kind,highlightParent,hli==HighlightedItem::Search);
3027 if (!extraTabs)
3028 {
3029 t << "</div><!-- main-nav -->\n";
3030 }
3031 }
3032 else if (!generateTreeView)
3033 {
3034 renderQuickLinksAsTree(t,relPath,root);
3035 }
3036 if (generateTreeView && !disableIndex && fullSidebar && !extraTabs)
3037 {
3038 t << "<div id=\"container\"><div id=\"doc-content\">\n";
3039 }
3040}
static QCString htmlFileExtension
Definition doxygen.h:122
LayoutNavEntry * rootNavEntry() const
returns the (invisible) root of the navigation tree.
Definition layout.cpp:1446
@ AnnotatedExceptions
Definition index.h:76
@ InterfaceVisible
Definition index.h:89
@ InterfaceHierarchy
Definition index.h:66
@ AnnotatedInterfaces
Definition index.h:74
@ NamespaceMembers
Definition index.h:78
@ AnnotatedClasses
Definition index.h:73
@ AnnotatedStructs
Definition index.h:75
@ ExceptionVisible
Definition index.h:91
@ NamespaceVisible
Definition index.h:92
@ ExceptionHierarchy
Definition index.h:67
Base class for the layout of a navigation item at the top of the HTML pages.
Definition layout.h:156
LayoutNavEntry * find(LayoutNavEntry::Kind k, const QCString &file=QCString()) const
Definition layout.cpp:133
Kind
Definition layout.h:193

References AnnotatedClasses, AnnotatedExceptions, AnnotatedInterfaces, AnnotatedStructs, LayoutNavEntry::children(), Classes, ClassHierarchy, ClassVisible, Concepts, ConceptVisible, Config_getBool, Examples, ExceptionHierarchy, Exceptions, ExceptionVisible, Files, FileVisible, LayoutNavEntry::find(), Functions, Globals, Doxygen::htmlFileExtension, LayoutDocManager::instance(), InterfaceHierarchy, Interfaces, InterfaceVisible, Main, ModuleMembers, Modules, ModuleVisible, NamespaceMembers, Namespaces, NamespaceVisible, None, Pages, renderQuickLinksAsTabs(), renderQuickLinksAsTree(), LayoutDocManager::rootNavEntry(), Search, Structs, StructVisible, theTranslator, Topics, TRUE, and UserGroup.

Referenced by HtmlGenerator::writeExternalSearchPage(), HtmlGenerator::writeQuickLinks(), and HtmlGenerator::writeSearchPage().

◆ writeDefaultStyleSheet()

void writeDefaultStyleSheet ( TextStream & t)
static

Definition at line 1365 of file htmlgen.cpp.

1366{
1367 t << "/* The standard CSS for doxygen " << getDoxygenVersion() << "*/\n\n";
1368 switch (Config_getEnum(HTML_COLORSTYLE))
1369 {
1370 case HTML_COLORSTYLE_t::LIGHT:
1371 case HTML_COLORSTYLE_t::DARK:
1372 /* variables will be resolved while writing to the CSS file */
1373 break;
1374 case HTML_COLORSTYLE_t::AUTO_LIGHT:
1375 case HTML_COLORSTYLE_t::TOGGLE:
1376 t << "html {\n";
1377 t << replaceColorMarkers(ResourceMgr::instance().getAsString("lightmode_settings.css"));
1378 t << "}\n\n";
1379 break;
1380 case HTML_COLORSTYLE_t::AUTO_DARK:
1381 t << "html {\n";
1382 t << replaceColorMarkers(ResourceMgr::instance().getAsString("darkmode_settings.css"));
1383 t << "}\n\n";
1384 break;
1385 }
1386 if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::AUTO_LIGHT)
1387 {
1388 t << "@media (prefers-color-scheme: dark) {\n";
1389 t << " html:not(.dark-mode) {\n";
1390 t << " color-scheme: dark;\n\n";
1391 t << replaceColorMarkers(ResourceMgr::instance().getAsString("darkmode_settings.css"));
1392 t << "}}\n";
1393 }
1394 else if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::AUTO_DARK)
1395 {
1396 t << "@media (prefers-color-scheme: light) {\n";
1397 t << " html:not(.light-mode) {\n";
1398 t << " color-scheme: light;\n\n";
1399 t << replaceColorMarkers(ResourceMgr::instance().getAsString("lightmode_settings.css"));
1400 t << "}}\n";
1401 }
1402 else if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::TOGGLE)
1403 {
1404 t << "html.dark-mode {\n";
1405 t << replaceColorMarkers(ResourceMgr::instance().getAsString("darkmode_settings.css"));
1406 t << "}\n\n";
1407 }
1408
1409 QCString cssStr = ResourceMgr::instance().getAsString("doxygen.css");
1410 bool hasFullSidebar = Config_getBool(FULL_SIDEBAR) && Config_getBool(GENERATE_TREEVIEW);
1411 if (hasFullSidebar)
1412 {
1413 cssStr+="\n"
1414 "#titlearea {\n"
1415 " border-bottom: none;\n"
1416 " background-color: var(--nav-background-color);\n"
1417 " border-right: 1px solid var(--nav-border-color);\n"
1418 "}\n";
1419 }
1420 t << replaceVariables(cssStr);
1421
1422 bool addTimestamp = Config_getEnum(TIMESTAMP)!=TIMESTAMP_t::NO;
1423 if (g_build_date || addTimestamp)
1424 {
1425 t << "\nhtml {\n";
1426
1427 if (addTimestamp)
1428 {
1429 QCString timeStampStr;
1430 switch (Config_getEnum(TIMESTAMP))
1431 {
1432 case TIMESTAMP_t::YES:
1433 case TIMESTAMP_t::DATETIME:
1434 timeStampStr = dateToString(DateTimeType::DateTime);
1435 break;
1436 case TIMESTAMP_t::DATE:
1437 timeStampStr = dateToString(DateTimeType::Date);
1438 break;
1439 default:
1440 break;
1441 }
1442 t << "--timestamp: '" << timeStampStr << "';\n";
1443 }
1444 if (g_build_date)
1445 {
1446 t << "--datetime: '" << dateToString(DateTimeType::DateTime) << "';\n";
1447 t << "--date: '" << dateToString(DateTimeType::Date) << "';\n";
1448 t << "--time: '" << dateToString(DateTimeType::Time) << "';\n";
1449 t << "--year: '" << yearToString() << "';\n";
1450 }
1451 t << "}\n";
1452
1453 if (addTimestamp)
1454 {
1455 t << "span.timestamp { content: ' '; }\n";
1456 t << "span.timestamp:before { content: var(--timestamp); }\n\n";
1457 }
1458 if (g_build_date)
1459 {
1460 t << "span.datetime { content: ' '; }\n";
1461 t << "span.datetime:before { content: var(--datetime); }\n\n";
1462 t << "span.date { content: ' '; }\n";
1463 t << "span.date:before { content: var(--date); }\n\n";
1464 t << "span.time { content: ' '; }\n";
1465 t << "span.time:before { content: var(--time); }\n\n";
1466 t << "span.year { content: ' '; }\n";
1467 t << "span.year:before { content: var(--year); }\n\n";
1468 }
1469 }
1470
1471 // For Webkit based the scrollbar styling cannot be overruled (bug in chromium?).
1472 // To allow the user to style the scrollbars differently we should only add it in case
1473 // the user did not specify any extra stylesheets.
1474 bool addScrollbarStyling = Config_getList(HTML_EXTRA_STYLESHEET).empty();
1475 if (addScrollbarStyling)
1476 {
1477 t << replaceVariables(ResourceMgr::instance().getAsString("scrollbar.css"));
1478 }
1479
1480}
QCString dateToString(DateTimeType includeTime)
Returns the current date, when includeTime is set also the time is provided.
Definition datetime.cpp:63
QCString yearToString()
Returns the current year as a string.
Definition datetime.cpp:76
static bool g_build_date
Definition htmlgen.cpp:70
static QCString replaceVariables(const QCString &input)
Definition htmlgen.cpp:667

References Config_getBool, Config_getEnum, Config_getList, Date, DateTime, dateToString(), g_build_date, ResourceMgr::getAsString(), ResourceMgr::instance(), replaceColorMarkers(), replaceVariables(), Time, and yearToString().

Referenced by HtmlGenerator::writeStyleInfo(), LatexGenerator::writeStyleInfo(), HtmlGenerator::writeStyleSheetFile(), and LatexGenerator::writeStyleSheetFile().

◆ writeServerSearchBox()

void writeServerSearchBox ( TextStream & t,
const QCString & relPath,
bool highlightSearch )
static

Definition at line 99 of file htmlgen.cpp.

100{
101 bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
102 t << " <div id=\"MSearchBox\" class=\"MSearchBoxInactive\">\n";
103 t << " <div class=\"left\">\n";
104 t << " <form id=\"FSearchBox\" action=\"" << relPath;
105 if (externalSearch)
106 {
107 t << "search" << Doxygen::htmlFileExtension;
108 }
109 else
110 {
111 t << "search.php";
112 }
113 t << "\" method=\"get\">\n";
114 t << " <span id=\"MSearchSelectExt\" class=\"search-icon\"></span>\n";
115 if (!highlightSearch || !Config_getBool(HTML_DYNAMIC_MENUS))
116 {
117 t << " <input type=\"text\" id=\"MSearchField\" name=\"query\" value=\"\" placeholder=\""
118 << theTranslator->trSearch() << "\" size=\"20\" accesskey=\"S\" \n";
119 t << " onfocus=\"searchBox.OnSearchFieldFocus(true)\" \n";
120 t << " onblur=\"searchBox.OnSearchFieldFocus(false)\"/>\n";
121 t << " </form>\n";
122 t << " </div><div class=\"right\"></div>\n";
123 t << " </div>\n";
124 }
125}

References Config_getBool, Doxygen::htmlFileExtension, and theTranslator.

Referenced by getSearchBox(), and renderQuickLinksAsTabs().

Variable Documentation

◆ g_build_date

bool g_build_date = false
static

Definition at line 70 of file htmlgen.cpp.

Referenced by HtmlGenerator::init(), and writeDefaultStyleSheet().

◆ g_darkMap

StringUnorderedMap g_darkMap
static

Definition at line 630 of file htmlgen.cpp.

Referenced by fillColorStyleMaps(), and replaceVariables().

◆ g_footer

◆ g_footer_file

◆ g_header

◆ g_header_file

◆ g_indexLock

std::mutex g_indexLock
static

Definition at line 1500 of file htmlgen.cpp.

Referenced by HtmlGenerator::startFile().

◆ g_latex_macro

QCString g_latex_macro
static

Definition at line 69 of file htmlgen.cpp.

Referenced by HtmlGenerator::init(), and substituteHtmlKeywords().

◆ g_lightMap

StringUnorderedMap g_lightMap
static

Definition at line 629 of file htmlgen.cpp.

Referenced by fillColorStyleMaps(), and replaceVariables().

◆ g_mathjax_code

QCString g_mathjax_code
static

Definition at line 68 of file htmlgen.cpp.

Referenced by HtmlGenerator::init(), and substituteHtmlKeywords().

◆ hex

auto hex ="0123456789ABCDEF"
staticconstexpr

Definition at line 71 of file htmlgen.cpp.

◆ htmlMarkerInfo

const SelectionMarkerInfo htmlMarkerInfo = { '<', "<!--BEGIN ",10,"<!--END ",8,"-->",3 }
static

Definition at line 73 of file htmlgen.cpp.

73{ '<', "<!--BEGIN ",10,"<!--END ",8,"-->",3 };

Referenced by HtmlGenerator::init(), and substituteHtmlKeywords().