summaryrefslogtreecommitdiffstats
path: root/tools/qdoc3
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-12-14 13:01:13 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-12-14 13:01:13 (GMT)
commit086a010a63895c6e6d178c1de9434483f11b2d34 (patch)
treebb2542f04438b42ae5c61b1c3a6330f011700474 /tools/qdoc3
parent0fe36ac832abf8f8d438b21fce0177b65b3bbf3a (diff)
parent5cb2226ddf96555417f08c9bfe35addfc93f6acd (diff)
downloadQt-086a010a63895c6e6d178c1de9434483f11b2d34.zip
Qt-086a010a63895c6e6d178c1de9434483f11b2d34.tar.gz
Qt-086a010a63895c6e6d178c1de9434483f11b2d34.tar.bz2
Merge branch 'qdoc-simplified' into mimir-simplified
Conflicts: tools/qdoc3/atom.h tools/qdoc3/qdoc3.pro
Diffstat (limited to 'tools/qdoc3')
-rw-r--r--tools/qdoc3/atom.h2
-rw-r--r--tools/qdoc3/doc.cpp47
-rw-r--r--tools/qdoc3/htmlgenerator.cpp2
-rw-r--r--tools/qdoc3/qdoc3.pro4
-rw-r--r--tools/qdoc3/qmlmarkupvisitor.cpp14
-rw-r--r--tools/qdoc3/qmlmarkupvisitor.h3
-rw-r--r--tools/qdoc3/quoter.cpp4
-rw-r--r--tools/qdoc3/test/macros.qdocconf32
-rw-r--r--tools/qdoc3/test/qt-html-default-styles.qdocconf26
-rw-r--r--tools/qdoc3/test/qt-html-online-styles.qdocconf11
-rw-r--r--tools/qdoc3/test/qt-html-templates-online.qdocconf6
-rw-r--r--tools/qdoc3/test/qt-html-templates.qdocconf20
12 files changed, 105 insertions, 66 deletions
diff --git a/tools/qdoc3/atom.h b/tools/qdoc3/atom.h
index fe85aec..a20e057 100644
--- a/tools/qdoc3/atom.h
+++ b/tools/qdoc3/atom.h
@@ -134,7 +134,7 @@ class Atom
Target, // 69
UnhandledFormat,
UnknownCommand,
- Last = UnknownCommand
+ Last = UnknownCommand
};
Atom(Type type, const QString &string = "")
diff --git a/tools/qdoc3/doc.cpp b/tools/qdoc3/doc.cpp
index 1c72f54..8d4d0ee 100644
--- a/tools/qdoc3/doc.cpp
+++ b/tools/qdoc3/doc.cpp
@@ -376,6 +376,7 @@ class DocParser
void leaveTableRow();
CodeMarker *quoteFromFile();
void expandMacro(const QString& name, const QString& def, int numParams);
+ QString expandMacroToString(const QString &name, const QString &def, int numParams);
Doc::SectioningUnit getSectioningUnit();
QString getArgument(bool verbatim = false);
QString getOptionalArgument();
@@ -1239,7 +1240,7 @@ void DocParser::parse(const QString& source,
}
else {
location().push(macro.defaultDefLocation.filePath());
- in.insert(pos, macro.defaultDef);
+ in.insert(pos, expandMacroToString(cmdStr, macro.defaultDef, macro.numParams));
len = in.length();
openedInputs.push(pos + macro.defaultDef.length());
}
@@ -1979,15 +1980,14 @@ void DocParser::expandMacro(const QString &name,
int j = 0;
while (j < def.size()) {
int paramNo;
- if ((def[j] == '\\') && (j < def.size() - 1) &&
- ((paramNo = def[j + 1].digitValue()) >= 1) &&
+ if (((paramNo = def[j].unicode()) >= 1) &&
(paramNo <= numParams)) {
if (!rawString.isEmpty()) {
append(Atom::RawString, rawString);
rawString = "";
}
append(Atom::String, args[paramNo - 1]);
- j += 2;
+ j += 1;
}
else {
rawString += def[j++];
@@ -1998,6 +1998,43 @@ void DocParser::expandMacro(const QString &name,
}
}
+QString DocParser::expandMacroToString(const QString &name, const QString &def, int numParams)
+{
+ if (numParams == 0) {
+ return def;
+ }
+ else {
+ QStringList args;
+ QString rawString;
+
+ for (int i = 0; i < numParams; i++) {
+ if (numParams == 1 || isLeftBraceAhead()) {
+ args << getArgument(true);
+ }
+ else {
+ location().warning(tr("Macro '\\%1' invoked with too few"
+ " arguments (expected %2, got %3)")
+ .arg(name).arg(numParams).arg(i));
+ break;
+ }
+ }
+
+ int j = 0;
+ while (j < def.size()) {
+ int paramNo;
+ if (((paramNo = def[j].unicode()) >= 1) &&
+ (paramNo <= numParams)) {
+ rawString += args[paramNo - 1];
+ j += 1;
+ }
+ else {
+ rawString += def[j++];
+ }
+ }
+ return rawString;
+ }
+}
+
Doc::SectioningUnit DocParser::getSectioningUnit()
{
QString name = getOptionalArgument();
@@ -2879,7 +2916,7 @@ void Doc::initialize(const Config& config)
QString def = config.getString(macroDotName + Config::dot + *f);
if (!def.isEmpty()) {
macro.otherDefs.insert(*f, def);
- int m = Config::numParams(macro.defaultDef);
+ int m = Config::numParams(def);
if (macro.numParams == -1) {
macro.numParams = m;
}
diff --git a/tools/qdoc3/htmlgenerator.cpp b/tools/qdoc3/htmlgenerator.cpp
index 40cfba3..948a7d6 100644
--- a/tools/qdoc3/htmlgenerator.cpp
+++ b/tools/qdoc3/htmlgenerator.cpp
@@ -490,7 +490,7 @@ int HtmlGenerator::generateAtom(const Atom *atom,
break;
#ifdef QDOC_QML
case Atom::Qml:
- out() << "<pre class=\"highlightedCode brush: cpp\">"
+ out() << "<pre class=\"qml\">"
<< trimmedTrailing(highlightedCode(indent(codeIndent,atom->string()),
marker,relative))
<< "</pre>\n";
diff --git a/tools/qdoc3/qdoc3.pro b/tools/qdoc3/qdoc3.pro
index 50c20ec..2fedc0f 100644
--- a/tools/qdoc3/qdoc3.pro
+++ b/tools/qdoc3/qdoc3.pro
@@ -86,9 +86,9 @@ SOURCES += atom.cpp \
tree.cpp \
yyindent.cpp
-INCLUDEPATH += $$(QT_SOURCE_TREE)/include/QtDeclarative
+INCLUDEPATH += $$QT_BUILD_TREE/include/QtDeclarative
-include($$(QT_SOURCE_TREE)/src/declarative/qml/parser/parser.pri)
+include($$QT_SOURCE_TREE/src/declarative/qml/parser/parser.pri)
### Documentation for qdoc3 ###
diff --git a/tools/qdoc3/qmlmarkupvisitor.cpp b/tools/qdoc3/qmlmarkupvisitor.cpp
index 6bede96..9916be2 100644
--- a/tools/qdoc3/qmlmarkupvisitor.cpp
+++ b/tools/qdoc3/qmlmarkupvisitor.cpp
@@ -183,7 +183,8 @@ void QmlMarkupVisitor::addExtra(quint32 start, quint32 finish)
}
void QmlMarkupVisitor::addMarkedUpToken(
- QDeclarativeJS::AST::SourceLocation &location, const QString &tagName)
+ QDeclarativeJS::AST::SourceLocation &location, const QString &tagName,
+ const QHash<QString, QString> &attributes)
{
if (!location.isValid())
return;
@@ -193,7 +194,10 @@ void QmlMarkupVisitor::addMarkedUpToken(
else if (cursor > location.offset)
return;
- output += QString(QLatin1String("<@%1>%2</@%3>")).arg(tagName, protect(sourceText(location)), tagName);
+ output += QString(QLatin1String("<@%1")).arg(tagName);
+ foreach (const QString &key, attributes)
+ output += QString(QLatin1String(" %1=\"%2\"")).arg(key).arg(attributes[key]);
+ output += QString(QLatin1String(">%2</@%3>")).arg(protect(sourceText(location)), tagName);
cursor += location.length;
}
@@ -853,9 +857,13 @@ bool QmlMarkupVisitor::visit(QDeclarativeJS::AST::DebuggerStatement *statement)
return true;
}
+// Elements and items are represented by UiObjectDefinition nodes.
+
bool QmlMarkupVisitor::visit(QDeclarativeJS::AST::UiObjectDefinition *definition)
{
- QDeclarativeJS::AST::Node::accept(definition->qualifiedTypeNameId, this);
+ QHash<QString, QString> attributes;
+ attributes[QLatin1String("node")] = sourceText(definition->qualifiedTypeNameId->identifierToken);
+ addMarkedUpToken(definition->qualifiedTypeNameId->identifierToken, QLatin1String("link"), attributes);
QDeclarativeJS::AST::Node::accept(definition->initializer, this);
return false;
}
diff --git a/tools/qdoc3/qmlmarkupvisitor.h b/tools/qdoc3/qmlmarkupvisitor.h
index 7a9ff22..60bc336 100644
--- a/tools/qdoc3/qmlmarkupvisitor.h
+++ b/tools/qdoc3/qmlmarkupvisitor.h
@@ -161,7 +161,8 @@ protected:
private:
void addExtra(quint32 start, quint32 finish);
void addMarkedUpToken(QDeclarativeJS::AST::SourceLocation &location,
- const QString &text);
+ const QString &text,
+ const QHash<QString, QString> &attributes = QHash<QString, QString>());
void addVerbatim(QDeclarativeJS::AST::SourceLocation first,
QDeclarativeJS::AST::SourceLocation last = QDeclarativeJS::AST::SourceLocation());
QString sourceText(QDeclarativeJS::AST::SourceLocation &location);
diff --git a/tools/qdoc3/quoter.cpp b/tools/qdoc3/quoter.cpp
index 6dc7894..84c6fb1 100644
--- a/tools/qdoc3/quoter.cpp
+++ b/tools/qdoc3/quoter.cpp
@@ -235,10 +235,14 @@ QString Quoter::quoteSnippet(const Location &docLocation, const QString &identif
QString lastLine = getLine();
int dIndex = lastLine.indexOf(delimiter);
if (dIndex > 0) {
+ // The delimiter might be preceded on the line by other
+ // delimeters, so look for the first comment on the line.
QString leading = lastLine.left(dIndex);
dIndex = leading.indexOf(comment);
if (dIndex != -1)
leading = leading.left(dIndex);
+ if (leading.endsWith(QLatin1String("<@comment>")))
+ leading.chop(10);
if (!leading.trimmed().isEmpty())
t += leading;
}
diff --git a/tools/qdoc3/test/macros.qdocconf b/tools/qdoc3/test/macros.qdocconf
index 2262daa..39986fc 100644
--- a/tools/qdoc3/test/macros.qdocconf
+++ b/tools/qdoc3/test/macros.qdocconf
@@ -30,6 +30,38 @@ macro.endcomment = "\\c{*/}"
macro.uuml.HTML = "&uuml;"
macro.mdash.HTML = "&mdash;"
+# Macros for floating images and floating images with alt text.
+# Ideally, these would be HTML-only macros.
+
+macro.floatleft = "\\raw HTML\n" \
+ "<div style=\"float: left; margin-right: 2em\">" \
+ "\\endraw\n" \
+ "\\inlineimage \1\n" \
+ "\\raw HTML\n" \
+ "</div>\n" \
+ "\\endraw\n"
+macro.figureleft = "\\raw HTML\n" \
+ "<div style=\"float: left; margin-right: 2em\">" \
+ "\\endraw\n" \
+ "\\inlineimage \1 \2\n" \
+ "\\raw HTML\n" \
+ "</div>\n" \
+ "\\endraw\n"
+macro.floatright = "\\raw HTML\n" \
+ "<div style=\"float: right; margin-left: 2em\">\n" \
+ "\\endraw\n" \
+ "\\inlineimage \1\n" \
+ "\\raw HTML\n" \
+ "</div>\n" \
+ "\\endraw\n"
+macro.figureright = "\\raw HTML\n" \
+ "<div style=\"float: right; margin-left: 2em\">" \
+ "\\endraw\n" \
+ "\\inlineimage \1 \2\n" \
+ "\\raw HTML\n" \
+ "</div>\n" \
+ "\\endraw\n"
+
macro.beginfloatleft.HTML = "<div style=\"float: left; margin-right: 2em\">"
macro.beginfloatright.HTML = "<div style=\"float: right; margin-left: 2em\">"
macro.endfloat.HTML = "</div>"
diff --git a/tools/qdoc3/test/qt-html-default-styles.qdocconf b/tools/qdoc3/test/qt-html-default-styles.qdocconf
index 30c28cb..c9c02ea 100644
--- a/tools/qdoc3/test/qt-html-default-styles.qdocconf
+++ b/tools/qdoc3/test/qt-html-default-styles.qdocconf
@@ -4,43 +4,25 @@
HTML.templatedir = $QT_SOURCE_TREE/doc/src/template
-HTML.stylesheets = style/style.css \
- style/narrow.css
+HTML.stylesheets = style/style.css
HTML.scripts =
# Files not referenced in any qdoc file (last four needed by qtdemo)
# See also qhp.Qt.extraFiles
-extraimages.HTML = qt-logo \
- trolltech-logo \
- bg_l.png \
- bg_l_blank.png \
- bg_ll_blank.png \
- bg_ul_blank.png \
- header_bg.png \
- bg_r.png \
- box_bg.png \
+extraimages.HTML = qt-logo.png \
+ arrow_down.png \
breadcrumb.png \
bullet_gt.png \
bullet_dn.png \
bullet_sq.png \
bullet_up.png \
- arrow_down.png \
- feedbackground.png \
horBar.png \
- page.png \
- page_bg.png \
- sprites-combined.png \
- spinner.gif \
- stylesheet-coffee-plastique.png \
- taskmenuextension-example.png \
- coloreditorfactoryimage.png \
- dynamiclayouts-example.png
+ sprites-combined.png
# Include the style sheets and scripts used.
HTML.headerstyles = \
- " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/narrow.css\" />\n" \
" <link rel=\"stylesheet\" type=\"text/css\" href=\"style/style.css\" />\n"
HTML.headerscripts =
diff --git a/tools/qdoc3/test/qt-html-online-styles.qdocconf b/tools/qdoc3/test/qt-html-online-styles.qdocconf
index 06f8964..6db3491 100644
--- a/tools/qdoc3/test/qt-html-online-styles.qdocconf
+++ b/tools/qdoc3/test/qt-html-online-styles.qdocconf
@@ -18,10 +18,9 @@ HTML.scripts = scripts/functions.js \
scripts/jquery.js
-# Files not referenced in any qdoc file (last four needed by qtdemo)
+# Files not referenced in any qdoc file.
# See also qhp.Qt.extraFiles
-extraimages.HTML = qt-logo \
- trolltech-logo \
+extraimages.HTML = qt-logo.png \
bg_l.png \
bg_l_blank.png \
bg_ll_blank.png \
@@ -40,11 +39,7 @@ extraimages.HTML = qt-logo \
page.png \
page_bg.png \
sprites-combined.png \
- spinner.gif \
- stylesheet-coffee-plastique.png \
- taskmenuextension-example.png \
- coloreditorfactoryimage.png \
- dynamiclayouts-example.png
+ spinner.gif
# Include the style sheets and scripts used.
diff --git a/tools/qdoc3/test/qt-html-templates-online.qdocconf b/tools/qdoc3/test/qt-html-templates-online.qdocconf
index 1d55cee..bc7dbd2 100644
--- a/tools/qdoc3/test/qt-html-templates-online.qdocconf
+++ b/tools/qdoc3/test/qt-html-templates-online.qdocconf
@@ -198,7 +198,7 @@ HTML.footer = \
" </script>\n"
-# Files not referenced in any qdoc file (last four are needed by qtdemo)
+# Files not referenced in any qdoc file.
# See also extraimages.HTML
qhp.Qt.extraFiles = index.html \
images/bg_l.png \
@@ -220,10 +220,6 @@ qhp.Qt.extraFiles = index.html \
images/page_bg.png \
images/sprites-combined.png \
images/spinner.gif \
- images/stylesheet-coffee-plastique.png \
- images/taskmenuextension-example.png \
- images/coloreditorfactoryimage.png \
- images/dynamiclayouts-example.png \
scripts/functions.js \
scripts/jquery.js \
scripts/narrow.js \
diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf
index 67ce95a..8241fa0 100644
--- a/tools/qdoc3/test/qt-html-templates.qdocconf
+++ b/tools/qdoc3/test/qt-html-templates.qdocconf
@@ -47,31 +47,15 @@ HTML.footer = \
" as published by the Free Software Foundation.</p>\n" \
"</div>\n" \
-# Files not referenced in any qdoc file (last four are needed by qtdemo)
+# Files not referenced in any qdoc file.
# See also extraimages.HTML
qhp.Qt.extraFiles = index.html \
- images/bg_l.png \
- images/bg_l_blank.png \
- images/bg_ll_blank.png \
- images/bg_ul_blank.png \
- images/header_bg.png \
- images/bg_r.png \
- images/box_bg.png \
+ images/arrow_down.png \
images/breadcrumb.png \
images/bullet_gt.png \
images/bullet_dn.png \
images/bullet_sq.png \
images/bullet_up.png \
- images/arrow_down.png \
- images/feedbackground.png \
images/horBar.png \
- images/page.png \
- images/page_bg.png \
images/sprites-combined.png \
- images/spinner.gif \
- images/stylesheet-coffee-plastique.png \
- images/taskmenuextension-example.png \
- images/coloreditorfactoryimage.png \
- images/dynamiclayouts-example.png \
- style/narrow.css \
style/style.css