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(), bool isSource=false)
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 2783 of file htmlgen.cpp.

2784{
2785 t << "</span>";
2786 if (!l.isEmpty()) t << "</a>";
2787 t << "</li>\n";
2788}
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:163

References QCString::isEmpty().

Referenced by renderQuickLinksAsTabs().

◆ endQuickIndexList()

void endQuickIndexList ( TextStream & t)
static

Definition at line 2756 of file htmlgen.cpp.

2757{
2758 if (!Config_getBool(DISABLE_INDEX))
2759 {
2760 t << " </ul>\n";
2761 t << " </div>\n";
2762 }
2763 else
2764 {
2765 t << "</ul>\n";
2766 }
2767}
#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 2066 of file htmlgen.cpp.

2067{
2068 //t << "<!-- endSectionContent -->";
2069 t << "</div>\n";
2070}

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 2040 of file htmlgen.cpp.

2041{
2042 //t << "<!-- endSectionSummary -->";
2043 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
2044 if (dynamicSections)
2045 {
2046 t << "</div>\n";
2047 }
2048}

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 671 of file htmlgen.cpp.

672{
673 int p=0,i=0;
674 while ((i=definitions.find('\n',p))!=-1)
675 {
676 QCString line = definitions.mid(p,i-p);
677 if (line.startsWith("--"))
678 {
679 int separator = line.find(':');
680 assert(separator!=-1);
681 std::string key = line.left(separator).str();
682 int semi = line.findRev(';');
683 assert(semi!=-1);
684 std::string value = line.mid(separator+1,semi-separator-1).stripWhiteSpace().str();
685 map.emplace(key,value);
686 //printf("var(%s)=%s\n",qPrint(key),qPrint(value));
687 }
688 p=i+1;
689 }
690}
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:507
QCString mid(size_t index, size_t len=static_cast< size_t >(-1)) const
Definition qcstring.h:241
QCString stripWhiteSpace() const
returns a copy of this string with leading and trailing whitespace removed
Definition qcstring.h:260
const std::string & str() const
Definition qcstring.h:552
int findRev(char c, int index=-1, bool cs=TRUE) const
Definition qcstring.cpp:96
QCString left(size_t len) const
Definition qcstring.h:229

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 692 of file htmlgen.cpp.

693{
695 auto colorStyle = Config_getEnum(HTML_COLORSTYLE);
696 if (colorStyle==HTML_COLORSTYLE_t::LIGHT)
697 {
698 fillColorStyleMap(replaceColorMarkers(mgr.getAsString("lightmode_settings.css")),g_lightMap);
699 }
700 else if (colorStyle==HTML_COLORSTYLE_t::DARK)
701 {
702 fillColorStyleMap(replaceColorMarkers(mgr.getAsString("darkmode_settings.css")),g_darkMap);
703 }
704}
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:671
static StringUnorderedMap g_lightMap
Definition htmlgen.cpp:668
static StringUnorderedMap g_darkMap
Definition htmlgen.cpp:669
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:5718

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:166
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:172
#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:1439

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 1194 of file htmlgen.cpp.

1195{
1196 return (str.contains("$datetime",false) ||
1197 str.contains("$date",false) ||
1198 str.contains("$time",false) ||
1199 str.contains("$year",false)
1200 );
1201}
int contains(char c, bool cs=TRUE) const
Definition qcstring.cpp:148

References QCString::contains().

Referenced by HtmlGenerator::init().

◆ quickLinkVisible()

bool quickLinkVisible ( LayoutNavEntry::Kind kind)
static

Definition at line 2790 of file htmlgen.cpp.

