summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid Boddie <david.boddie@nokia.com>2010-12-20 15:08:57 (GMT)
committerDavid Boddie <david.boddie@nokia.com>2010-12-20 15:08:57 (GMT)
commit382b359f2c014d8ce353845579508a8c54410c7f (patch)
tree423d432e717422ca8839f799fac0132ff92995f8 /tools
parent02c548c7a38c627b12e84ff164a406cc478f8658 (diff)
downloadQt-382b359f2c014d8ce353845579508a8c54410c7f.zip
Qt-382b359f2c014d8ce353845579508a8c54410c7f.tar.gz
Qt-382b359f2c014d8ce353845579508a8c54410c7f.tar.bz2
Fixed handling of indented snippet markers.
Refactored the code to remove namespace macros and snippet markers.
Diffstat (limited to 'tools')
-rw-r--r--tools/qdoc3/quoter.cpp56
-rw-r--r--tools/qdoc3/quoter.h1
2 files changed, 27 insertions, 30 deletions
diff --git a/tools/qdoc3/quoter.cpp b/tools/qdoc3/quoter.cpp
index 84c6fb1..8e08e9a 100644
--- a/tools/qdoc3/quoter.cpp
+++ b/tools/qdoc3/quoter.cpp
@@ -248,21 +248,8 @@ QString Quoter::quoteSnippet(const Location &docLocation, const QString &identif
}
return t;
}
- // Remove special macros to support Qt namespacing.
- if (line.startsWith("QT_BEGIN_NAMESPACE")) {
- getLine();
- } else if (line.startsWith("QT_END_NAMESPACE")) {
- getLine();
- t += QLatin1Char('\n');
- } else if (!line.startsWith(comment)) {
- // Ordinary code
- t += getLine();
- } else {
- // Normal comments
- if (line.contains(QLatin1Char('\n')))
- t += QLatin1Char('\n');
- getLine();
- }
+
+ t += removeSpecialLines(line, comment);
}
failedAtEnd(docLocation, QString("snippet (%1)").arg(delimiter));
return t;
@@ -277,21 +264,7 @@ QString Quoter::quoteTo( const Location& docLocation, const QString& command,
if ( pattern.isEmpty() ) {
while ( !plainLines.isEmpty() ) {
QString line = plainLines.first();
- // Remove special macros to support Qt namespacing.
- if (line.startsWith("QT_BEGIN_NAMESPACE")) {
- getLine();
- } else if (line.startsWith("QT_END_NAMESPACE")) {
- getLine();
- t += QLatin1Char('\n');
- } else if (!line.startsWith(comment))
- // Ordinary code
- t += getLine();
- else {
- // Normal comments
- if (line.contains(QLatin1Char('\n')))
- t += QLatin1Char('\n');
- getLine();
- }
+ t += removeSpecialLines(line, comment);
}
} else {
while ( !plainLines.isEmpty() ) {
@@ -369,4 +342,27 @@ QString Quoter::commentForCode() const
return commentHash.value(suffix, "//!");
}
+QString Quoter::removeSpecialLines(const QString &line, const QString &comment)
+{
+ QString t;
+
+ // Remove special macros to support Qt namespacing.
+ QString trimmed = line.trimmed();
+ if (trimmed.startsWith("QT_BEGIN_NAMESPACE")) {
+ getLine();
+ } else if (trimmed.startsWith("QT_END_NAMESPACE")) {
+ getLine();
+ t += QLatin1Char('\n');
+ } else if (!trimmed.startsWith(comment)) {
+ // Ordinary code
+ t += getLine();
+ } else {
+ // Comments
+ if (line.contains(QLatin1Char('\n')))
+ t += QLatin1Char('\n');
+ getLine();
+ }
+ return t;
+}
+
QT_END_NAMESPACE
diff --git a/tools/qdoc3/quoter.h b/tools/qdoc3/quoter.h
index d984194..e1728d1 100644
--- a/tools/qdoc3/quoter.h
+++ b/tools/qdoc3/quoter.h
@@ -75,6 +75,7 @@ private:
bool match( const Location& docLocation, const QString& pattern,
const QString& line );
QString commentForCode() const;
+ QString removeSpecialLines(const QString &line, const QString &comment);
bool silent;
bool validRegExp;