diff options
author | Jan-Arve Saether <jan-arve.saether@nokia.com> | 2012-08-17 11:52:40 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-17 19:31:50 +0200 |
commit | 526da72e991e11205436a6363b6cfb6948a0eb0c (patch) | |
tree | 1fd22bbbeee38b4ea00ce0abf437b69385f4de9a /src/tools/qdoc/config.cpp | |
parent | 8160ca6dfd5332993e22fc82597aac947f335ee6 (diff) |
Fix a bug in qdocs handling of excludedirs
The bug was there because the way qdoc tries to exclude the directories
given in the "excludedirs" variable:
It did a simple string comparision on the candidate path (to include)
with every string in the "excludedirs" variable.
However, this did not work for all cases, since the paths are not
canonicalized.
For instance, the problem I faced was that the following qdocconf
fragment: (config file located in doc/qtwidgets.qdocconf)
sourcedirs += ..
excludedirs += snippets
Since qdoc would recursively parse all subfolders of sourcedirs, it
would at one point visit the snippets folder, but it would have the
relative path "../doc/snippets", which did not match with "snippets",
causing snippets to not be excluded.
In addition, it seems that qdoc tries hard not to use absolute paths
(maybe because of more human-friendly error messages). I therefore
chose to canonicalize the relative paths.
As a side-effect this also give a better output from qdoc, as
../doc/foo.qdoc:42: Missing link
will become
foo.qdoc:42: Missing link
Change-Id: If9c25fa569abd03542bd12675acd44d8f4e0282c
Reviewed-by: Martin Smith <martin.smith@nokia.com>
Diffstat (limited to 'src/tools/qdoc/config.cpp')
-rw-r--r-- | src/tools/qdoc/config.cpp | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp index f2e66311a8..7daf84dc4e 100644 --- a/src/tools/qdoc/config.cpp +++ b/src/tools/qdoc/config.cpp @@ -327,6 +327,32 @@ QStringList Config::getStringList(const QString& var) const return stringListValueMap[var]; } + +/*! + \brief Returns the a path list where all paths are canonicalized, then + made relative to the config file. + \param var The variable containing the list of paths. + \see Location::canonicalRelativePath() + */ +QStringList Config::getCanonicalRelativePathList(const QString& var) const +{ + if (!locMap[var].isEmpty()) + (Location&) lastLoc = locMap[var]; + QStringList t; + QMap<QString,QStringList>::const_iterator it = stringListValueMap.constFind(var); + if (it != stringListValueMap.constEnd()) { + const QStringList& sl = it.value(); + if (!sl.isEmpty()) { + t.reserve(sl.size()); + for (int i=0; i<sl.size(); ++i) { + const QString &canonicalized = location().canonicalRelativePath(sl[i]); + t.append(canonicalized); + } + } + } + return t; +} + /*! This function should only be called when the configuration variable \a var maps to a string list that contains file paths. @@ -465,13 +491,13 @@ QStringList Config::getAllFiles(const QString &filesVar, const QSet<QString> &excludedFiles) { QStringList result = getStringList(filesVar); - QStringList dirs = getStringList(dirsVar); + QStringList dirs = getCanonicalRelativePathList(dirsVar); QString nameFilter = getString(filesVar + dot + QLatin1String(CONFIG_FILEEXTENSIONS)); QStringList::ConstIterator d = dirs.constBegin(); while (d != dirs.constEnd()) { - result += getFilesHere(*d, nameFilter, excludedDirs, excludedFiles); + result += getFilesHere(*d, nameFilter, location(), excludedDirs, excludedFiles); ++d; } return result; @@ -487,7 +513,7 @@ QStringList Config::getExampleQdocFiles() QStringList::ConstIterator d = dirs.constBegin(); while (d != dirs.constEnd()) { - result += getFilesHere(*d, nameFilter, excludedDirs, excludedFiles); + result += getFilesHere(*d, nameFilter, location(), excludedDirs, excludedFiles); ++d; } return result; @@ -948,10 +974,12 @@ void Config::load(Location location, const QString& fileName) QStringList Config::getFilesHere(const QString& uncleanDir, const QString& nameFilter, + const Location &location, const QSet<QString> &excludedDirs, const QSet<QString> &excludedFiles) { - QString dir = QDir::cleanPath(uncleanDir); + // + QString dir = location.isEmpty() ? QDir::cleanPath(uncleanDir) : location.canonicalRelativePath(uncleanDir); QStringList result; if (excludedDirs.contains(dir)) return result; @@ -981,7 +1009,7 @@ QStringList Config::getFilesHere(const QString& uncleanDir, fileNames = dirInfo.entryList(); fn = fileNames.constBegin(); while (fn != fileNames.constEnd()) { - result += getFilesHere(dirInfo.filePath(*fn), nameFilter, excludedDirs, excludedFiles); + result += getFilesHere(dirInfo.filePath(*fn), nameFilter, location, excludedDirs, excludedFiles); ++fn; } return result; |