2791{
2792 const auto &index = Index::instance();
2793 bool showNamespaces = Config_getBool(SHOW_NAMESPACES);
2794 bool showFiles = Config_getBool(SHOW_FILES);
2795 switch (kind)
2796 {
2797 case LayoutNavEntry::MainPage: return TRUE;
2798 case LayoutNavEntry::User: return TRUE;
2799 case LayoutNavEntry::UserGroup: return TRUE;
2800 case LayoutNavEntry::Pages: return index.numIndexedPages()>0;
2801 case LayoutNavEntry::Topics: return index.numDocumentedGroups()>0;
2802 case LayoutNavEntry::Modules: return index.numDocumentedModules()>0;
2803 case LayoutNavEntry::ModuleList: return index.numDocumentedModules()>0;
2804 case LayoutNavEntry::ModuleMembers: return index.numDocumentedModuleMembers(ModuleMemberHighlight::All)>0;
2805 case LayoutNavEntry::Namespaces: return showNamespaces && index.numDocumentedNamespaces()>0;
2806 case LayoutNavEntry::NamespaceList: return showNamespaces && index.numDocumentedNamespaces()>0;
2807 case LayoutNavEntry::NamespaceMembers: return showNamespaces && index.numDocumentedNamespaceMembers(NamespaceMemberHighlight::All)>0;
2808 case LayoutNavEntry::Concepts: return index.numDocumentedConcepts()>0;
2809 case LayoutNavEntry::Classes: return index.numAnnotatedClasses()>0;
2810 case LayoutNavEntry::ClassList: return index.numAnnotatedClasses()>0;
2811 case LayoutNavEntry::ClassIndex: return index.numAnnotatedClasses()>0;
2812 case LayoutNavEntry::ClassHierarchy: return index.numHierarchyClasses()>0;
2813 case LayoutNavEntry::ClassMembers: return index.numDocumentedClassMembers(ClassMemberHighlight::All)>0;
2814 case LayoutNavEntry::Files: return showFiles && index.numDocumentedFiles()>0;
2815 case LayoutNavEntry::FileList: return showFiles && index.numDocumentedFiles()>0;
2816 case LayoutNavEntry::FileGlobals: return showFiles && index.numDocumentedFileMembers(FileMemberHighlight::All)>0;
2817 case LayoutNavEntry::Examples: return !Doxygen::exampleLinkedMap->empty();
2818 case LayoutNavEntry::Interfaces: return index.numAnnotatedInterfaces()>0;
2819 case LayoutNavEntry::InterfaceList: return index.numAnnotatedInterfaces()>0;
2820 case LayoutNavEntry::InterfaceIndex: return index.numAnnotatedInterfaces()>0;
2821 case LayoutNavEntry::InterfaceHierarchy: return index.numHierarchyInterfaces()>0;
2822 case LayoutNavEntry::Structs: return index.numAnnotatedStructs()>0;
2823 case LayoutNavEntry::StructList: return index.numAnnotatedStructs()>0;
2824 case LayoutNavEntry::StructIndex: return index.numAnnotatedStructs()>0;
2825 case LayoutNavEntry::Exceptions: return index.numAnnotatedExceptions()>0;
2826 case LayoutNavEntry::ExceptionList: return index.numAnnotatedExceptions()>0;
2827 case LayoutNavEntry::ExceptionIndex: return index.numAnnotatedExceptions()>0;
2828 case LayoutNavEntry::ExceptionHierarchy: return index.numHierarchyExceptions()>0;
2829 case LayoutNavEntry::None: // should never happen, means not properly initialized
2830 assert(kind != LayoutNavEntry::None);
2831 return FALSE;
2832 }
2833 return FALSE;
2834}
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 2865 of file htmlgen.cpp.

2868{
2869 if (hlEntry->parent()) // first draw the tabs for the parent of hlEntry
2870 {
2871 renderQuickLinksAsTabs(t,relPath,hlEntry->parent(),kind,highlightParent,highlightSearch);
2872 }
2873 if (hlEntry->parent() && !hlEntry->parent()->children().empty()) // draw tabs for row containing hlEntry
2874 {
2875 bool topLevel = hlEntry->parent()->parent()==nullptr;
2876 int count=0;
2877 for (const auto &entry : hlEntry->parent()->children())
2878 {
2879 if (entry->visible() && quickLinkVisible(entry->kind())) count++;
2880 }
2881 if (count>0) // at least one item is visible
2882 {
2883 startQuickIndexList(t,topLevel);
2884 for (const auto &entry : hlEntry->parent()->children())
2885 {
2886 if (entry->visible() && quickLinkVisible(entry->kind()))
2887 {
2888 QCString url = entry->url();
2889 startQuickIndexItem(t,url,
2890 entry.get()==hlEntry &&
2891 (!entry->children().empty() ||
2892 (entry->kind()==kind && !highlightParent)
2893 ),
2894 TRUE,relPath);
2895 t << fixSpaces(entry->title());
2896 endQuickIndexItem(t,url);
2897 }
2898 }
2899 if (hlEntry->parent()==LayoutDocManager::instance().rootNavEntry()) // first row is special as it contains the search box
2900 {
2901 bool searchEngine = Config_getBool(SEARCHENGINE);
2902 bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
2903 bool disableIndex = Config_getBool(DISABLE_INDEX);
2904 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
2905 bool fullSidebar = Config_getBool(FULL_SIDEBAR);
2906 // case where DISABLE_INDEX=NO & GENERATE_TREEVIEW=YES & FULL_SIDEBAR=YES has search box in the side panel
2907 if (searchEngine)
2908 {
2909 t << " <li>\n";
2910 if (disableIndex || !generateTreeView || !fullSidebar)
2911 {
2912 if (!serverBasedSearch) // pure client side search
2913 {
2914 writeClientSearchBox(t,relPath);
2915 t << " </li>\n";
2916 }
2917 else // server based search
2918 {
2919 writeServerSearchBox(t,relPath,highlightSearch);
2920 if (!highlightSearch)
2921 {
2922 t << " </li>\n";
2923 }
2924 }
2925 }
2926 else
2927 {
2928 t << " </li>\n";
2929 }
2930 }
2931 if (!highlightSearch || Config_getBool(FULL_SIDEBAR))
2932 // on the search page the index will be ended by the page itself if the search box is part of the navigation bar
2933 {
2935 }
2936 }
2937 else // normal case for other rows than first one
2938 {
2940 }
2941 }
2942 }
2943}
static LayoutDocManager & instance()
Returns a reference to this singleton.
Definition layout.cpp:1435
static void endQuickIndexList(TextStream &t)
Definition htmlgen.cpp:2756
static void startQuickIndexList(TextStream &t, bool topLevel=TRUE)
Definition htmlgen.cpp:2736
static void startQuickIndexItem(TextStream &t, const QCString &l, bool hl, bool, const QCString &relPath)
Definition htmlgen.cpp:2769
static void renderQuickLinksAsTabs(TextStream &t, const QCString &relPath, LayoutNavEntry *hlEntry, LayoutNavEntry::Kind kind, bool highlightParent, bool highlightSearch)
Definition htmlgen.cpp:2865
static void endQuickIndexItem(TextStream &t, const QCString &l)
Definition htmlgen.cpp:2783
static bool quickLinkVisible(LayoutNavEntry::Kind kind)
Definition htmlgen.cpp:2790
const LayoutNavEntryList & children() const
Definition layout.h:219
LayoutNavEntry * parent() const
Definition layout.h:212
QCString fixSpaces(const QCString &s)
Definition util.h:470

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 2836 of file htmlgen.cpp.

