From 2400960842ff9ffdd634c7d3edd4685d59415acd Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Mon, 7 Nov 2022 11:06:41 +0100 Subject: qdoc: Add translate attribute to HTML blocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A browser translates everything by default, which means even the ,
, s listing the class members,
and so on, are also translated. With this change, such HTML
blocks will include the "translate=no" attribute, indicating
that they should not be translated.

Fixes: QTBUG-106679
Done-with: Topi Reinio 
Change-Id: I446fe26c73b9e3fee2984297bd504ae72c555e73
Reviewed-by: Topi Reiniƶ 
(cherry picked from commit b7849d42efff91a4d247a4028d6c129f3742743a)
---
 src/qdoc/htmlgenerator.cpp | 56 +++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 26 deletions(-)

(limited to 'src')

diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp
index 43c1f3247..34852bb2e 100644
--- a/src/qdoc/htmlgenerator.cpp
+++ b/src/qdoc/htmlgenerator.cpp
@@ -106,12 +106,12 @@ void HtmlGenerator::initializeGenerator()
     } defaults[] = { { ATOM_FORMATTING_BOLD, "", "" },
                      { ATOM_FORMATTING_INDEX, "" },
                      { ATOM_FORMATTING_ITALIC, "", "" },
-                     { ATOM_FORMATTING_PARAMETER, "", "" },
+                     { ATOM_FORMATTING_PARAMETER, "", "" },
                      { ATOM_FORMATTING_SUBSCRIPT, "", "" },
                      { ATOM_FORMATTING_SUPERSCRIPT, "", "" },
-                     { ATOM_FORMATTING_TELETYPE, "",
+                     { ATOM_FORMATTING_TELETYPE, "",
                        "" }, //  tag is not supported in HTML5
-                     { ATOM_FORMATTING_UICONTROL, "", "" },
+                     { ATOM_FORMATTING_UICONTROL, "", "" },
                      { ATOM_FORMATTING_UNDERLINE, "", "" },
                      { nullptr, nullptr, nullptr } };
 
@@ -352,7 +352,7 @@ qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, Co
         }
         break;
     case Atom::Qml:
-        out() << "
"
+        out() << "
"
               << trimmedTrailing(highlightedCode(indent(m_codeIndent, atom->string()), relative,
                                                  false, Node::QML),
                                  m_codePrefix, m_codeSuffix)
@@ -366,13 +366,13 @@ qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, Co
               << "
\n"; break; case Atom::Code: - out() << "
"
+        out() << "
"
               << trimmedTrailing(highlightedCode(indent(m_codeIndent, atom->string()), relative),
                                  m_codePrefix, m_codeSuffix)
               << "
\n"; break; case Atom::CodeBad: - out() << "
"
+        out() << "
"
               << trimmedTrailing(protectEnc(plainCode(indent(m_codeIndent, atom->string()))),
                                  m_codePrefix, m_codeSuffix)
               << "
\n"; @@ -774,7 +774,7 @@ qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, Co std::pair pair = getAtomListValue(atom); skipAhead = pair.second; QString t = protectEnc(plainCode(marker->markedUpEnumValue(pair.first, relative))); - out() << "
" << t << ""; + out() << "
" << t << ""; if (relative->isEnumType()) { out() << ""; @@ -783,7 +783,7 @@ qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, Co if (itemValue.isEmpty()) out() << '?'; else - out() << "" << protectEnc(itemValue) << ""; + out() << "" << protectEnc(itemValue) << ""; } } break; @@ -966,7 +966,7 @@ qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, Co out() << "<Missing HTML>"; break; case Atom::UnknownCommand: - out() << R"(\)" << protectEnc(atom->string()) << ""; + out() << R"(\)" << protectEnc(atom->string()) << ""; break; case Atom::QmlText: case Atom::EndQmlText: @@ -1811,14 +1811,18 @@ void HtmlGenerator::generateTitle(const QString &title, const Text &subtitle, CodeMarker *marker) { out() << QString(m_prologue).replace("\\" + COMMAND_VERSION, m_qdb->version()); + QString attribute; + if (relative->genus() & Node::API) + attribute = R"( translate="no")"; + if (!title.isEmpty()) - out() << "

" << protectEnc(title) << "

\n"; + out() << "

" << protectEnc(title) << "

