qdoc: better copying of .css files

This fix searches for the css files specified in the
stylesheets variable. It searches for them in the
directory specified as the templatedir. It copies
them into the style subdirectory of the outputdir.

It also tests QT_INSTALL_DOCS before setting it to
the library info. If it was set on the command line,
it is not set from the library info.

This change also includes some debug code, which
will be removed after testing.

Task-number: QTBUG-27878
Change-Id: I7a9469b840e13b966aca44b99aebba102e5d4f0c
Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
This commit is contained in:
Martin Smith 2012-11-09 15:33:02 +01:00
parent 80f91f4e1b
commit 6326746d22
4 changed files with 27 additions and 9 deletions

View File

@ -50,6 +50,7 @@
#include <qtextstream.h> #include <qtextstream.h>
#include <qdebug.h> #include <qdebug.h>
#include "config.h" #include "config.h"
#include "generator.h"
#include <stdlib.h> #include <stdlib.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -148,6 +149,7 @@ QStringList MetaStack::getExpanded(const Location& location)
} }
QT_STATIC_CONST_IMPL QString Config::dot = QLatin1String("."); QT_STATIC_CONST_IMPL QString Config::dot = QLatin1String(".");
bool Config::debug = false;
bool Config::generateExamples = true; bool Config::generateExamples = true;
QString Config::overrideOutputDir; QString Config::overrideOutputDir;
QString Config::installDir; QString Config::installDir;
@ -548,6 +550,10 @@ QString Config::findFile(const Location& location,
const QString& fileName, const QString& fileName,
QString& userFriendlyFilePath) QString& userFriendlyFilePath)
{ {
if (debug)
qDebug() << "FILES:" << files
<< "DIRS:" << dirs
<< "FILENAME:" << fileName;
if (fileName.isEmpty() || fileName.startsWith(QLatin1Char('/'))) { if (fileName.isEmpty() || fileName.startsWith(QLatin1Char('/'))) {
userFriendlyFilePath = fileName; userFriendlyFilePath = fileName;
return fileName; return fileName;
@ -572,6 +578,8 @@ QString Config::findFile(const Location& location,
if (fileInfo.fileName().isEmpty()) { if (fileInfo.fileName().isEmpty()) {
QStringList::ConstIterator d = dirs.constBegin(); QStringList::ConstIterator d = dirs.constBegin();
while (d != dirs.constEnd()) { while (d != dirs.constEnd()) {
if (debug)
qDebug() << "TEST:" << QDir(*d).absolutePath() << firstComponent;
fileInfo.setFile(QDir(*d), firstComponent); fileInfo.setFile(QDir(*d), firstComponent);
if (fileInfo.exists()) { if (fileInfo.exists()) {
break; break;
@ -853,9 +861,7 @@ void Config::load(Location location, const QString& fileName)
/* /*
Here is the recursive call. Here is the recursive call.
*/ */
load(location, load(location, QFileInfo(QFileInfo(fileName).dir(), includeFile).filePath());
QFileInfo(QFileInfo(fileName).dir(), includeFile)
.filePath());
} }
else { else {
/* /*

View File

@ -114,6 +114,7 @@ public:
QT_STATIC_CONST QString dot; QT_STATIC_CONST QString dot;
static bool debug;
static bool generateExamples; static bool generateExamples;
static QString installDir; static QString installDir;
static QString overrideOutputDir; static QString overrideOutputDir;

View File

@ -1548,10 +1548,10 @@ void Generator::initialize(const Config &config)
// Documentation template handling // Documentation template handling
QStringList searchDirs; QStringList searchDirs;
QString templateDir = config.getString((*g)->format() + Config::dot + CONFIG_TEMPLATEDIR); QString templateDir = config.getString((*g)->format() + Config::dot + CONFIG_TEMPLATEDIR);
qDebug() << "TEMPLATEDIR:" << templateDir << (*g)->format() + Config::dot + CONFIG_TEMPLATEDIR;
if (templateDir.isEmpty()) if (templateDir.isEmpty())
templateDir = "."; templateDir = ".";
searchDirs.append(templateDir); searchDirs.append(templateDir);
QStringList noExts; QStringList noExts;
QStringList scripts = config.getCleanPathList((*g)->format()+Config::dot+CONFIG_SCRIPTS); QStringList scripts = config.getCleanPathList((*g)->format()+Config::dot+CONFIG_SCRIPTS);
e = scripts.constBegin(); e = scripts.constBegin();
@ -1573,6 +1573,10 @@ void Generator::initialize(const Config &config)
} }
QStringList styles = config.getCleanPathList((*g)->format()+Config::dot+CONFIG_STYLESHEETS); QStringList styles = config.getCleanPathList((*g)->format()+Config::dot+CONFIG_STYLESHEETS);
qDebug() << "STYLES:" << styles;
qDebug() << "SEARCHDIRS:" << searchDirs;
qDebug() << "STYLEFILES:" << styleFiles;
Config::debug = true;
e = styles.constBegin(); e = styles.constBegin();
while (e != styles.constEnd()) { while (e != styles.constEnd()) {
QString userFriendlyFilePath; QString userFriendlyFilePath;
@ -1582,6 +1586,7 @@ void Generator::initialize(const Config &config)
*e, *e,
noExts, noExts,
userFriendlyFilePath); userFriendlyFilePath);
qDebug() << "FILEPATH:" << filePath;
if (!filePath.isEmpty()) if (!filePath.isEmpty())
Config::copyFile(config.lastLocation(), Config::copyFile(config.lastLocation(),
filePath, filePath,
@ -1590,6 +1595,7 @@ void Generator::initialize(const Config &config)
"/style"); "/style");
++e; ++e;
} }
Config::debug = false;
} }
++g; ++g;
} }

View File

@ -261,11 +261,16 @@ static void processQdocconfFile(const QString &fileName)
config.setStringList(CONFIG_NOLINKERRORS, QStringList(noLinkErrors ? "true" : "false")); config.setStringList(CONFIG_NOLINKERRORS, QStringList(noLinkErrors ? "true" : "false"));
config.setStringList(CONFIG_OBSOLETELINKS, QStringList(obsoleteLinks ? "true" : "false")); config.setStringList(CONFIG_OBSOLETELINKS, QStringList(obsoleteLinks ? "true" : "false"));
documentationPath = QLibraryInfo::rawLocation(QLibraryInfo::DocumentationPath, /*
QLibraryInfo::EffectivePaths); If QT_INSTALL_DOCS is not set, set it here so it can be used from
the qdocconf files.
// Set a few environment variables that can be used from the qdocconf file */
qputenv("QT_INSTALL_DOCS", documentationPath.toLatin1()); QString qt_install_docs = qgetenv("QT_INSTALL_DOCS");
if (qt_install_docs.isEmpty()) {
documentationPath = QLibraryInfo::rawLocation(QLibraryInfo::DocumentationPath,
QLibraryInfo::EffectivePaths);
qputenv("QT_INSTALL_DOCS", documentationPath.toLatin1());
}
/* /*
With the default configuration values in place, load With the default configuration values in place, load