2838{
2839 int count=0;
2840 for (const auto &entry : root->children())
2841 {
2842 if (entry->visible() && quickLinkVisible(entry->kind())) count++;
2843 }
2844 if (count>0) // at least one item is visible
2845 {
2847 for (const auto &entry : root->children())
2848 {
2849 if (entry->visible() && quickLinkVisible(entry->kind()))
2850 {
2851 QCString url = entry->url();
2852 t << "<li><a href=\"" << relPath << url << "\"><span>";
2853 t << fixSpaces(entry->title());
2854 t << "</span></a>\n";
2855 // recursive into child list
2856 renderQuickLinksAsTree(t,relPath,entry.get());
2857 t << "</li>";
2858 }
2859 }
2861 }
2862}
static void renderQuickLinksAsTree(TextStream &t, const QCString &relPath, LayoutNavEntry *root)
Definition htmlgen.cpp:2836

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

Referenced by renderQuickLinksAsTree(), and writeDefaultQuickLinks().

◆ replaceVariables()

QCString replaceVariables ( const QCString & input)
static

Definition at line 706 of file htmlgen.cpp.

707{
708 auto doReplacements = [&input](const StringUnorderedMap &mapping) -> QCString
709 {
710 GrowBuf output;
711 int p=0,i=0;
712 while ((i=input.find("var(",p))!=-1)
713 {
714 output.addStr(input.data()+p,i-p);
715 int j=input.find(")",i+4);
716 assert(j!=-1);
717 auto it = mapping.find(input.mid(i+4,j-i-4).str()); // find variable
718 if (it==mapping.end())
719 { // should be found
720 err("failed to find value variable {}. It is not longer defined in doxygen.css\n",input.mid(i+4,j-i-4));
721 }
722 else
723 {
724 //printf("replace '%s' by '%s'\n",qPrint(input.mid(i+4,j-i-4)),qPrint(it->second));
725 output.addStr(it->second); // add it value
726 }
727 p=j+1;
728 }
729 output.addStr(input.data()+p,input.length()-p);
730 output.addChar(0);
731 return output.get();
732 };
733
734 auto colorStyle = Config_getEnum(HTML_COLORSTYLE);
735 if (colorStyle==HTML_COLORSTYLE_t::LIGHT)
736 {
737 return doReplacements(g_lightMap);
738 }
739 else if (colorStyle==HTML_COLORSTYLE_t::DARK)
740 {
741 return doReplacements(g_darkMap);
742 }
743 else
744 {
745 return input;
746 }
747}
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 2769 of file htmlgen.cpp.

2772{
2773 t << " <li";
2774 if (hl)
2775 {
2776 t << " class=\"current\"";
2777 }
2778 t << ">";
2779 if (!l.isEmpty()) t << "<a href=\"" << correctURL(l,relPath) << "\">";
2780 t << "<span>";
2781}
QCString correctURL(const QCString &url, const QCString &relPath)
Corrects URL url according to the relative path relPath.
Definition util.cpp:5837

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

Referenced by renderQuickLinksAsTabs().

◆ startQuickIndexList()

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

Definition at line 2736 of file htmlgen.cpp.

2737{
2738 if (!Config_getBool(DISABLE_INDEX))
2739 {
2740 if (topLevel)
2741 {
2742 t << " <div id=\"navrow1\" class=\"tabs\">\n";
2743 }
2744 else
2745 {
2746 t << " <div id=\"navrow2\" class=\"tabs2\">\n";
2747 }
2748 t << " <ul class=\"tablist\">\n";
2749 }
2750 else
2751 {
2752 t << "<ul>";
2753 }
2754}

References Config_getBool, and TRUE.

Referenced by renderQuickLinksAsTabs(), and renderQuickLinksAsTree().

◆ startSectionContent()

void startSectionContent ( TextStream & t,
int sectionCount )
static

Definition at line 2050 of file htmlgen.cpp.

