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>
This commit is contained in:
parent
d9b5cead97
commit
e4df7fc75a
@ -1,5 +1,3 @@
|
||||
alias.include = input
|
||||
|
||||
macro.0 = "\\\\0"
|
||||
macro.n = "\\\\n"
|
||||
macro.r = "\\\\r"
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -588,6 +591,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").
|
||||
|
@ -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"
|
||||
|
@ -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();
|
||||
|
@ -189,10 +189,12 @@ public:
|
||||
Quoter "er,
|
||||
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user