summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@theqtcompany.com>2016-01-20 15:56:54 +0100
committerTopi Reiniƶ <topi.reinio@theqtcompany.com>2016-01-22 13:41:16 +0000
commit0ea13138a8b8ad324c5bdf2a566fe949766713ef (patch)
tree390fc9e5e7566fc93b85e1eb00f348d5465e8060
parent2ae9f3729cfda0451a24a8a112fd326170e1cc14 (diff)
qdoc: Allow wildcards for excludefiles qdocconf variable
This commit allows the use of simple wildcards ('*' and '?') for excluding a set of files. A typical use case is to exclude all private header files with '*_p.h'. Task-number: QTBUG-50600 Change-Id: Ib50e9e85731d7506ea7299016f609e48ab3d277f Reviewed-by: Martin Smith <martin.smith@theqtcompany.com>
-rw-r--r--src/qdoc/config.cpp23
-rw-r--r--src/qdoc/config.h1
-rw-r--r--src/qdoc/doc/qdoc-manual-qdocconf.qdoc11
3 files changed, 30 insertions, 5 deletions
diff --git a/src/qdoc/config.cpp b/src/qdoc/config.cpp
index 6c47b86d2..03afcdb7b 100644
--- a/src/qdoc/config.cpp
+++ b/src/qdoc/config.cpp
@@ -496,8 +496,13 @@ QStringList Config::getCanonicalPathList(const QString& var, bool validate) cons
dir.setPath(d + QLatin1Char('/') + path);
if (validate && !QFileInfo::exists(dir.path()))
lastLocation_.warning(tr("Cannot find file or directory: %1").arg(path));
- else
- t.append(dir.canonicalPath());
+ else {
+ QString canonicalPath = dir.canonicalPath();
+ if (!canonicalPath.isEmpty())
+ t.append(canonicalPath);
+ else if (path.contains(QLatin1Char('*')) || path.contains(QLatin1Char('?')))
+ t.append(path);
+ }
}
}
--i;
@@ -1156,6 +1161,18 @@ void Config::load(Location location, const QString& fileName)
QDir::setCurrent(workingDirs_.top());
}
+bool Config::isFileExcluded(const QString &fileName, const QSet<QString> &excludedFiles)
+{
+ foreach (const QString &entry, excludedFiles) {
+ if (entry.contains(QLatin1Char('*')) || entry.contains(QLatin1Char('?'))) {
+ QRegExp re(entry, Qt::CaseSensitive, QRegExp::Wildcard);
+ if (re.exactMatch(fileName))
+ return true;
+ }
+ }
+ return excludedFiles.contains(fileName);
+}
+
QStringList Config::getFilesHere(const QString& uncleanDir,
const QString& nameFilter,
const Location &location,
@@ -1180,7 +1197,7 @@ QStringList Config::getFilesHere(const QString& uncleanDir,
if (!fn->startsWith(QLatin1Char('~'))) {
QString s = dirInfo.filePath(*fn);
QString c = QDir::cleanPath(s);
- if (!excludedFiles.contains(c))
+ if (!isFileExcluded(c, excludedFiles))
result.append(c);
}
++fn;
diff --git a/src/qdoc/config.h b/src/qdoc/config.h
index 740568ca0..8356f9396 100644
--- a/src/qdoc/config.h
+++ b/src/qdoc/config.h
@@ -109,6 +109,7 @@ public:
QStringList getExampleImageFiles(const QSet<QString> &excludedDirs, const QSet<QString> &excludedFiles);
static QStringList loadMaster(const QString& fileName);
+ static bool isFileExcluded(const QString &fileName, const QSet<QString> &excludedFiles);
static QStringList getFilesHere(const QString& dir,
const QString& nameFilter,
const Location &location = Location(),
diff --git a/src/qdoc/doc/qdoc-manual-qdocconf.qdoc b/src/qdoc/doc/qdoc-manual-qdocconf.qdoc
index 7579a5598..bb4d9af47 100644
--- a/src/qdoc/doc/qdoc-manual-qdocconf.qdoc
+++ b/src/qdoc/doc/qdoc-manual-qdocconf.qdoc
@@ -410,8 +410,15 @@
\endcode
If you include the above in your qdocconf file for qtbase, there
- will be no qwidget.html generated for html and no qwidget.xml
- generated for DITA XML.
+ will be no class documentation generated for QWidget.
+
+ Since Qt 5.6, also simple wildcards ('*' and '?') are recognized by
+ \c excludefiles. For example, to exclude all private Qt header files
+ from being parsed, define the following:
+
+ \badcode
+ excludefiles += "*_p.h"
+ \endcode
See also \l {excludedirs-variable} {excludedirs}.