2051{
2052 //t << "<!-- startSectionContent -->";
2053 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
2054 if (dynamicSections)
2055 {
2056 t << "<div id=\"dynsection-" << sectionCount << "-content\" "
2057 "class=\"dyncontent\" "
2058 "style=\"display:none;\">\n";
2059 }
2060 else
2061 {
2062 t << "<div class=\"dyncontent\">\n";
2063 }
2064}

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 2003 of file htmlgen.cpp.

2005{
2006 //t << "<!-- startSectionHeader -->";
2007 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
2008 if (dynamicSections)
2009 {
2010 t << "<div id=\"dynsection-" << sectionCount << "\" "
2011 "onclick=\"return dynsection.toggleVisibility(this)\" "
2012 "class=\"dynheader closed\" "
2013 "style=\"cursor:pointer;\">"
2014 "<span class=\"dynarrow\"><span class=\"arrowhead closed\"></span></span>";
2015 }
2016 else
2017 {
2018 t << "<div class=\"dynheader\">\n";
2019 }
2020}

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 2028 of file htmlgen.cpp.

2029{
2030 //t << "<!-- startSectionSummary -->";
2031 bool dynamicSections = Config_getBool(HTML_DYNAMIC_SECTIONS);
2032 if (dynamicSections)
2033 {
2034 t << "<div id=\"dynsection-" << sectionCount << "-summary\" "
2035 "class=\"dynsummary\" "
2036 "style=\"display:block;\">\n";
2037 }
2038}

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(),
bool isSource = false )
static

Definition at line 324 of file htmlgen.cpp.

