summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-03-01 15:41:49 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2011-03-01 15:55:19 -0300
commitd401ac2ad96082211c48b584a11c51c0c81a837c (patch)
treee1dc0bbfbfe35a8f253b7b7d0eca9a2b5ec95193
parent14ae00ad2aab93770bd7b023fbb247e606019757 (diff)
documentation-code-snippets-dir option now accepts multiple directories.
-rw-r--r--generators/qtdoc/qtdocgenerator.cpp35
-rw-r--r--generators/qtdoc/qtdocgenerator.h9
2 files changed, 35 insertions, 9 deletions
diff --git a/generators/qtdoc/qtdocgenerator.cpp b/generators/qtdoc/qtdocgenerator.cpp
index 016090fc..04e648be 100644
--- a/generators/qtdoc/qtdocgenerator.cpp
+++ b/generators/qtdoc/qtdocgenerator.cpp
@@ -213,12 +213,31 @@ QString QtXmlToSphinx::transform(const QString& doc)
return retval;
}
-QString QtXmlToSphinx::readFromLocation(QString& location, QString& identifier)
+QString QtXmlToSphinx::readFromLocations(const QStringList& locations, const QString& path, const QString& identifier)
+{
+ QString result;
+ bool ok;
+ foreach (QString location, locations) {
+ location.append('/');
+ location.append(path);
+ result = readFromLocation(location, identifier, &ok);
+ if (ok)
+ break;
+ }
+ if (!ok)
+ ReportHandler::warning("Couldn't read code snippet file: {"+ locations.join("|") + '}' + path);
+ return result;
+}
+
+QString QtXmlToSphinx::readFromLocation(const QString& location, const QString& identifier, bool* ok)
{
QFile inputFile;
inputFile.setFileName(location);
if (!inputFile.open(QIODevice::ReadOnly)) {
- ReportHandler::warning("Couldn't read code snippet file: "+inputFile.fileName());
+ if (!ok)
+ ReportHandler::warning("Couldn't read code snippet file: "+inputFile.fileName());
+ else
+ *ok = false;
return QString();
}
@@ -246,6 +265,8 @@ QString QtXmlToSphinx::readFromLocation(QString& location, QString& identifier)
if (code.isEmpty())
ReportHandler::warning("Code snippet file found ("+location+"), but snippet "+ identifier +" not found.");
+ if (ok)
+ *ok = true;
return code;
}
@@ -345,8 +366,7 @@ void QtXmlToSphinx::handleSnippetTag(QXmlStreamReader& reader)
}
QString location = reader.attributes().value("location").toString();
QString identifier = reader.attributes().value("identifier").toString();
- location.prepend(m_generator->codeSnippetDir() + '/');
- QString code = readFromLocation(location, identifier);
+ QString code = readFromLocations(m_generator->codeSnippetDirs(), location, identifier);
if (!consecutiveSnippet)
m_output << INDENT << "::\n\n";
@@ -1406,7 +1426,12 @@ bool QtDocGenerator::doSetup(const QMap<QString, QString>& args)
{
m_libSourceDir = args.value("library-source-dir");
m_docDataDir = args.value("documentation-data-dir");
- m_codeSnippetDir = args.value("documentation-code-snippets-dir", m_libSourceDir);
+#ifdef __WIN32__
+# define PATH_SEP ";"
+#else
+# define PATH_SEP ":"
+#endif
+ m_codeSnippetDirs = args.value("documentation-code-snippets-dir", m_libSourceDir).split(PATH_SEP);
m_extraSectionDir = args.value("documentation-extra-sections-dir");
if (m_libSourceDir.isEmpty() || m_docDataDir.isEmpty()) {
diff --git a/generators/qtdoc/qtdocgenerator.h b/generators/qtdoc/qtdocgenerator.h
index dd2091d7..f8805577 100644
--- a/generators/qtdoc/qtdocgenerator.h
+++ b/generators/qtdoc/qtdocgenerator.h
@@ -141,7 +141,8 @@ private:
QString m_lastTagName;
QString m_opened_anchor;
- QString readFromLocation(QString& location, QString& identifier);
+ QString readFromLocations(const QStringList& locations, const QString& path, const QString& identifier);
+ QString readFromLocation(const QString& location, const QString& identifier, bool* ok = 0);
void pushOutputBuffer();
QString popOutputBuffer();
void writeTable(Table& table);
@@ -177,9 +178,9 @@ public:
QMap<QString, QString> options() const;
- QString codeSnippetDir() const
+ QStringList codeSnippetDirs() const
{
- return m_codeSnippetDir;
+ return m_codeSnippetDirs;
}
protected:
@@ -212,7 +213,7 @@ private:
QString m_docDataDir;
QString m_libSourceDir;
- QString m_codeSnippetDir;
+ QStringList m_codeSnippetDirs;
QString m_extraSectionDir;
QStringList m_functionList;
QMap<QString, QStringList> m_packages;