diff options
Diffstat (limited to 'src/qdoc/htmlgenerator.cpp')
-rw-r--r-- | src/qdoc/htmlgenerator.cpp | 111 |
1 files changed, 44 insertions, 67 deletions
diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index 055a40229..e293b5aae 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -72,7 +72,7 @@ static void addLink(const QString &linkTarget, const QStringRef &nestedStuff, QS if (!linkTarget.isEmpty()) { *res += QLatin1String("<a href=\""); *res += linkTarget; - *res += QLatin1String("\">"); + *res += QLatin1String("\" translate=\"no\">"); *res += nestedStuff; *res += QLatin1String("</a>"); } else { @@ -118,12 +118,12 @@ void HtmlGenerator::initializeGenerator() } defaults[] = { { ATOM_FORMATTING_BOLD, "<b>", "</b>" }, { ATOM_FORMATTING_INDEX, "<!--", "-->" }, { ATOM_FORMATTING_ITALIC, "<i>", "</i>" }, - { ATOM_FORMATTING_PARAMETER, "<i>", "</i>" }, + { ATOM_FORMATTING_PARAMETER, "<i translate=\"no\">", "</i>" }, { ATOM_FORMATTING_SUBSCRIPT, "<sub>", "</sub>" }, { ATOM_FORMATTING_SUPERSCRIPT, "<sup>", "</sup>" }, - { ATOM_FORMATTING_TELETYPE, "<code>", + { ATOM_FORMATTING_TELETYPE, "<code translate=\"no\">", "</code>" }, // <tt> tag is not supported in HTML5 - { ATOM_FORMATTING_UICONTROL, "<b>", "</b>" }, + { ATOM_FORMATTING_UICONTROL, "<b translate=\"no\">", "</b>" }, { ATOM_FORMATTING_UNDERLINE, "<u>", "</u>" }, { nullptr, nullptr, nullptr } }; @@ -538,7 +538,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark } break; case Atom::Qml: - out() << "<pre class=\"qml\">" + out() << "<pre class=\"qml\" translate=\"no\">" << trimmedTrailing(highlightedCode(indent(codeIndent, atom->string()), relative, false, Node::QML), codePrefix, codeSuffix) @@ -555,7 +555,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << "<p>you can rewrite it as</p>\n"; Q_FALLTHROUGH(); case Atom::Code: - out() << "<pre class=\"cpp\">" + out() << "<pre class=\"cpp\" translate=\"no\">" << trimmedTrailing(highlightedCode(indent(codeIndent, atom->string()), relative), codePrefix, codeSuffix) << "</pre>\n"; @@ -564,7 +564,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << "<p>For example, if you have code like</p>\n"; Q_FALLTHROUGH(); case Atom::CodeBad: - out() << "<pre class=\"cpp plain\">" + out() << "<pre class=\"cpp plain\" translate=\"no\">" << trimmedTrailing(protectEnc(plainCode(indent(codeIndent, atom->string()))), codePrefix, codeSuffix) << "</pre>\n"; @@ -750,7 +750,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark NodeVector nv = map->values().toVector(); out() << "<p>Class "; - out() << "<a href=\"" << linkForNode(map.key(), relative) << "\">"; + out() << "<a href=\"" << linkForNode(map.key(), relative) << "\" translate=\"no\">"; QStringList pieces = map.key()->fullName().split("::"); out() << protectEnc(pieces.last()); out() << "</a>" @@ -931,7 +931,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark QPair<QString, int> pair = getAtomListValue(atom); skipAhead = pair.second; QString t = protectEnc(plainCode(marker->markedUpEnumValue(pair.first, relative))); - out() << "<tr><td class=\"topAlign\"><code>" << t << "</code>"; + out() << "<tr><td class=\"topAlign\"><code translate=\"no\">" << t << "</code>"; if (relative->isEnumType()) { out() << "</td><td class=\"topAlign tblval\">"; @@ -940,7 +940,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark if (itemValue.isEmpty()) out() << '?'; else - out() << "<code>" << protectEnc(itemValue) << "</code>"; + out() << "<code translate=\"no\">" << protectEnc(itemValue) << "</code>"; } } break; @@ -1126,7 +1126,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark out() << "<b class=\"redFont\"><Missing HTML></b>"; break; case Atom::UnknownCommand: - out() << "<b class=\"redFont\"><code>\\" << protectEnc(atom->string()) << "</code></b>"; + out() << "<b class=\"redFont\"><code translate=\"no\">\\" << protectEnc(atom->string()) << "</code></b>"; break; case Atom::QmlText: case Atom::EndQmlText: @@ -1302,7 +1302,6 @@ void HtmlGenerator::generateCppReferencePage(Aggregate *aggregate, CodeMarker *m generateBody(aggregate, marker); out() << "</div>\n"; // QTBUG-9504 generateAlsoList(aggregate, marker); - generateMaintainerList(aggregate, marker); generateExtractionMark(aggregate, EndMark); } @@ -1406,7 +1405,6 @@ void HtmlGenerator::generateProxyPage(Aggregate *aggregate, CodeMarker *marker) generateBody(aggregate, marker); out() << "</div>\n"; // QTBUG-9504 generateAlsoList(aggregate, marker); - generateMaintainerList(aggregate, marker); generateExtractionMark(aggregate, EndMark); } @@ -1970,14 +1968,18 @@ void HtmlGenerator::generateTitle(const QString &title, const Text &subtitle, CodeMarker *marker) { out() << QString(prologue).replace("\\" + COMMAND_VERSION, qdb_->version()); + QString attribute; + if (relative->genus() != Node::DontCare && relative->genus() != Node::DOC) + attribute = R"( translate="no")"; + if (!title.isEmpty()) - out() << "<h1 class=\"title\">" << protectEnc(title) << "</h1>\n"; + out() << "<h1 class=\"title\"" << attribute << ">" << protectEnc(title) << "</h1>\n"; if (!subtitle.isEmpty()) { out() << "<span"; if (subTitleSize == SmallSubTitle) - out() << " class=\"small-subtitle\">"; + out() << " class=\"small-subtitle\"" << attribute << ">"; else - out() << " class=\"subtitle\">"; + out() << " class=\"subtitle\"" << attribute << ">"; generateText(subtitle, relative, marker); out() << "</span>\n"; } @@ -2090,10 +2092,9 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker) if (!requisites.isEmpty()) { // generate the table - out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; + out() << "<div class=\"table\"><table class=\"alignedsummary\" translate=\"no\">\n"; for (auto it = requisiteorder.constBegin(); it != requisiteorder.constEnd(); ++it) { - if (requisites.contains(*it)) { out() << "<tr>" << "<td class=\"memItemLeft rightAlign topAlign\"> " << *it @@ -2201,7 +2202,7 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) if (!requisites.isEmpty()) { // generate the table - out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; + out() << "<div class=\"table\"><table class=\"alignedsummary\" translate=\"no\">\n"; for (const auto &requisite : requisiteorder) { if (requisites.contains(requisite)) { @@ -2423,7 +2424,7 @@ QString HtmlGenerator::generateAllQmlMembersFile(const Sections §ions, CodeM continue; std::function<void(Node *)> generate = [&](Node *n) { - out() << "<li class=\"fn\">"; + out() << "<li class=\"fn\" translate=\"no\">"; generateQmlItem(n, aggregate, marker, true); if (n->isDefault()) out() << " [default]"; @@ -2472,7 +2473,7 @@ QString HtmlGenerator::generateObsoleteMembersFile(const Sections §ions, Cod generateTitle(title, Text(), SmallSubTitle, aggregate, marker); out() << "<p><b>The following members of class " - << "<a href=\"" << linkForNode(aggregate, nullptr) << "\">" + << "<a href=\"" << linkForNode(aggregate, nullptr) << "\" translate=\"no\">" << protectEnc(aggregate->name()) << "</a>" << " are obsolete.</b> " << "They are provided to keep old source code working. " @@ -2633,7 +2634,7 @@ void HtmlGenerator::generateAnnotatedList(const Node *relative, CodeMarker *mark out() << "<tr class=\"odd topAlign\">"; else out() << "<tr class=\"even topAlign\">"; - out() << "<td class=\"tblName\"><p>"; + out() << "<td class=\"tblName\" translate=\"no\"><p>"; generateFullName(node, relative); out() << "</p></td>"; @@ -2746,7 +2747,7 @@ void HtmlGenerator::generateCompactList(ListType listType, const Node *relative, Output the alphabet as a row of links. */ if (includeAlphabet) { - out() << "<p class=\"centerAlign functionIndex\"><b>"; + out() << "<p class=\"centerAlign functionIndex\" translate=\"no\"><b>"; for (int i = 0; i < 26; i++) { QChar ch('a' + i); if (usedParagraphNames.contains(char('a' + i))) @@ -2758,7 +2759,7 @@ void HtmlGenerator::generateCompactList(ListType listType, const Node *relative, /* Output a <div> element to contain all the <dl> elements. */ - out() << "<div class=\"flowListDiv\">\n"; + out() << "<div class=\"flowListDiv\" translate=\"no\">\n"; numTableRows_ = 0; int curParNr = 0; @@ -2853,7 +2854,7 @@ void HtmlGenerator::generateCompactList(ListType listType, const Node *relative, void HtmlGenerator::generateFunctionIndex(const Node *relative) { - out() << "<p class=\"centerAlign functionIndex\"><b>"; + out() << "<p class=\"centerAlign functionIndex\" translate=\"no\"><b>"; for (int i = 0; i < 26; i++) { QChar ch('a' + i); out() << QString("<a href=\"#%1\">%2</a> ").arg(ch).arg(ch.toUpper()); @@ -2863,7 +2864,7 @@ void HtmlGenerator::generateFunctionIndex(const Node *relative) char nextLetter = 'a'; char currentLetter; - out() << "<ul>\n"; + out() << "<ul translate=\"no\">\n"; NodeMapMap &funcIndex = qdb_->getFunctionIndex(); for (auto fnMap = funcIndex.constBegin(); fnMap != funcIndex.constEnd(); ++fnMap) { out() << "<li>"; @@ -3002,10 +3003,10 @@ void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, alignNames = false; } if (alignNames) { - out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; + out() << "<div class=\"table\"><table class=\"alignedsummary\" translate=\"no\">\n"; } else { if (twoColumn) - out() << "<div class=\"table\"><table class=\"propsummary\">\n" + out() << "<div class=\"table\"><table class=\"propsummary\" translate=\"no\">\n" << "<tr><td class=\"topAlign\">"; out() << "<ul>\n"; } @@ -3020,7 +3021,7 @@ void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, } else { if (twoColumn && i == (nv.count() + 1) / 2) out() << "</ul></td><td class=\"topAlign\"><ul>\n"; - out() << "<li class=\"fn\">"; + out() << "<li class=\"fn\" translate=\"no\">"; } generateSynopsis(member, relative, marker, Section::Summary, alignNames); @@ -3058,10 +3059,10 @@ void HtmlGenerator::generateSectionList(const Section §ion, const Node *rela alignNames = false; } if (alignNames) { - out() << "<div class=\"table\"><table class=\"alignedsummary\">\n"; + out() << "<div class=\"table\"><table class=\"alignedsummary\" translate=\"no\">\n"; } else { if (twoColumn) - out() << "<div class=\"table\"><table class=\"propsummary\">\n" + out() << "<div class=\"table\"><table class=\"propsummary\" translate=\"no\">\n" << "<tr><td class=\"topAlign\">"; out() << "<ul>\n"; } @@ -3076,7 +3077,7 @@ void HtmlGenerator::generateSectionList(const Section §ion, const Node *rela } else { if (twoColumn && i == (members.count() + 1) / 2) out() << "</ul></td><td class=\"topAlign\"><ul>\n"; - out() << "<li class=\"fn\">"; + out() << "<li class=\"fn\" translate=\"no\">"; } QString prefix; @@ -3131,7 +3132,7 @@ void HtmlGenerator::generateSectionInheritedList(const Section §ion, const N { const QVector<QPair<Aggregate *, int>> &inheritedMembers = section.inheritedMembers(); for (const auto &member : inheritedMembers) { - out() << "<li class=\"fn\">"; + out() << "<li class=\"fn\" translate=\"no\">"; out() << member.second << ' '; if (member.second == 1) { out() << section.singular(); @@ -3170,7 +3171,7 @@ void HtmlGenerator::generateSynopsis(const Node *node, const Node *relative, Cod extraRegExp.setMinimal(true); marked.remove(extraRegExp); } else { - marked.replace("<@extra>", "<code>"); + marked.replace("<@extra>", "<code translate=\"no\">"); marked.replace("</@extra>", "</code>"); } @@ -3447,7 +3448,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, const PageNode *rel out() << "<div class=\"fngroup\">\n"; for (const auto *node : collective) { nodeRef = refForNode(node); - out() << "<h3 class=\"fn fngroupitem\" id=\"" << nodeRef << "\">"; + out() << "<h3 class=\"fn fngroupitem\" translate=\"no\" id=\"" << nodeRef << "\">"; out() << "<a name=\"" + nodeRef + "\"></a>"; generateSynopsis(node, relative, marker, Section::Details); out() << "</h3>"; @@ -3468,7 +3469,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, const PageNode *rel generateSynopsis(etn->flagsType(), relative, marker, Section::Details); out() << "</h3>\n"; } else { - out() << "<h3 class=\"fn\" id=\"" << nodeRef << "\">"; + out() << "<h3 class=\"fn\" translate=\"no\" id=\"" << nodeRef << "\">"; out() << "<a name=\"" + nodeRef + "\"></a>"; generateSynopsis(node, relative, marker, Section::Details); out() << "</h3>" << divNavTop << '\n'; @@ -3542,7 +3543,7 @@ void HtmlGenerator::beginLink(const QString &link) if (showBrokenLinks) out() << "<i>"; } - out() << "<a href=\"" << link_ << "\">"; + out() << "<a href=\"" << link_ << "\" translate=\"no\">"; inLink_ = true; } @@ -3553,11 +3554,11 @@ void HtmlGenerator::beginLink(const QString &link, const Node *node, const Node if (showBrokenLinks) out() << "<i>"; } else if (node == nullptr || (relative != nullptr && node->status() == relative->status())) - out() << "<a href=\"" << link_ << "\">"; + out() << "<a href=\"" << link_ << "\" translate=\"no\">"; else if (node->isObsolete()) - out() << "<a href=\"" << link_ << "\" class=\"obsolete\">"; + out() << "<a href=\"" << link_ << "\" class=\"obsolete\" translate=\"no\">"; else - out() << "<a href=\"" << link_ << "\">"; + out() << "<a href=\"" << link_ << "\" translate=\"no\">"; inLink_ = true; } @@ -3588,7 +3589,7 @@ void HtmlGenerator::generateQmlSummary(const NodeVector &members, const Node *re if (!members.isEmpty()) { out() << "<ul>\n"; for (const auto &member : members) { - out() << "<li class=\"fn\">"; + out() << "<li class=\"fn\" translate=\"no\">"; generateQmlItem(member, relative, marker, true); if (member->isPropertyGroup()) { const SharedCommentNode *scn = static_cast<const SharedCommentNode *>(member); @@ -3597,7 +3598,7 @@ void HtmlGenerator::generateQmlSummary(const NodeVector &members, const Node *re const QVector<Node *> sharedNodes = scn->collective(); for (const auto &node : sharedNodes) { if (node->isQmlProperty() || node->isJsProperty()) { - out() << "<li class=\"fn\">"; + out() << "<li class=\"fn\" translate=\"no\">"; generateQmlItem(node, relative, marker, true); out() << "</li>\n"; } @@ -3624,7 +3625,7 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, const Aggregate *relat generateExtractionMark(node, MemberMark); generateKeywordAnchors(node); - QString qmlItemHeader("<div class=\"qmlproto\">\n" + QString qmlItemHeader("<div class=\"qmlproto\" translate=\"no\">\n" "<div class=\"table\"><table class=\"qmlname\">\n"); QString qmlItemStart("<tr valign=\"top\" class=\"odd\" id=\"%1\">\n" @@ -3708,30 +3709,6 @@ void HtmlGenerator::generateDetailedQmlMember(Node *node, const Aggregate *relat } /*! - Output the "Inherits" line for the QML element, - if there should be one. - */ -void HtmlGenerator::generateQmlInherits(QmlTypeNode *qcn, CodeMarker *marker) -{ - if (!qcn) - return; - QmlTypeNode *base = qcn->qmlBaseNode(); - while (base && base->isInternal()) { - base = base->qmlBaseNode(); - } - if (base) { - Text text; - text << Atom::ParaLeft << "Inherits "; - text << Atom(Atom::LinkNode, CodeMarker::stringForNode(base)); - text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK); - text << Atom(Atom::String, base->name()); - text << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK); - text << Atom::ParaRight; - generateText(text, qcn, marker); - } -} - -/*! Output the "[Xxx instantiates the C++ class QmlGraphicsXxx]" line for the QML element, if there should be one. |