330{
331 // Build CSS/JavaScript tags depending on treeview, search engine settings
332 QCString cssFile;
333 QCString generatedBy;
334 QCString treeViewCssJs;
335 QCString searchCssJs;
336 QCString searchBox;
337 QCString mathJaxJs;
338 QCString extraCssText;
339
340 QCString projectName = Config_getString(PROJECT_NAME);
341 bool treeView = Config_getBool(GENERATE_TREEVIEW);
342 bool searchEngine = Config_getBool(SEARCHENGINE);
343 bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
344 bool mathJax = Config_getBool(USE_MATHJAX);
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;
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)+"\" 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 && !isSource)
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 auto writeMathJax3Packages = [&mathJaxJs](const StringVector &mathJaxExtensions)
466 {
467 mathJaxJs += " packages: ['base','configmacros'";
468 if (!g_latex_macro.isEmpty())
469 {
470 mathJaxJs+= ",'newcommand'";
471 }
472 for (const auto &s : mathJaxExtensions)
473 {
474 mathJaxJs+= ",'"+s+"'";
475 }
476 mathJaxJs += "]\n";
477 };
478
479 auto writeMathJax4Packages = [&mathJaxJs](const StringVector &mathJaxExtensions)
480 {
481 mathJaxJs += " packages: {\n";
482 bool first = true;
483 for (const auto &s : mathJaxExtensions)
484 {
485 if (!first) mathJaxJs+= ",";
486 if (s.at(0) =='-')
487 {
488 mathJaxJs+= "\n '[-]': ['";
489 mathJaxJs+=s.data()+1;
490 mathJaxJs+="']";
491 }
492 else
493 {
494 mathJaxJs+= "\n '[+]': ['"+s+"']";
495 }
496 first = false;
497 }
498 mathJaxJs += "\n }\n";
499 };
500
501 auto writeMathJaxScript = [&path,&mathJaxJs](const QCString &pathPostfix,
502 std::function<void(const StringVector&)> writePackages)
503 {
504 QCString mathJaxFormat = Config_getEnumAsString(MATHJAX_FORMAT);
505 mathJaxJs += "<script type=\"text/javascript\">\n"
506 "window.MathJax = {\n"
507 " options: {\n"
508 " ignoreHtmlClass: 'tex2jax_ignore',\n"
509 " processHtmlClass: 'tex2jax_process'\n"
510 " }";
511 // MACRO / EXT
512 const StringVector &mathJaxExtensions = Config_getList(MATHJAX_EXTENSIONS);
513 if (!mathJaxExtensions.empty() || !g_latex_macro.isEmpty())
514 {
515 mathJaxJs+= ",\n";
516 if (!mathJaxExtensions.empty())
517 {
518 bool first = true;
519 mathJaxJs+= " loader: {\n"
520 " load: [";
521 for (const auto &s : mathJaxExtensions)
522 {
523 if (s.at(0) !='-')
524 {
525 if (!first) mathJaxJs+= ",";
526 mathJaxJs+= "'[tex]/"+s+"'"; // packages preceded by a minus sign should not be loaded
527 first = false;
528 }
529 }
530 mathJaxJs+= "]\n"
531 " },\n";
532 }
533 mathJaxJs+= " tex: {\n"
534 " macros: {";
535 if (!g_latex_macro.isEmpty())
536 {
537 mathJaxJs += g_latex_macro+" ";
538 }
539 mathJaxJs+="},\n";
540 writePackages(mathJaxExtensions);
541 mathJaxJs += " }\n";
542 }
543 else
544 {
545 mathJaxJs += "\n";
546 }
547 mathJaxJs += "};\n";
548 // MATHJAX_CODEFILE
549 if (!g_mathjax_code.isEmpty())
550 {
551 mathJaxJs += g_mathjax_code;
552 mathJaxJs += "\n";
553 }
554 mathJaxJs+="</script>\n";
555 mathJaxJs += "<script type=\"text/javascript\" id=\"MathJax-script\" async=\"async\" src=\"" +
556 path + pathPostfix + "tex-" + mathJaxFormat.lower() + ".js\">";
557 mathJaxJs+="</script>\n";
558 };
559
560 switch (mathJaxVersion)
561 {
562 case MATHJAX_VERSION_t::MathJax_4:
563 writeMathJaxScript("",writeMathJax4Packages);
564 break;
565 case MATHJAX_VERSION_t::MathJax_3:
566 writeMathJaxScript("es5/",writeMathJax3Packages);
567 break;
568 case MATHJAX_VERSION_t::MathJax_2:
569 {
570 QCString mathJaxFormat = Config_getEnumAsString(MATHJAX_FORMAT);
571 mathJaxJs = "<script type=\"text/x-mathjax-config\">\n"
572 "MathJax.Hub.Config({\n"
573 " extensions: [\"tex2jax.js\"";
574 const StringVector &mathJaxExtensions = Config_getList(MATHJAX_EXTENSIONS);
575 for (const auto &s : mathJaxExtensions)
576 {
577 mathJaxJs+= ", \""+QCString(s)+".js\"";
578 }
579 if (mathJaxFormat.isEmpty())
580 {
581 mathJaxFormat = "HTML-CSS";
582 }
583 mathJaxJs += "],\n"
584 " jax: [\"input/TeX\",\"output/"+mathJaxFormat+"\"],\n";
585 if (!g_latex_macro.isEmpty())
586 {
587 mathJaxJs += " TeX: { Macros: {\n";
588 mathJaxJs += g_latex_macro;
589 mathJaxJs += "\n"
590 " } }\n";
591 }
592 mathJaxJs += "});\n";
593 if (!g_mathjax_code.isEmpty())
594 {
595 mathJaxJs += g_mathjax_code;
596 mathJaxJs += "\n";
597 }
598 mathJaxJs += "</script>\n";
599 mathJaxJs += "<script type=\"text/javascript\" async=\"async\" src=\"" + path + "MathJax.js\"></script>\n";
600 }
601 break;
602 }
603 }
604
605 QCString darkModeJs;
606 if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::TOGGLE)
607 {
608 darkModeJs="<script type=\"text/javascript\" src=\"$relpath^darkmode_toggle.js\"></script>\n";
609 }
610
611 if (hasCookie) // extend the $treeview tag to avoid breaking old files used with HTML_HEADER
612 {
613 treeViewCssJs+="<script type=\"text/javascript\" src=\"$relpath^cookie.js\"></script>\n";
614 }
615
616 // first substitute generic keywords
617 QCString result = substituteKeywords(file,str,title,
618 convertToHtml(Config_getString(PROJECT_NAME)),
619 convertToHtml(Config_getString(PROJECT_NUMBER)),
620 convertToHtml(Config_getString(PROJECT_BRIEF)));
621
622 // then do the HTML specific keywords
623 result = substituteKeywords(file,result,
624 {
625 // keyword value getter
626 { "$datetime", [&]() -> QCString { return "<span class=\"datetime\"></span>"; } },
627 { "$date", [&]() -> QCString { return "<span class=\"date\"></span>"; } },
628 { "$time", [&]() -> QCString { return "<span class=\"time\"></span>"; } },
629 { "$year", [&]() -> QCString { return "<span class=\"year\"></span>"; } },
630 { "$navpath", [&]() -> QCString { return navPath; } },
631 { "$stylesheet", [&]() -> QCString { return cssFile; } },
632 { "$treeview", [&]() -> QCString { return treeViewCssJs; } },
633 { "$searchbox", [&]() -> QCString { return searchBox; } },
634 { "$search", [&]() -> QCString { return searchCssJs; } },
635 { "$mathjax", [&]() -> QCString { return mathJaxJs; } },
636 { "$darkmode", [&]() -> QCString { return darkModeJs; } },
637 { "$generatedby", [&]() -> QCString { return generatedBy; } },
638 { "$extrastylesheet",[&]() -> QCString { return extraCssText; } },
639 { "$relpath$", [&]() -> QCString { return relPath; } } //<-- obsolete: for backwards compatibility only
640 });
641
642 result = substitute(result,"$relpath^",relPath); //<-- must be done after the previous substitutions
643
644 // remove conditional blocks
645 result = selectBlocks(result,
646 {
647 // keyword, is enabled
648 { "FULL_SIDEBAR", hasFullSideBar },
649 { "DISABLE_INDEX", disableIndex },
650 { "GENERATE_TREEVIEW", treeView },
651 { "SEARCHENGINE", searchEngine },
652 { "TITLEAREA", titleArea },
653 { "PROJECT_NAME", hasProjectName },
654 { "PROJECT_NUMBER", hasProjectNumber },
655 { "PROJECT_BRIEF", hasProjectBrief },
656 { "PROJECT_LOGO", hasProjectLogo },
657 { "PROJECT_ICON", hasProjectIcon },
658 { "COPY_CLIPBOARD", hasCopyClipboard },
660
661 result = removeEmptyLines(result);
662
663 return result;
664}
QCString & prepend(const char *s)
Definition qcstring.h:422
QCString lower() const
Definition qcstring.h:249
#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:482
QCString convertToHtml(const QCString &s, bool keepEntities)
Definition util.cpp:3884
QCString stripPath(const QCString &s)
Definition util.cpp:4850
QCString removeEmptyLines(const QCString &s)
Definition util.cpp:6496
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:6319
QCString substituteKeywords(const QCString &file, const QCString &s, const KeywordSubstitutionList &keywords)
Definition util.cpp:2981

References Config_getBool, Config_getEnum, Config_getEnumAsString, Config_getList, Config_getString, convertToHtml(), QCString::data(), 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 2945 of file htmlgen.cpp.

2950{
2951 bool serverBasedSearch = Config_getBool(SERVER_BASED_SEARCH);
2952 bool searchEngine = Config_getBool(SEARCHENGINE);
2953 bool externalSearch = Config_getBool(EXTERNAL_SEARCH);
2954 bool generateTreeView = Config_getBool(GENERATE_TREEVIEW);
2955 bool fullSidebar = Config_getBool(FULL_SIDEBAR);
2956 bool disableIndex = Config_getBool(DISABLE_INDEX);
2957 bool dynamicMenus = Config_getBool(HTML_DYNAMIC_MENUS);
2959 LayoutNavEntry::Kind kind = LayoutNavEntry::None;
2960 LayoutNavEntry::Kind altKind = LayoutNavEntry::None; // fall back for the old layout file
2961 bool highlightParent=false;
2962 switch (hli) // map HLI enums to LayoutNavEntry::Kind enums
2963 {
2964 case HighlightedItem::Main: kind = LayoutNavEntry::MainPage; break;
2965 case HighlightedItem::Topics: kind = LayoutNavEntry::Topics; break;
2966 case HighlightedItem::Modules: kind = LayoutNavEntry::ModuleList; altKind = LayoutNavEntry::Modules; break;
2967 case HighlightedItem::Namespaces: kind = LayoutNavEntry::NamespaceList; altKind = LayoutNavEntry::Namespaces; break;
2968 case HighlightedItem::ClassHierarchy: kind = LayoutNavEntry::ClassHierarchy; break;
2969 case HighlightedItem::InterfaceHierarchy: kind = LayoutNavEntry::InterfaceHierarchy; break;
2970 case HighlightedItem::ExceptionHierarchy: kind = LayoutNavEntry::ExceptionHierarchy; break;
2971 case HighlightedItem::Classes: kind = LayoutNavEntry::ClassIndex; altKind = LayoutNavEntry::Classes; break;
2972 case HighlightedItem::Concepts: kind = LayoutNavEntry::Concepts; break;
2973 case HighlightedItem::Interfaces: kind = LayoutNavEntry::InterfaceIndex; altKind = LayoutNavEntry::Interfaces; break;
2974 case HighlightedItem::Structs: kind = LayoutNavEntry::StructIndex; altKind = LayoutNavEntry::Structs; break;
2975 case HighlightedItem::Exceptions: kind = LayoutNavEntry::ExceptionIndex; altKind = LayoutNavEntry::Exceptions; break;
2976 case HighlightedItem::AnnotatedClasses: kind = LayoutNavEntry::ClassList; altKind = LayoutNavEntry::Classes; break;
2977 case HighlightedItem::AnnotatedInterfaces: kind = LayoutNavEntry::InterfaceList; altKind = LayoutNavEntry::Interfaces; break;
2978 case HighlightedItem::AnnotatedStructs: kind = LayoutNavEntry::StructList; altKind = LayoutNavEntry::Structs; break;
2979 case HighlightedItem::AnnotatedExceptions: kind = LayoutNavEntry::ExceptionList; altKind = LayoutNavEntry::Exceptions; break;
2980 case HighlightedItem::Files: kind = LayoutNavEntry::FileList; altKind = LayoutNavEntry::Files; break;
2981 case HighlightedItem::NamespaceMembers: kind = LayoutNavEntry::NamespaceMembers; break;
2982 case HighlightedItem::ModuleMembers: kind = LayoutNavEntry::ModuleMembers; break;
2983 case HighlightedItem::Functions: kind = LayoutNavEntry::ClassMembers; break;
2984 case HighlightedItem::Globals: kind = LayoutNavEntry::FileGlobals; break;
2985 case HighlightedItem::Pages: kind = LayoutNavEntry::Pages; break;
2986 case HighlightedItem::Examples: kind = LayoutNavEntry::Examples; break;
2987 case HighlightedItem::UserGroup: kind = LayoutNavEntry::UserGroup; break;
2988 case HighlightedItem::ClassVisible: kind = LayoutNavEntry::ClassList; altKind = LayoutNavEntry::Classes;
2989 highlightParent = true; break;
2990 case HighlightedItem::ConceptVisible: kind = LayoutNavEntry::Concepts;
2991 highlightParent = true; break;
2992 case HighlightedItem::ModuleVisible: kind = LayoutNavEntry::ModuleList; altKind = LayoutNavEntry::Modules;
2993 highlightParent = true; break;
2994 case HighlightedItem::InterfaceVisible: kind = LayoutNavEntry::InterfaceList; altKind = LayoutNavEntry::Interfaces;
2995 highlightParent = true; break;
2996 case HighlightedItem::StructVisible: kind = LayoutNavEntry::StructList; altKind = LayoutNavEntry::Structs;
2997 highlightParent = true; break;
2998 case HighlightedItem::ExceptionVisible: kind = LayoutNavEntry::ExceptionList; altKind = LayoutNavEntry::Exceptions;
2999 highlightParent = true; break;
3000 case HighlightedItem::NamespaceVisible: kind = LayoutNavEntry::NamespaceList; altKind = LayoutNavEntry::Namespaces;
3001 highlightParent = true; break;
3002 case HighlightedItem::FileVisible: kind = LayoutNavEntry::FileList; altKind = LayoutNavEntry::Files;
3003 highlightParent = true; break;
3004 case HighlightedItem::None: break;
3005 case HighlightedItem::Search: break;
3006 }
3007
3008 if (!disableIndex && dynamicMenus)
3009 {
3010 QCString searchPage;
3011 if (externalSearch)
3012 {
3013 searchPage = "search" + Doxygen::htmlFileExtension;
3014 }
3015 else
3016 {
3017 searchPage = "search.php";
3018 }
3019 t << "<script type=\"text/javascript\" src=\"" << relPath << "menudata.js\"></script>\n";
3020 t << "<script type=\"text/javascript\" src=\"" << relPath << "menu.js\"></script>\n";
3021 t << "<script type=\"text/javascript\">\n";
3022 t << "$(function() {\n";
3023 t << " initMenu('" << relPath << "',"
3024 << (searchEngine && !(generateTreeView && fullSidebar)?"true":"false") << ","
3025 << (serverBasedSearch?"true":"false") << ",'"
3026 << searchPage << "','"
3027 << theTranslator->trSearch() << "',"
3028 << (generateTreeView?"true":"false")
3029 << ");\n";
3030 if (searchEngine)
3031 {
3032 if (!serverBasedSearch)
3033 {
3034 if (!disableIndex && dynamicMenus && !fullSidebar)
3035 {
3036 t << " $(function() { init_search(); });\n";
3037 }
3038 }
3039 else
3040 {
3041 t << " $(function() {\n"
3042 << " if ($('.searchresults').length > 0) { searchBox.DOMSearchField().focus(); }\n";
3043 t << " });\n";
3044 }
3045 }
3046 t << "});\n";
3047 t << "</script>\n";
3048 t << "<div id=\"main-nav\"></div>\n";
3049 }
3050 else if (!disableIndex) // && !Config_getBool(HTML_DYNAMIC_MENUS)
3051 {
3052 // find highlighted index item
3053 LayoutNavEntry *hlEntry = root->find(kind,kind==LayoutNavEntry::UserGroup ? file : QCString());
3054 if (!hlEntry && altKind!=LayoutNavEntry::None) { hlEntry=root->find(altKind); kind=altKind; }
3055 if (!hlEntry) // highlighted item not found in the index! -> just show the level 1 index...
3056 {
3057 highlightParent=TRUE;
3058 hlEntry = root->children().front().get();
3059 if (hlEntry==nullptr)
3060 {
3061 return; // argl, empty index!
3062 }
3063 }
3064 if (kind==LayoutNavEntry::UserGroup)
3065 {
3066 LayoutNavEntry *e = hlEntry->children().front().get();
3067 if (e)
3068 {
3069 hlEntry = e;
3070 }
3071 }
3072 t << "<div id=\"main-nav\">\n";
3073 renderQuickLinksAsTabs(t,relPath,hlEntry,kind,highlightParent,hli==HighlightedItem::Search);
3074 if (!extraTabs)
3075 {
3076 t << "</div><!-- main-nav -->\n";
3077 }
3078 }
3079 else if (!generateTreeView)
3080 {
3081 renderQuickLinksAsTree(t,relPath,root);
3082 }
3083 if (generateTreeView && !disableIndex && fullSidebar && !extraTabs)
3084 {
3085 t << "<div id=\"container\"><div id=\"doc-content\">\n";
3086 }
3087}
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 1408 of file htmlgen.cpp.

1409{
1410 t << "/* The standard CSS for doxygen " << getDoxygenVersion() << "*/\n\n";
1411 switch (Config_getEnum(HTML_COLORSTYLE))
1412 {
1413 case HTML_COLORSTYLE_t::LIGHT:
1414 case HTML_COLORSTYLE_t::DARK:
1415 /* variables will be resolved while writing to the CSS file */
1416 break;
1417 case HTML_COLORSTYLE_t::AUTO_LIGHT:
1418 case HTML_COLORSTYLE_t::TOGGLE:
1419 t << "html {\n";
1420 t << replaceColorMarkers(ResourceMgr::instance().getAsString("lightmode_settings.css"));
1421 t << "}\n\n";
1422 break;
1423 case HTML_COLORSTYLE_t::AUTO_DARK:
1424 t << "html {\n";
1425 t << replaceColorMarkers(ResourceMgr::instance().getAsString("darkmode_settings.css"));
1426 t << "}\n\n";
1427 break;
1428 }
1429 if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::AUTO_LIGHT)
1430 {
1431 t << "@media (prefers-color-scheme: dark) {\n";
1432 t << " html:not(.dark-mode) {\n";
1433 t << " color-scheme: dark;\n\n";
1434 t << replaceColorMarkers(ResourceMgr::instance().getAsString("darkmode_settings.css"));
1435 t << "}}\n";
1436 }
1437 else if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::AUTO_DARK)
1438 {
1439 t << "@media (prefers-color-scheme: light) {\n";
1440 t << " html:not(.light-mode) {\n";
1441 t << " color-scheme: light;\n\n";
1442 t << replaceColorMarkers(ResourceMgr::instance().getAsString("lightmode_settings.css"));
1443 t << "}}\n";
1444 }
1445 else if (Config_getEnum(HTML_COLORSTYLE)==HTML_COLORSTYLE_t::TOGGLE)
1446 {
1447 t << "html.dark-mode {\n";
1448 t << replaceColorMarkers(ResourceMgr::instance().getAsString("darkmode_settings.css"));
1449 t << "}\n\n";
1450 }
1451
1452 QCString cssStr = ResourceMgr::instance().getAsString("doxygen.css");
1453 bool hasFullSidebar = Config_getBool(FULL_SIDEBAR) && Config_getBool(GENERATE_TREEVIEW);
1454 if (hasFullSidebar)
1455 {
1456 cssStr+="\n"
1457 "#titlearea {\n"
1458 " border-bottom: none;\n"
1459 " background-color: var(--nav-background-color);\n"
1460 " border-right: 1px solid var(--nav-border-color);\n"
1461 "}\n";
1462 }
1463 t << replaceVariables(cssStr);
1464
1465 bool addTimestamp = Config_getEnum(TIMESTAMP)!=TIMESTAMP_t::NO;
1466 if (g_build_date || addTimestamp)
1467 {
1468 t << "\nhtml {\n";
1469
1470 if (addTimestamp)
1471 {
1472 QCString timeStampStr;
1473 switch (Config_getEnum(TIMESTAMP))
1474 {
1475 case TIMESTAMP_t::YES:
1476 case TIMESTAMP_t::DATETIME:
1477 timeStampStr = dateToString(DateTimeType::DateTime);
1478 break;
1479 case TIMESTAMP_t::DATE:
1480 timeStampStr = dateToString(DateTimeType::Date);
1481 break;
1482 default:
1483 break;
1484 }
1485 t << "--timestamp: '" << timeStampStr << "';\n";
1486 }
1487 if (g_build_date)
1488 {
1489 t << "--datetime: '" << dateToString(DateTimeType::DateTime) << "';\n";
1490 t << "--date: '" << dateToString(DateTimeType::Date) << "';\n";
1491 t << "--time: '" << dateToString(DateTimeType::Time) << "';\n";
1492 t << "--year: '" << yearToString() << "';\n";
1493 }
1494 t << "}\n";
1495
1496 if (addTimestamp)
1497 {
1498 t << "span.timestamp { content: ' '; }\n";
1499 t << "span.timestamp:before { content: var(--timestamp); }\n\n";
1500 }
1501 if (g_build_date)
1502 {
1503 t << "span.datetime { content: ' '; }\n";
1504 t << "span.datetime:before { content: var(--datetime); }\n\n";
1505 t << "span.date { content: ' '; }\n";
1506 t << "span.date:before { content: var(--date); }\n\n";
1507 t << "span.time { content: ' '; }\n";
1508 t << "span.time:before { content: var(--time); }\n\n";
1509 t << "span.year { content: ' '; }\n";
1510 t << "span.year:before { content: var(--year); }\n\n";
1511 }
1512 }
1513
1514 // For Webkit based the scrollbar styling cannot be overruled (bug in chromium?).
1515 // To allow the user to style the scrollbars differently we should only add it in case
1516 // the user did not specify any extra stylesheets.
1517 bool addScrollbarStyling = Config_getList(HTML_EXTRA_STYLESHEET).empty();
1518 if (addScrollbarStyling)
1519 {
1520 t << replaceVariables(ResourceMgr::instance().getAsString("scrollbar.css"));
1521 }
1522
1523}
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:706

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 669 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 1543 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 668 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().