From b74034a3bcedee3cb1489f17a028a7680bfc5d98 Mon Sep 17 00:00:00 2001 From: Thibaut Cuvelier Date: Fri, 13 Dec 2019 02:16:54 +0100 Subject: Factor out the formatting of the "since" text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I3ec3342eb3362664c605c4120238566d87c8b176 Reviewed-by: Paul Wicking Reviewed-by: Topi Reiniƶ --- src/qdoc/generator.cpp | 34 ++++++++++++---------- src/qdoc/generator.h | 1 + src/qdoc/htmlgenerator.cpp | 24 +++------------ .../expected_output/qml-qdoc-test-doctest.html | 4 +-- .../expected_output/testqdoc-test.html | 2 +- 5 files changed, 27 insertions(+), 38 deletions(-) diff --git a/src/qdoc/generator.cpp b/src/qdoc/generator.cpp index fe2b56b7a..a65b47333 100644 --- a/src/qdoc/generator.cpp +++ b/src/qdoc/generator.cpp @@ -1337,28 +1337,32 @@ void Generator::generateReimplementsClause(const FunctionNode *fn, CodeMarker *m } } +QString Generator::formatSince(const Node *node) +{ + QStringList since = node->since().split(QLatin1Char(' ')); + + // If there is only one argument, assume it is the Qt version number. + if (since.count() == 1) + return "Qt " + since[0]; + + // Otherwise, use the original string. + return node->since(); +} + void Generator::generateSince(const Node *node, CodeMarker *marker) { if (!node->since().isEmpty()) { Text text; text << Atom::ParaLeft << "This " - << typeString(node); + << typeString(node) + << " was introduced "; if (node->isEnumType()) - text << " was introduced or modified in "; - else - text << " was introduced in "; - - QStringList since = node->since().split(QLatin1Char(' ')); - if (since.count() == 1) { - // If there is only one argument, assume it is the Qt version number. - text << " Qt " << since[0]; - } else { - // Otherwise, reconstruct the string. - text << " " << since.join(' '); - } - - text << "." << Atom::ParaRight; + text << "or modified "; + text << "in " + << formatSince(node) + << "." + << Atom::ParaRight; generateText(text, node, marker); } } diff --git a/src/qdoc/generator.h b/src/qdoc/generator.h index 2ed902ec6..10fd5131a 100644 --- a/src/qdoc/generator.h +++ b/src/qdoc/generator.h @@ -157,6 +157,7 @@ protected: void generateRequiredLinks(const Node *node, CodeMarker *marker); void generateLinkToExample(const ExampleNode *en, CodeMarker *marker, const QString &exampleUrl); virtual void generateFileList(const ExampleNode *en, CodeMarker *marker, bool images); + static QString formatSince(const Node *node); void generateSince(const Node *node, CodeMarker *marker); void generateStatus(const Node *node, CodeMarker *marker); void generatePrivateSignalNote(const Node *node, CodeMarker *marker); diff --git a/src/qdoc/htmlgenerator.cpp b/src/qdoc/htmlgenerator.cpp index a336467ba..afd39e0e2 100644 --- a/src/qdoc/htmlgenerator.cpp +++ b/src/qdoc/htmlgenerator.cpp @@ -2172,16 +2172,8 @@ void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker) //add the since and project into the map if (!aggregate->since().isEmpty()) { text.clear(); - QStringList since = aggregate->since().split(QLatin1Char(' ')); - if (since.count() == 1) { - // If there is only one argument, assume it is the Qt version number. - text << " Qt " << since[0]; - } - else { - //Otherwise, reconstruct the string. - text << " " << since.join(' '); - } - text << Atom::ParaRight; + text << formatSince(aggregate) + << Atom::ParaRight; requisites.insert(sinceText, text); } @@ -2304,16 +2296,8 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) //add the since and project into the map if (!qcn->since().isEmpty()) { text.clear(); - QStringList since = qcn->since().split(QLatin1Char(' ')); - if (since.count() == 1) { - // If there is only one argument, assume it is the Qt version number. - text << " Qt " << since[0]; - } - else { - //Otherwise, reconstruct the string. - text << " " << since.join(' '); - } - text << Atom::ParaRight; + text << formatSince(qcn) + << Atom::ParaRight; requisites.insert(sinceText, text); } diff --git a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html index 8ad2b4d5e..626531c04 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/qml-qdoc-test-doctest.html @@ -24,7 +24,7 @@

Represents a doc test case. More...

-
Import Statement: import QDoc.Test 1.1
Since: QDoc.Test 0.9
    + Import Statement: import QDoc.Test 1.1 Since: QDoc.Test 0.9 @@ -80,7 +80,7 @@ fail(message = "oops")

    Fails the current test case, with the optional message.

    -

    This method was introduced in QDoc.Test 1.0.

    +

    This method was introduced in QDoc.Test 1.0.


    diff --git a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html index 32fb9efa0..f172a10e7 100644 --- a/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html +++ b/tests/auto/qdoc/generatedoutput/expected_output/testqdoc-test.html @@ -73,7 +73,7 @@

    QDOCTEST_MACRO2(x)

    A macro with argument x.

    -

    This function was introduced in Test 1.1.

    +

    This function was introduced in Test 1.1.

    -- cgit v1.2.3