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 /src/qdoc/qmlcodeparser.cpp | |
parent | 6a3863ec30a0ff477fa73aff9b64ba5407d26347 (diff) | |
download | qttools-2b262fad86ef38a5fa692b4c73e6ec26a5d45a5f.tar.gz |
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>
Diffstat (limited to 'src/qdoc/qmlcodeparser.cpp')
-rw-r--r-- | src/qdoc/qmlcodeparser.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
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 |