summaryrefslogtreecommitdiffstats
path: root/src/htmlgen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/htmlgen.cpp')
-rw-r--r--src/htmlgen.cpp127
1 files changed, 78 insertions, 49 deletions
diff --git a/src/htmlgen.cpp b/src/htmlgen.cpp
index 601c02e..cd615e4 100644
--- a/src/htmlgen.cpp
+++ b/src/htmlgen.cpp
@@ -16,8 +16,10 @@
*/
#include <stdlib.h>
-
#include <assert.h>
+
+#include <mutex>
+
#include <qdir.h>
#include <qregexp.h>
#include "message.h"
@@ -58,8 +60,7 @@ static QCString g_header;
static QCString g_footer;
static QCString g_mathjax_code;
static QCString g_latex_macro;
-
-static bool DoxyCodeLineOpen = FALSE;
+static const char *hex="0123456789ABCDEF";
// note: this is only active if DISABLE_INDEX=YES, if DISABLE_INDEX is disabled, this
// part will be rendered inside menu.js
@@ -608,12 +609,11 @@ static QCString substituteHtmlKeywords(const QCString &str,
//--------------------------------------------------------------------------
HtmlCodeGenerator::HtmlCodeGenerator()
- : m_streamSet(FALSE), m_col(0)
{
}
HtmlCodeGenerator::HtmlCodeGenerator(FTextStream &t,const QCString &relPath)
- : m_col(0), m_relPath(relPath)
+ : m_relPath(relPath)
{
setTextStream(t);
}
@@ -673,9 +673,21 @@ void HtmlCodeGenerator::codify(const char *str)
m_t << "\\";
m_col++;
break;
- default: p=writeUtf8Char(m_t,p-1);
- m_col++;
- break;
+ default:
+ {
+ uchar uc = static_cast<uchar>(c);
+ if (uc<32)
+ {
+ m_t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
+ m_col++;
+ }
+ else
+ {
+ p=writeUtf8Char(m_t,p-1);
+ m_col++;
+ }
+ }
+ break;
}
}
}
@@ -699,18 +711,30 @@ void HtmlCodeGenerator::docify(const char *str)
case '&': m_t << "&amp;"; break;
case '"': m_t << "&quot;"; break;
case '\\':
- if (*p=='<')
- { m_t << "&lt;"; p++; }
- else if (*p=='>')
- { m_t << "&gt;"; p++; }
- else if (*p=='(')
- { m_t << "\\&zwj;("; p++; }
- else if (*p==')')
- { m_t << "\\&zwj;)"; p++; }
- else
- m_t << "\\";
- break;
- default: m_t << c;
+ if (*p=='<')
+ { m_t << "&lt;"; p++; }
+ else if (*p=='>')
+ { m_t << "&gt;"; p++; }
+ else if (*p=='(')
+ { m_t << "\\&zwj;("; p++; }
+ else if (*p==')')
+ { m_t << "\\&zwj;)"; p++; }
+ else
+ m_t << "\\";
+ break;
+ default:
+ {
+ uchar uc = static_cast<uchar>(c);
+ if (uc<32 && !isspace(c))
+ {
+ m_t << "&#x24" << hex[uc>>4] << hex[uc&0xF] << ";";
+ }
+ else
+ {
+ m_t << c;
+ }
+ }
+ break;
}
}
}
@@ -726,10 +750,10 @@ void HtmlCodeGenerator::writeLineNumber(const char *ref,const char *filename,
qsnprintf(lineNumber,maxLineNrStr,"%5d",l);
qsnprintf(lineAnchor,maxLineNrStr,"l%05d",l);
- if (!DoxyCodeLineOpen)
+ if (!m_lineOpen)
{
m_t << "<div class=\"line\">";
- DoxyCodeLineOpen = TRUE;
+ m_lineOpen = TRUE;
}
m_t << "<a name=\"" << lineAnchor << "\"></a><span class=\"lineno\">";
@@ -868,10 +892,10 @@ void HtmlCodeGenerator::startCodeLine(bool)
if (m_streamSet)
{
m_col=0;
- if (!DoxyCodeLineOpen)
+ if (!m_lineOpen)
{
m_t << "<div class=\"line\">";
- DoxyCodeLineOpen = TRUE;
+ m_lineOpen = TRUE;
}
}
}
@@ -885,10 +909,10 @@ void HtmlCodeGenerator::endCodeLine()
m_t << " ";
m_col++;
}
- if (DoxyCodeLineOpen)
+ if (m_lineOpen)
{
m_t << "</div>\n";
- DoxyCodeLineOpen = FALSE;
+ m_lineOpen = FALSE;
}
}
}
@@ -908,6 +932,20 @@ void HtmlCodeGenerator::writeCodeAnchor(const char *anchor)
if (m_streamSet) m_t << "<a name=\"" << anchor << "\"></a>";
}
+void HtmlCodeGenerator::startCodeFragment(const char *)
+{
+ if (m_streamSet) m_t << "<div class=\"fragment\">";
+}
+
+void HtmlCodeGenerator::endCodeFragment(const char *)
+{
+ //endCodeLine checks is there is still an open code line, if so closes it.
+ endCodeLine();
+
+ if (m_streamSet) m_t << "</div><!-- fragment -->";
+}
+
+
//--------------------------------------------------------------------------
HtmlGenerator::HtmlGenerator() : OutputGenerator(Config_getString(HTML_OUTPUT))
@@ -1114,8 +1152,10 @@ void HtmlGenerator::writeFooterFile(QFile &file)
t << ResourceMgr::instance().getAsString("footer.html");
}
+static std::mutex g_indexLock;
+
void HtmlGenerator::startFile(const char *name,const char *,
- const char *title)
+ const char *title,int id)
{
//printf("HtmlGenerator::startFile(%s)\n",name);
m_relPath = relativePathToRoot(name);
@@ -1123,9 +1163,13 @@ void HtmlGenerator::startFile(const char *name,const char *,
m_lastTitle=title;
startPlainFile(fileName);
+ m_codeGen.setId(id);
m_codeGen.setTextStream(t);
m_codeGen.setRelativePath(m_relPath);
- Doxygen::indexList->addIndexFile(fileName);
+ {
+ std::lock_guard<std::mutex> lock(g_indexLock);
+ Doxygen::indexList->addIndexFile(fileName);
+ }
m_lastFile = fileName;
t << substituteHtmlKeywords(g_header,convertToHtml(filterTitle(title)),m_relPath);
@@ -1139,7 +1183,7 @@ void HtmlGenerator::startFile(const char *name,const char *,
t << "<script type=\"text/javascript\">\n";
t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */\n";
t << "var searchBox = new SearchBox(\"searchBox\", \""
- << m_relPath<< "search\",false,'" << theTranslator->trSearch() << "');\n";
+ << m_relPath<< "search\",false,'" << theTranslator->trSearch() << "','" << Doxygen::htmlFileExtension << "');\n";
t << "/* @license-end */\n";
t << "</script>\n";
}
@@ -1191,7 +1235,7 @@ QCString HtmlGenerator::writeLogoAsString(const char *path)
{
result += theTranslator->trGeneratedBy();
}
- result += "&#160;\n<a href=\"http://www.doxygen.org/index.html\">\n"
+ result += "&#160;\n<a href=\"https://www.doxygen.org/index.html\">\n"
"<img class=\"footer\" src=\"";
result += path;
result += "doxygen.svg\" width=\"104\" height=\"31\" alt=\"doxygen\"/></a> ";
@@ -1213,9 +1257,6 @@ void HtmlGenerator::writePageFooter(FTextStream &t,const QCString &lastTitle,
void HtmlGenerator::writeFooter(const char *navPath)
{
- // Currently only tooltips in HTML
- TooltipManager::instance()->writeTooltips(m_codeGen);
-
writePageFooter(t,m_lastTitle,m_relPath,navPath);
}
@@ -2223,8 +2264,9 @@ void HtmlGenerator::endParamList()
t << "</dl>";
}
-void HtmlGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *)
+void HtmlGenerator::writeDoc(DocNode *n,const Definition *ctx,const MemberDef *,int id)
{
+ m_codeGen.setId(id);
HtmlDocVisitor *visitor = new HtmlDocVisitor(t,m_codeGen,ctx);
n->accept(visitor);
delete visitor;
@@ -2674,7 +2716,7 @@ void HtmlGenerator::writeSearchPage()
t << "<script type=\"text/javascript\">\n";
t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */\n";
t << "var searchBox = new SearchBox(\"searchBox\", \""
- << "search\",false,'" << theTranslator->trSearch() << "');\n";
+ << "search\",false,'" << theTranslator->trSearch() << "','" << Doxygen::htmlFileExtension << "');\n";
t << "/* @license-end */\n";
t << "</script>\n";
if (!Config_getBool(DISABLE_INDEX))
@@ -2728,7 +2770,7 @@ void HtmlGenerator::writeExternalSearchPage()
t << "<script type=\"text/javascript\">\n";
t << "/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */\n";
t << "var searchBox = new SearchBox(\"searchBox\", \""
- << "search\",false,'" << theTranslator->trSearch() << "');\n";
+ << "search\",false,'" << theTranslator->trSearch() << "','" << Doxygen::htmlFileExtension << "');\n";
t << "/* @license-end */\n";
t << "</script>\n";
if (!Config_getBool(DISABLE_INDEX))
@@ -2861,19 +2903,6 @@ void HtmlGenerator::endConstraintList()
t << "</div>" << endl;
}
-void HtmlGenerator::startCodeFragment()
-{
- t << PREFRAG_START;
-}
-
-void HtmlGenerator::endCodeFragment()
-{
- //endCodeLine checks is there is still an open code line, if so closes it.
- endCodeLine();
-
- t << PREFRAG_END;
-}
-
void HtmlGenerator::lineBreak(const char *style)
{
if (style)