aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/generator/qtdoc/qtxmltosphinx.h')
-rw-r--r--sources/shiboken6/generator/qtdoc/qtxmltosphinx.h83
1 files changed, 41 insertions, 42 deletions
diff --git a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
index 55d6a79b1..398c5bc97 100644
--- a/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
+++ b/sources/shiboken6/generator/qtdoc/qtxmltosphinx.h
@@ -1,42 +1,16 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of Qt for Python.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#ifndef QTXMLTOSPHINX_H
#define QTXMLTOSPHINX_H
#include <textstream.h>
-#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtCore/QScopedPointer>
-#include <QtCore/QSharedPointer>
#include <QtCore/QStack>
-#include <QtCore/QTextStream>
+
+#include <memory>
QT_BEGIN_NAMESPACE
class QDebug;
@@ -67,7 +41,7 @@ public:
QString data;
TableCell(const QString& text = QString()) : data(text) {}
- TableCell(const char* text) : data(QLatin1String(text)) {}
+ TableCell(const char* text) : data(QString::fromLatin1(text)) {}
};
using TableRow = QList<TableCell>;
@@ -96,20 +70,19 @@ public:
return m_normalized;
}
- void clear() {
- m_normalized = false;
- m_rows.clear();
- }
-
void appendRow(const TableRow &row) { m_rows.append(row); }
- const TableRow &constFirst() { return m_rows.constFirst(); }
+ const TableRow &constFirst() const { return m_rows.constFirst(); }
TableRow &first() { return m_rows.first(); }
TableRow &last() { return m_rows.last(); }
void format(TextStream& s) const;
+ void formatDebug(QDebug &debug) const;
private:
+ bool hasEmptyLeadingRow() const;
+ bool hasEmptyTrailingRow() const;
+
QList<TableRow> m_rows;
bool m_hasHeader = false;
bool m_normalized = false;
@@ -128,8 +101,12 @@ public:
static void stripPythonQualifiers(QString *s);
+ // For testing
+ static QString readSnippet(QIODevice &inputFile, const QString &identifier,
+ QString *errorMessage);
+
private:
- using StringSharedPtr = QSharedPointer<QString>;
+ using StringSharedPtr = std::shared_ptr<QString>;
QString transform(const QString& doc);
@@ -155,6 +132,7 @@ private:
// table tagsvoid QtXmlToSphinx::handleValueTag(QXmlStreamReader& reader)
void handleTableTag(QXmlStreamReader& reader);
+ void handleHeaderTag(QXmlStreamReader& reader);
void handleRowTag(QXmlStreamReader& reader);
void handleItemTag(QXmlStreamReader& reader);
void handleRawTag(QXmlStreamReader& reader);
@@ -182,21 +160,40 @@ private:
QStack<StringSharedPtr> m_buffers; // Maintain address stability since it used in TextStream
- Table m_currentTable;
+ QStack<Table> m_tables; // Stack of tables, used for <table><list> with nested <item>
QScopedPointer<QtXmlToSphinxLink> m_linkContext; // for <link>
QScopedPointer<QtXmlToSphinxLink> m_seeAlsoContext; // for <see-also>foo()</see-also>
- bool m_tableHasHeader = false;
QString m_context;
const QtXmlToSphinxDocGeneratorInterface *m_generator;
const QtXmlToSphinxParameters &m_parameters;
+ int m_formattingDepth = 0;
bool m_insideBold = false;
bool m_insideItalic = false;
QString m_lastTagName;
QString m_opened_anchor;
QList<InlineImage> m_inlineImages;
- QString readFromLocations(const QStringList &locations, const QString &path,
- const QString &identifier, QString *errorMessage);
+ bool m_containsAutoTranslations = false;
+
+ struct Snippet
+ {
+ enum Result {
+ Converted, // C++ converted to Python
+ Resolved, // Otherwise resolved in snippet paths
+ Fallback, // Fallback from XML
+ Error
+ };
+
+ QString code;
+ Result result;
+ };
+
+ void setAutoTranslatedNote(QString *str) const;
+
+ Snippet readSnippetFromLocations(const QString &path,
+ const QString &identifier,
+ const QString &fallbackPath,
+ QString *errorMessage);
static QString readFromLocation(const QString &location, const QString &identifier,
QString *errorMessage);
void pushOutputBuffer();
@@ -213,5 +210,7 @@ inline TextStream& operator<<(TextStream& s, const QtXmlToSphinx& xmlToSphinx)
}
QDebug operator<<(QDebug d, const QtXmlToSphinxLink &l);
+QDebug operator<<(QDebug debug, const QtXmlToSphinx::Table &t);
+QDebug operator<<(QDebug debug, const QtXmlToSphinx::TableCell &c);
#endif // QTXMLTOSPHINX_H