diff options
author | Martin Smith <martin.smith@theqtcompany.com> | 2016-02-29 13:07:11 +0100 |
---|---|---|
committer | Martin Smith <martin.smith@theqtcompany.com> | 2016-03-09 11:34:16 +0000 |
commit | 2b262fad86ef38a5fa692b4c73e6ec26a5d45a5f (patch) | |
tree | 4b61e71f6bd7f62bf5784ab5e11df80c42e12db3 | |
parent | 6a3863ec30a0ff477fa73aff9b64ba5407d26347 (diff) |
qdoc: Let qdoc run without QtDeclarative
When qdoc is built without QtDeclarative present,
define QT_NO_DECLARATIVE. Then qdoc will not compile
the QML and JS parsers from QtDeclarative, and if it
encounters a request in the documentation to parse a
QML or JS snippet or file, it prints an error message
indicating that it can't parse QML or JS because
QtDeclarative is not installed.
Change-Id: I7e7948118244b7ffa563126520def083d75e3bb6
Task-number: QTBUG-51409
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Topi Reiniƶ <topi.reinio@theqtcompany.com>
-rw-r--r-- | src/qdoc/jscodemarker.cpp | 11 | ||||
-rw-r--r-- | src/qdoc/qdoc.pro | 7 | ||||
-rw-r--r-- | src/qdoc/qmlcodemarker.cpp | 13 | ||||
-rw-r--r-- | src/qdoc/qmlcodemarker.h | 4 | ||||
-rw-r--r-- | src/qdoc/qmlcodeparser.cpp | 14 | ||||
-rw-r--r-- | src/qdoc/qmlcodeparser.h | 6 | ||||
-rw-r--r-- | src/qdoc/qmlmarkupvisitor.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/qmlmarkupvisitor.h | 4 | ||||
-rw-r--r-- | src/qdoc/qmlvisitor.cpp | 4 | ||||
-rw-r--r-- | src/qdoc/qmlvisitor.h | 4 |
10 files changed, 70 insertions, 1 deletions
diff --git a/src/qdoc/jscodemarker.cpp b/src/qdoc/jscodemarker.cpp index 669040da0..496eb8c30 100644 --- a/src/qdoc/jscodemarker.cpp +++ b/src/qdoc/jscodemarker.cpp @@ -44,10 +44,12 @@ #include "tree.h" #include "generator.h" +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsast_p.h> #include <private/qqmljsengine_p.h> #include <private/qqmljslexer_p.h> #include <private/qqmljsparser_p.h> +#endif QT_BEGIN_NAMESPACE @@ -64,6 +66,7 @@ JsCodeMarker::~JsCodeMarker() */ bool JsCodeMarker::recognizeCode(const QString &code) { +#ifndef QT_NO_DECLARATIVE QQmlJS::Engine engine; QQmlJS::Lexer lexer(&engine); QQmlJS::Parser parser(&engine); @@ -73,6 +76,9 @@ bool JsCodeMarker::recognizeCode(const QString &code) lexer.setCode(newCode, 1); return parser.parseProgram(); +#else + return false; +#endif } /*! @@ -112,6 +118,7 @@ QString JsCodeMarker::addMarkUp(const QString &code, const Node * /* relative */, const Location &location) { +#ifndef QT_NO_DECLARATIVE QQmlJS::Engine engine; QQmlJS::Lexer lexer(&engine); @@ -137,6 +144,10 @@ QString JsCodeMarker::addMarkUp(const QString &code, output = protect(code); } return output; +#else + location.warning("QtDeclarative not installed; cannot parse QML or JS."); + return QString(); +#endif } QT_END_NAMESPACE diff --git a/src/qdoc/qdoc.pro b/src/qdoc/qdoc.pro index 6333a046e..52b40bccb 100644 --- a/src/qdoc/qdoc.pro +++ b/src/qdoc/qdoc.pro @@ -4,7 +4,12 @@ } option(host_build) -QT = core qmldevtools-private +QT = core +qtHaveModule(qmldevtools-private) { + QT += qmldevtools-private +} else { + DEFINES += QT_NO_DECLARATIVE +} DEFINES += \ QDOC2_COMPAT diff --git a/src/qdoc/qmlcodemarker.cpp b/src/qdoc/qmlcodemarker.cpp index 089e1d1c8..3b76f87da 100644 --- a/src/qdoc/qmlcodemarker.cpp +++ b/src/qdoc/qmlcodemarker.cpp @@ -44,11 +44,13 @@ #include "tree.h" #include "generator.h" +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsast_p.h> #include <private/qqmljsastfwd_p.h> #include <private/qqmljsengine_p.h> #include <private/qqmljslexer_p.h> #include <private/qqmljsparser_p.h> +#endif QT_BEGIN_NAMESPACE @@ -65,6 +67,7 @@ QmlCodeMarker::~QmlCodeMarker() */ bool QmlCodeMarker::recognizeCode(const QString &code) { +#ifndef QT_NO_DECLARATIVE QQmlJS::Engine engine; QQmlJS::Lexer lexer(&engine); QQmlJS::Parser parser(&engine); @@ -74,6 +77,9 @@ bool QmlCodeMarker::recognizeCode(const QString &code) lexer.setCode(newCode, 1); return parser.parse(); +#else + return false; +#endif } /*! @@ -163,6 +169,7 @@ QString QmlCodeMarker::addMarkUp(const QString &code, const Node * /* relative */, const Location &location) { +#ifndef QT_NO_DECLARATIVE QQmlJS::Engine engine; QQmlJS::Lexer lexer(&engine); @@ -188,8 +195,13 @@ QString QmlCodeMarker::addMarkUp(const QString &code, } return output; +#else + location.warning("QtDeclarative not installed; cannot parse QML or JS."); + return QString(); +#endif } +#ifndef QT_NO_DECLARATIVE /* Copied and pasted from src/declarative/qml/qqmlscriptparser.cpp. @@ -270,5 +282,6 @@ QList<QQmlJS::AST::SourceLocation> QmlCodeMarker::extractPragmas(QString &script } return removed; } +#endif QT_END_NAMESPACE diff --git a/src/qdoc/qmlcodemarker.h b/src/qdoc/qmlcodemarker.h index 96353ebe5..0090350e7 100644 --- a/src/qdoc/qmlcodemarker.h +++ b/src/qdoc/qmlcodemarker.h @@ -40,7 +40,9 @@ #include "cppcodemarker.h" +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsastfwd_p.h> +#endif QT_BEGIN_NAMESPACE @@ -67,7 +69,9 @@ public: virtual QString functionEndRegExp(const QString &funcName) Q_DECL_OVERRIDE; /* Copied from src/declarative/qml/qdeclarativescriptparser.cpp */ +#ifndef QT_NO_DECLARATIVE QList<QQmlJS::AST::SourceLocation> extractPragmas(QString &script); +#endif private: QString addMarkUp(const QString &code, const Node *relative, diff --git a/src/qdoc/qmlcodeparser.cpp b/src/qdoc/qmlcodeparser.cpp index e94df4753..58be80d01 100644 --- a/src/qdoc/qmlcodeparser.cpp +++ b/src/qdoc/qmlcodeparser.cpp @@ -41,8 +41,10 @@ #include "config.h" #include "qmlvisitor.h" +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsast_p.h> #include <private/qqmljsastvisitor_p.h> +#endif #include <qdebug.h> QT_BEGIN_NAMESPACE @@ -97,8 +99,10 @@ QT_BEGIN_NAMESPACE Constructs the QML code parser. */ QmlCodeParser::QmlCodeParser() +#ifndef QT_NO_DECLARATIVE : lexer( 0 ), parser( 0 ) +#endif { } @@ -119,8 +123,10 @@ void QmlCodeParser::initializeParser(const Config &config) { CodeParser::initializeParser(config); +#ifndef QT_NO_DECLARATIVE lexer = new QQmlJS::Lexer(&engine); parser = new QQmlJS::Parser(&engine); +#endif } /*! @@ -129,8 +135,10 @@ void QmlCodeParser::initializeParser(const Config &config) */ void QmlCodeParser::terminateParser() { +#ifndef QT_NO_DECLARATIVE delete lexer; delete parser; +#endif } /*! @@ -167,6 +175,7 @@ void QmlCodeParser::parseSourceFile(const Location& location, const QString& fil return; } +#ifndef QT_NO_DECLARATIVE QString document = in.readAll(); in.close(); @@ -195,6 +204,9 @@ void QmlCodeParser::parseSourceFile(const Location& location, const QString& fil << ": " << qPrintable(msg.message); } currentFile_.clear(); +#else + location.warning("QtDeclarative not installed; cannot parse QML or JS."); +#endif } /*! @@ -265,6 +277,7 @@ const QSet<QString>& QmlCodeParser::otherMetaCommands() return otherMetaCommands_; } +#ifndef QT_NO_DECLARATIVE /*! Copy and paste from src/declarative/qml/qdeclarativescriptparser.cpp. This function blanks out the section of the \a str beginning at \a idx @@ -329,5 +342,6 @@ void QmlCodeParser::extractPragmas(QString &script) } return; } +#endif QT_END_NAMESPACE diff --git a/src/qdoc/qmlcodeparser.h b/src/qdoc/qmlcodeparser.h index 8b5667532..f483b7382 100644 --- a/src/qdoc/qmlcodeparser.h +++ b/src/qdoc/qmlcodeparser.h @@ -41,9 +41,11 @@ #include "codeparser.h" #include <qset.h> +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsengine_p.h> #include <private/qqmljslexer_p.h> #include <private/qqmljsparser_p.h> +#endif QT_BEGIN_NAMESPACE @@ -66,17 +68,21 @@ public: virtual void parseSourceFile(const Location& location, const QString& filePath) Q_DECL_OVERRIDE; virtual void doneParsingSourceFiles() Q_DECL_OVERRIDE; +#ifndef QT_NO_DECLARATIVE /* Copied from src/declarative/qml/qdeclarativescriptparser.cpp */ void extractPragmas(QString &script); +#endif protected: const QSet<QString>& topicCommands(); const QSet<QString>& otherMetaCommands(); private: +#ifndef QT_NO_DECLARATIVE QQmlJS::Engine engine; QQmlJS::Lexer *lexer; QQmlJS::Parser *parser; +#endif }; QT_END_NAMESPACE diff --git a/src/qdoc/qmlmarkupvisitor.cpp b/src/qdoc/qmlmarkupvisitor.cpp index 17dd99325..122c23040 100644 --- a/src/qdoc/qmlmarkupvisitor.cpp +++ b/src/qdoc/qmlmarkupvisitor.cpp @@ -35,12 +35,15 @@ #include <qstringlist.h> #include <qglobal.h> +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsast_p.h> #include <private/qqmljsastfwd_p.h> #include <private/qqmljsengine_p.h> +#endif QT_BEGIN_NAMESPACE +#ifndef QT_NO_DECLARATIVE QmlMarkupVisitor::QmlMarkupVisitor(const QString &source, const QList<QQmlJS::AST::SourceLocation> &pragmas, QQmlJS::Engine *engine) @@ -840,5 +843,6 @@ bool QmlMarkupVisitor::visit(QQmlJS::AST::UiObjectDefinition *definition) QQmlJS::AST::Node::accept(definition->initializer, this); return false; } +#endif QT_END_NAMESPACE diff --git a/src/qdoc/qmlmarkupvisitor.h b/src/qdoc/qmlmarkupvisitor.h index ab1180fd4..63d6f1bf4 100644 --- a/src/qdoc/qmlmarkupvisitor.h +++ b/src/qdoc/qmlmarkupvisitor.h @@ -38,11 +38,14 @@ #include "tree.h" #include <qstring.h> +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsastvisitor_p.h> #include <private/qqmljsengine_p.h> +#endif QT_BEGIN_NAMESPACE +#ifndef QT_NO_DECLARATIVE class QmlMarkupVisitor : public QQmlJS::AST::Visitor { public: @@ -167,6 +170,7 @@ private: int extraIndex; }; Q_DECLARE_TYPEINFO(QmlMarkupVisitor::ExtraType, Q_PRIMITIVE_TYPE); +#endif QT_END_NAMESPACE diff --git a/src/qdoc/qmlvisitor.cpp b/src/qdoc/qmlvisitor.cpp index 654922929..3fee46932 100644 --- a/src/qdoc/qmlvisitor.cpp +++ b/src/qdoc/qmlvisitor.cpp @@ -42,9 +42,11 @@ #include <qstringlist.h> #include <qglobal.h> #include <qdebug.h> +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsast_p.h> #include <private/qqmljsastfwd_p.h> #include <private/qqmljsengine_p.h> +#endif QT_BEGIN_NAMESPACE @@ -89,6 +91,7 @@ QT_BEGIN_NAMESPACE #define COMMAND_JSATTACHEDMETHOD Doc::alias(QLatin1String("jsattachedmethod")) #define COMMAND_JSBASICTYPE Doc::alias(QLatin1String("jsbasictype")) +#ifndef QT_NO_DECLARATIVE /*! The constructor stores all the parameters in local data members. */ @@ -823,5 +826,6 @@ void QmlDocVisitor::endVisit(QQmlJS::AST::UiQualifiedId* ) { // nothing. } +#endif QT_END_NAMESPACE diff --git a/src/qdoc/qmlvisitor.h b/src/qdoc/qmlvisitor.h index 8a23eef75..bc7a3c003 100644 --- a/src/qdoc/qmlvisitor.h +++ b/src/qdoc/qmlvisitor.h @@ -37,8 +37,10 @@ #include "node.h" #include <qstring.h> +#ifndef QT_NO_DECLARATIVE #include <private/qqmljsastvisitor_p.h> #include <private/qqmljsengine_p.h> +#endif QT_BEGIN_NAMESPACE @@ -57,6 +59,7 @@ struct QmlPropArgs } }; +#ifndef QT_NO_DECLARATIVE class QmlDocVisitor : public QQmlJS::AST::Visitor { Q_DECLARE_TR_FUNCTIONS(QDoc::QmlDocVisitor) @@ -115,6 +118,7 @@ private: QSet<quint32> usedComments; Aggregate *current; }; +#endif QT_END_NAMESPACE |