\n"; if (!subtitle.isEmpty()) { out() << ""; + out() << " class=\"small-subtitle\"" << attribute << ">"; else - out() << " class=\"subtitle\">"; + out() << " class=\"subtitle\"" << attribute << ">"; generateText(subtitle, relative, marker); out() << "\n"; } @@ -1888,7 +1892,7 @@ void HtmlGenerator::generateTheTable(const QStringList &requisiteOrder, const QString &headerText, const Aggregate *aggregate, CodeMarker *marker) { - out() << "
\n"; + out() << "
\n"; for (auto it = requisiteOrder.constBegin(); it != requisiteOrder.constEnd(); ++it) { @@ -2141,7 +2145,7 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) if (!requisites.isEmpty()) { // generate the table - out() << "
\n"; + out() << "
\n"; for (const auto &requisite : requisiteorder) { if (requisites.contains(requisite)) { @@ -2365,7 +2369,7 @@ QString HtmlGenerator::generateAllQmlMembersFile(const Sections §ions, CodeM continue; std::function generate = [&](Node *n) { - out() << "
  • "; + out() << "
  • "; generateQmlItem(n, aggregate, marker, true); if (n->isDefault()) out() << " [default]"; @@ -2941,7 +2945,7 @@ void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, alignNames = false; } if (alignNames) { - out() << "
  • \n"; + out() << "
    \n"; } else { if (twoColumn) out() << "
    \n" @@ -2959,7 +2963,7 @@ void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, } else { if (twoColumn && i == (nv.size() + 1) / 2) out() << "
      \n"; - out() << "
    • "; + out() << "
    • "; } generateSynopsis(member, relative, marker, Section::Summary, alignNames); @@ -2997,10 +3001,10 @@ void HtmlGenerator::generateSectionList(const Section §ion, const Node *rela alignNames = false; } if (alignNames) { - out() << "
      \n"; + out() << "
      \n"; } else { if (twoColumn) - out() << "
      \n" + out() << "
      \n" << "
      "; out() << "
        \n"; } @@ -3015,7 +3019,7 @@ void HtmlGenerator::generateSectionList(const Section §ion, const Node *rela } else { if (twoColumn && i == (members.size() + 1) / 2) out() << "
        \n"; - out() << "
      • "; + out() << "
      • "; } QString prefix; @@ -3070,7 +3074,7 @@ void HtmlGenerator::generateSectionInheritedList(const Section §ion, const N { const QList> &inheritedMembers = section.inheritedMembers(); for (const auto &member : inheritedMembers) { - out() << "
      • "; + out() << "
      • "; out() << member.second << ' '; if (member.second == 1) { out() << section.singular(); @@ -3112,7 +3116,7 @@ void HtmlGenerator::generateSynopsis(const Node *node, const Node *relative, Cod QRegularExpression::InvertedGreedinessOption); marked.remove(extraRegExp); } else { - marked.replace("<@extra>", ""); + marked.replace("<@extra>", ""); marked.replace("", ""); } @@ -3381,7 +3385,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, const PageNode *rel out() << "
        \n"; for (const auto *sharedNode : collective) { nodeRef = refForNode(sharedNode); - out() << R"(

        "; + out() << R"(

        "; generateSynopsis(sharedNode, relative, marker, Section::Details); out() << "

        "; } @@ -3397,7 +3401,7 @@ void HtmlGenerator::generateDetailedMember(const Node *node, const PageNode *rel generateSynopsis(etn->flagsType(), relative, marker, Section::Details); out() << "\n"; } else { - out() << R"(

        "; + out() << R"(

        "; generateSynopsis(node, relative, marker, Section::Details); out() << "

        " << '\n'; } @@ -3498,7 +3502,7 @@ void HtmlGenerator::generateQmlSummary(const NodeVector &members, const Node *re if (!members.isEmpty()) { out() << "
          \n"; for (const auto &member : members) { - out() << "
        • "; + out() << "
        • "; generateQmlItem(member, relative, marker, true); if (member->isPropertyGroup()) { const auto *scn = static_cast(member); @@ -3507,7 +3511,7 @@ void HtmlGenerator::generateQmlSummary(const NodeVector &members, const Node *re const QList &sharedNodes = scn->collective(); for (const auto &node : sharedNodes) { if (node->isQmlProperty()) { - out() << "
        • "; + out() << "
        • "; generateQmlItem(node, relative, marker, true); out() << "
        • \n"; } -- cgit v1.2.1