summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@digia.com>2013-08-20 13:55:28 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-22 16:11:29 +0200
commite4df7fc75ad16412b9fbe800b2d7a0b94bbfe8a7 (patch)
tree57e94263c8bd13c68c40c46d63e48d7677ef5deb
parentd9b5cead974d486e015872e73f918f0e68dda96e (diff)
qdoc: Fix the qdoc \include command
qdoc's \include command now works as expected. This command is only for including a file that contains qdoc comments that contain qdoc commands to be processed by qdoc. The file to be included should have the .qdocinc suffix, although qdoc will accept any suffix now. The file must be in one of the directories specified by the sourcedirs variable in the qdocconf file. Task-number: QTBUG-33046 Change-Id: I45ea08932b4218aae369469968117fb5132f764b Reviewed-by: Alex Blasche <alexander.blasche@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
-rw-r--r--doc/global/compat.qdocconf2
-rw-r--r--src/tools/qdoc/config.cpp30
-rw-r--r--src/tools/qdoc/config.h2
-rw-r--r--src/tools/qdoc/doc.cpp14
-rw-r--r--src/tools/qdoc/doc.h2
5 files changed, 44 insertions, 6 deletions
diff --git a/doc/global/compat.qdocconf b/doc/global/compat.qdocconf
index ec4cfaa7c8..12d061a28a 100644
--- a/doc/global/compat.qdocconf
+++ b/doc/global/compat.qdocconf
@@ -1,5 +1,3 @@
-alias.include = input
-
macro.0 = "\\\\0"
macro.n = "\\\\n"
macro.r = "\\\\r"
diff --git a/src/tools/qdoc/config.cpp b/src/tools/qdoc/config.cpp
index 8729bf387f..48be30c24e 100644
--- a/src/tools/qdoc/config.cpp
+++ b/src/tools/qdoc/config.cpp
@@ -181,6 +181,7 @@ QSet<QString> Config::overrideOutputFormats;
QMap<QString, QString> Config::extractedDirs;
int Config::numInstances;
QStack<QString> Config::workingDirs_;
+QMap<QString, QStringList> Config::includeFilesMap_;
/*!
\class Config
@@ -201,6 +202,7 @@ Config::Config(const QString& programName)
lastLocation_ = Location::null;
configVars_.clear();
numInstances++;
+ includeFilesMap_.clear();
}
/*!
@@ -208,6 +210,7 @@ Config::Config(const QString& programName)
*/
Config::~Config()
{
+ includeFilesMap_.clear();
}
/*!
@@ -589,6 +592,33 @@ void Config::subVarsAndValues(const QString& var, ConfigVarMultimap& t) const
}
/*!
+ Get all .qdocinc files.
+ */
+QString Config::getIncludeFilePath(const QString& fileName) const
+{
+ QString ext = fileName.mid(fileName.lastIndexOf('.'));
+ ext.prepend('*');
+
+ if (!includeFilesMap_.contains(ext)) {
+ QSet<QString> t;
+ QStringList result;
+ QStringList dirs = getCanonicalPathList(CONFIG_SOURCEDIRS);
+ QStringList::ConstIterator d = dirs.constBegin();
+ while (d != dirs.constEnd()) {
+ result += getFilesHere(*d, ext, location(), t, t);
+ ++d;
+ }
+ includeFilesMap_.insert(ext, result);
+ }
+ const QStringList& paths = (*includeFilesMap_.find(ext));
+ for (int i=0; i<paths.size(); ++i) {
+ if (paths[i].endsWith(fileName))
+ return paths[i];
+ }
+ return QString();
+}
+
+/*!
Builds and returns a list of file pathnames for the file
type specified by \a filesVar (e.g. "headers" or "sources").
The files are found in the directories specified by
diff --git a/src/tools/qdoc/config.h b/src/tools/qdoc/config.h
index 948f31c01a..6efff44442 100644
--- a/src/tools/qdoc/config.h
+++ b/src/tools/qdoc/config.h
@@ -112,6 +112,7 @@ public:
const QString& dirsVar,
const QSet<QString> &excludedDirs = QSet<QString>(),
const QSet<QString> &excludedFiles = QSet<QString>());
+ QString getIncludeFilePath(const QString& fileName) const;
QStringList getExampleQdocFiles(const QSet<QString> &excludedDirs, const QSet<QString> &excludedFiles);
QStringList getExampleImageFiles(const QSet<QString> &excludedDirs, const QSet<QString> &excludedFiles);
@@ -160,6 +161,7 @@ private:
static QMap<QString, QString> extractedDirs;
static int numInstances;
static QStack<QString> workingDirs_;
+ static QMap<QString, QStringList> includeFilesMap_;
};
#define CONFIG_ALIAS "alias"
diff --git a/src/tools/qdoc/doc.cpp b/src/tools/qdoc/doc.cpp
index 4d6b0b1a2c..1e0c66cd08 100644
--- a/src/tools/qdoc/doc.cpp
+++ b/src/tools/qdoc/doc.cpp
@@ -125,6 +125,7 @@ enum {
CMD_INCLUDE,
CMD_INLINEIMAGE,
CMD_INDEX,
+ CMD_INPUT,
CMD_KEYWORD,
CMD_L,
CMD_LEGALESE,
@@ -242,6 +243,7 @@ static struct {
{ "include", CMD_INCLUDE, 0 },
{ "inlineimage", CMD_INLINEIMAGE, 0 },
{ "index", CMD_INDEX, 0 }, // ### don't document for now
+ { "input", CMD_INPUT, 0 },
{ "keyword", CMD_KEYWORD, 0 },
{ "l", CMD_L, 0 },
{ "legalese", CMD_LEGALESE, 0 },
@@ -923,6 +925,7 @@ void DocParser::parse(const QString& source,
enterPara(Atom::ImportantLeft, Atom::ImportantRight);
break;
case CMD_INCLUDE:
+ case CMD_INPUT:
{
QString fileName = getArgument();
QString identifier = getRestOfLine();
@@ -1681,16 +1684,17 @@ void DocParser::insertTarget(const QString &target, bool keyword)
void DocParser::include(const QString& fileName, const QString& identifier)
{
if (location().depth() > 16)
- location().fatal(tr("Too many nested '\\%1's")
- .arg(cmdName(CMD_INCLUDE)));
+ location().fatal(tr("Too many nested '\\%1's").arg(cmdName(CMD_INCLUDE)));
QString userFriendlyFilePath;
- // ### use current directory?
+ QString filePath = Doc::config()->getIncludeFilePath(fileName);
+#if 0
QString filePath = Config::findFile(location(),
sourceFiles,
sourceDirs,
fileName,
userFriendlyFilePath);
+#endif
if (filePath.isEmpty()) {
location().warning(tr("Cannot find qdoc include file '%1'").arg(fileName));
}
@@ -3043,6 +3047,8 @@ const QStringMultiMap &Doc::metaTagMap() const
return priv && priv->extra ? priv->extra->metaMap : *null_QStringMultiMap();
}
+const Config* Doc::config_ = 0;
+
void Doc::initialize(const Config& config)
{
DocParser::tabSize = config.getInt(CONFIG_TABSIZE);
@@ -3053,8 +3059,8 @@ void Doc::initialize(const Config& config)
DocParser::quoting = config.getBool(CONFIG_QUOTINGINFORMATION);
QmlClassNode::qmlOnly = config.getBool(CONFIG_QMLONLY);
-
QStringMap reverseAliasMap;
+ config_ = &config;
QSet<QString> commands = config.subVars(CONFIG_ALIAS);
QSet<QString>::ConstIterator c = commands.constBegin();
diff --git a/src/tools/qdoc/doc.h b/src/tools/qdoc/doc.h
index bd3d623a05..65007634a6 100644
--- a/src/tools/qdoc/doc.h
+++ b/src/tools/qdoc/doc.h
@@ -189,10 +189,12 @@ public:
Quoter &quoter,
const QString &fileName);
static QString canonicalTitle(const QString &title);
+ static const Config* config() { return config_; }
private:
void detach();
DocPrivate *priv;
+ static const Config* config_;
};
typedef QList<Doc> DocList;