summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-12-21 17:38:04 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-12-21 17:38:04 (GMT)
commitea41ba11fc848dbefecb0cde324478ab1986e555 (patch)
treea2a4dd1786ad4e3f0ffbfcb20ad3f964815e3049 /tools/qdoc3
parent9862f29b3c8d3f23113388b48b1c4b86523137dc (diff)
downloadQt-ea41ba11fc848dbefecb0cde324478ab1986e555.zip
Qt-ea41ba11fc848dbefecb0cde324478ab1986e555.tar.gz
Qt-ea41ba11fc848dbefecb0cde324478ab1986e555.tar.bz2
Enabled error reporting and a plain text fallback for invalid QML.
The location of places where code is included in documentation is now passed into each code marker when highlighted code is needed.
Diffstat (limited to 'tools/qdoc3')
-rw-r--r--tools/qdoc3/codemarker.h2
-rw-r--r--tools/qdoc3/cppcodemarker.cpp9
-rw-r--r--tools/qdoc3/cppcodemarker.h4
-rw-r--r--tools/qdoc3/doc.cpp6
-rw-r--r--tools/qdoc3/jscodemarker.cpp12
-rw-r--r--tools/qdoc3/jscodemarker.h6
-rw-r--r--tools/qdoc3/plaincodemarker.cpp2
-rw-r--r--tools/qdoc3/plaincodemarker.h2
-rw-r--r--tools/qdoc3/qmlcodemarker.cpp15
-rw-r--r--tools/qdoc3/qmlcodemarker.h6
10 files changed, 39 insertions, 25 deletions
diff --git a/tools/qdoc3/codemarker.h b/tools/qdoc3/codemarker.h
index 029ddb9..3cf3984 100644
--- a/tools/qdoc3/codemarker.h
+++ b/tools/qdoc3/codemarker.h
@@ -126,7 +126,7 @@ class CodeMarker
const Node *relative = 0) = 0;
virtual QString markedUpCode(const QString& code,
const Node *relative,
- const QString& dirPath) = 0;
+ const Location &location) = 0;
virtual QString markedUpSynopsis(const Node *node,
const Node *relative,
SynopsisStyle style) = 0;
diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp
index 55a455f..8ea1c7f 100644
--- a/tools/qdoc3/cppcodemarker.cpp
+++ b/tools/qdoc3/cppcodemarker.cpp
@@ -157,9 +157,9 @@ QString CppCodeMarker::plainFullName(const Node *node, const Node *relative)
QString CppCodeMarker::markedUpCode(const QString &code,
const Node *relative,
- const QString &dirPath)
+ const Location &location)
{
- return addMarkUp(protect(code), relative, dirPath);
+ return addMarkUp(protect(code), relative, location);
}
QString CppCodeMarker::markedUpSynopsis(const Node *node,
@@ -440,7 +440,8 @@ QString CppCodeMarker::markedUpIncludes(const QStringList& includes)
code += "#include &lt;<@headerfile>" + *inc + "</@headerfile>&gt;\n";
++inc;
}
- return addMarkUp(code, 0, "");
+ Location location;
+ return addMarkUp(code, 0, location);
}
QString CppCodeMarker::functionBeginRegExp(const QString& funcName)
@@ -868,7 +869,7 @@ const Node *CppCodeMarker::resolveTarget(const QString& target,
QString CppCodeMarker::addMarkUp(const QString& protectedCode,
const Node * /* relative */,
- const QString& /* dirPath */)
+ const Location & /* location */)
{
static QRegExp globalInclude("#include +&lt;([^<>&]+)&gt;");
static QRegExp yHasTypeX("(?:^|\n *)([a-zA-Z_][a-zA-Z_0-9]*)"
diff --git a/tools/qdoc3/cppcodemarker.h b/tools/qdoc3/cppcodemarker.h
index 40695c5..bb307f9 100644
--- a/tools/qdoc3/cppcodemarker.h
+++ b/tools/qdoc3/cppcodemarker.h
@@ -63,7 +63,7 @@ class CppCodeMarker : public CodeMarker
virtual QString plainFullName(const Node *node, const Node *relative);
virtual QString markedUpCode(const QString& code,
const Node *relative,
- const QString& dirPath);
+ const Location &location);
virtual QString markedUpSynopsis(const Node *node,
const Node *relative,
SynopsisStyle style);
@@ -90,7 +90,7 @@ class CppCodeMarker : public CodeMarker
private:
QString addMarkUp(const QString& protectedCode,
const Node *relative,
- const QString& dirPath);
+ const Location &location);
};
QT_END_NAMESPACE
diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp
index ce9e30d..774f8ba 100644
--- a/tools/qdoc3/doc.cpp
+++ b/tools/qdoc3/doc.cpp
@@ -536,7 +536,7 @@ void DocParser::parse(const QString& source,
enterPara();
x = untabifyEtc(getArgument(true));
marker = CodeMarker::markerForCode(x);
- append(Atom::C, marker->markedUpCode(x, 0, ""));
+ append(Atom::C, marker->markedUpCode(x, 0, location()));
break;
case CMD_CAPTION:
leavePara();
@@ -2305,7 +2305,7 @@ QString DocParser::getCode(int cmd, CodeMarker *marker)
code = unindent(minIndent, code);
if (!marker)
marker = CodeMarker::markerForCode(code);
- return marker->markedUpCode(code, 0, "");
+ return marker->markedUpCode(code, 0, location());
}
/*!
@@ -3043,7 +3043,7 @@ CodeMarker *Doc::quoteFromFile(const Location &location,
CodeMarker *marker = CodeMarker::markerForFileName(fileName);
quoter.quoteFromFile(userFriendlyFilePath,
code,
- marker->markedUpCode(code, 0, dirPath));
+ marker->markedUpCode(code, 0, location));
return marker;
}
diff --git a/tools/qdoc3/jscodemarker.cpp b/tools/qdoc3/jscodemarker.cpp
index 84a28c6..80df0aa 100644
--- a/tools/qdoc3/jscodemarker.cpp
+++ b/tools/qdoc3/jscodemarker.cpp
@@ -103,14 +103,14 @@ bool JsCodeMarker::recognizeLanguage(const QString &language)
QString JsCodeMarker::markedUpCode(const QString &code,
const Node *relative,
- const QString &dirPath)
+ const Location &location)
{
- return addMarkUp(code, relative, dirPath);
+ return addMarkUp(code, relative, location);
}
QString JsCodeMarker::addMarkUp(const QString &code,
const Node * /* relative */,
- const QString & /* dirPath */)
+ const Location &location)
{
QDeclarativeJS::Engine engine;
QDeclarativeJS::Lexer lexer(&engine);
@@ -130,7 +130,13 @@ QString JsCodeMarker::addMarkUp(const QString &code,
QmlMarkupVisitor visitor(code, pragmas, &engine);
QDeclarativeJS::AST::Node::accept(ast, &visitor);
output = visitor.markedUpCode();
+ } else {
+ location.warning(tr("Unable to parse JavaScript: \"%1\" at line %2, column %3").arg(
+ parser.errorMessage()).arg(parser.errorLineNumber()).arg(
+ parser.errorColumnNumber()));
+ output = protect(code);
}
+
return output;
}
diff --git a/tools/qdoc3/jscodemarker.h b/tools/qdoc3/jscodemarker.h
index f7cb025..6d85063 100644
--- a/tools/qdoc3/jscodemarker.h
+++ b/tools/qdoc3/jscodemarker.h
@@ -62,11 +62,11 @@ public:
virtual QString markedUpCode(const QString &code,
const Node *relative,
- const QString &dirPath);
+ const Location &location);
private:
- QString addMarkUp(const QString &code, const Node * /* relative */,
- const QString & /* dirPath */);
+ QString addMarkUp(const QString &code, const Node *relative,
+ const Location &location);
};
QT_END_NAMESPACE
diff --git a/tools/qdoc3/plaincodemarker.cpp b/tools/qdoc3/plaincodemarker.cpp
index d825c13..9819593 100644
--- a/tools/qdoc3/plaincodemarker.cpp
+++ b/tools/qdoc3/plaincodemarker.cpp
@@ -78,7 +78,7 @@ QString PlainCodeMarker::plainFullName(const Node * /* node */, const Node * /*
QString PlainCodeMarker::markedUpCode( const QString& code,
const Node * /* relative */,
- const QString& /* dirPath */ )
+ const Location & /* location */ )
{
return protect( code );
}
diff --git a/tools/qdoc3/plaincodemarker.h b/tools/qdoc3/plaincodemarker.h
index 7afb88e..1c469a0 100644
--- a/tools/qdoc3/plaincodemarker.h
+++ b/tools/qdoc3/plaincodemarker.h
@@ -61,7 +61,7 @@ public:
bool recognizeLanguage( const QString& lang );
QString plainName( const Node *node );
QString plainFullName( const Node *node, const Node *relative );
- QString markedUpCode( const QString& code, const Node *relative, const QString& dirPath );
+ QString markedUpCode( const QString& code, const Node *relative, const Location &location );
QString markedUpSynopsis( const Node *node, const Node *relative,
SynopsisStyle style );
QString markedUpName( const Node *node );
diff --git a/tools/qdoc3/qmlcodemarker.cpp b/tools/qdoc3/qmlcodemarker.cpp
index 1e4ad1e..fc91cbb 100644
--- a/tools/qdoc3/qmlcodemarker.cpp
+++ b/tools/qdoc3/qmlcodemarker.cpp
@@ -134,9 +134,9 @@ QString QmlCodeMarker::plainFullName(const Node *node, const Node *relative)
QString QmlCodeMarker::markedUpCode(const QString &code,
const Node *relative,
- const QString &dirPath)
+ const Location &location)
{
- return addMarkUp(code, relative, dirPath);
+ return addMarkUp(code, relative, location);
}
QString QmlCodeMarker::markedUpName(const Node *node)
@@ -174,7 +174,8 @@ QString QmlCodeMarker::markedUpIncludes(const QStringList& includes)
code += "import " + *inc + "\n";
++inc;
}
- return protect(addMarkUp(code, 0, ""));
+ Location location;
+ return protect(addMarkUp(code, 0, location));
}
QString QmlCodeMarker::functionBeginRegExp(const QString& funcName)
@@ -190,7 +191,7 @@ QString QmlCodeMarker::functionEndRegExp(const QString& /* funcName */)
QString QmlCodeMarker::addMarkUp(const QString &code,
const Node * /* relative */,
- const QString & /* dirPath */)
+ const Location &location)
{
QDeclarativeJS::Engine engine;
QDeclarativeJS::Lexer lexer(&engine);
@@ -210,7 +211,13 @@ QString QmlCodeMarker::addMarkUp(const QString &code,
QmlMarkupVisitor visitor(code, pragmas, &engine);
QDeclarativeJS::AST::Node::accept(ast, &visitor);
output = visitor.markedUpCode();
+ } else {
+ location.warning(tr("Unable to parse QML: \"%1\" at line %2, column %3").arg(
+ parser.errorMessage()).arg(parser.errorLineNumber()).arg(
+ parser.errorColumnNumber()));
+ output = protect(code);
}
+
return output;
}
diff --git a/tools/qdoc3/qmlcodemarker.h b/tools/qdoc3/qmlcodemarker.h
index 68e6753..b1d365c 100644
--- a/tools/qdoc3/qmlcodemarker.h
+++ b/tools/qdoc3/qmlcodemarker.h
@@ -64,7 +64,7 @@ public:
virtual QString plainFullName(const Node *node, const Node *relative);
virtual QString markedUpCode(const QString &code,
const Node *relative,
- const QString &dirPath);
+ const Location &location);
virtual QString markedUpName(const Node *node);
virtual QString markedUpFullName(const Node *node, const Node *relative);
@@ -76,8 +76,8 @@ public:
QList<QDeclarativeJS::AST::SourceLocation> extractPragmas(QString &script);
private:
- QString addMarkUp(const QString &code, const Node * /* relative */,
- const QString & /* dirPath */);
+ QString addMarkUp(const QString &code, const Node *relative,
+ const Location &location);
};
QT_END_NAMESPACE