diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/linguist/lconvert/main.cpp | 2 | ||||
-rw-r--r-- | tools/linguist/lupdate/main.cpp | 71 | ||||
-rw-r--r-- | tools/qdoc3/config.cpp | 26 | ||||
-rw-r--r-- | tools/qdoc3/config.h | 3 | ||||
-rw-r--r-- | tools/qdoc3/ditaxmlgenerator.cpp | 35 | ||||
-rw-r--r-- | tools/qdoc3/ditaxmlgenerator.h | 3 | ||||
-rw-r--r-- | tools/qdoc3/doc/qdoc-manual.qdoc | 91 | ||||
-rw-r--r-- | tools/qdoc3/main.cpp | 20 | ||||
-rw-r--r-- | tools/qdoc3/test/qt-project.qdocconf | 7 |
9 files changed, 155 insertions, 103 deletions
diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index a10a42b..a9960fc 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -65,7 +65,7 @@ static int usage(const QStringList &args) foreach (Translator::FileFormat format, Translator::registeredFileFormats()) loaders += line.arg(format.extension, -5).arg(format.description); - std::cerr << qPrintable(LC::tr("\nUsage:\n" + std::cout << qPrintable(LC::tr("\nUsage:\n" " lconvert [options] <infile> [<infile>...]\n\n" "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" "stand-alone tool to convert and filter translation data files.\n" diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 15583e1..f8e6a90 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -61,6 +61,11 @@ static QString m_defaultExtensions; static void printOut(const QString & out) { + std::cout << qPrintable(out); +} + +static void printErr(const QString & out) +{ std::cerr << qPrintable(out); } @@ -151,23 +156,23 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil cd.m_sortContexts = !(options & NoSort); if (QFile(fileName).exists()) { if (!tor.load(fileName, cd, QLatin1String("auto"))) { - printOut(cd.error()); + printErr(cd.error()); *fail = true; continue; } tor.resolveDuplicates(); cd.clearErrors(); if (setCodec && fetchedTor.codec() != tor.codec()) - printOut(LU::tr("lupdate warning: Codec for tr() '%1' disagrees with" + printErr(LU::tr("lupdate warning: Codec for tr() '%1' disagrees with" " existing file's codec '%2'. Expect trouble.\n") .arg(QString::fromLatin1(fetchedTor.codecName()), QString::fromLatin1(tor.codecName()))); if (!targetLanguage.isEmpty() && targetLanguage != tor.languageCode()) - printOut(LU::tr("lupdate warning: Specified target language '%1' disagrees with" + printErr(LU::tr("lupdate warning: Specified target language '%1' disagrees with" " existing file's language '%2'. Ignoring.\n") .arg(targetLanguage, tor.languageCode())); if (!sourceLanguage.isEmpty() && sourceLanguage != tor.sourceLanguageCode()) - printOut(LU::tr("lupdate warning: Specified source language '%1' disagrees with" + printErr(LU::tr("lupdate warning: Specified source language '%1' disagrees with" " existing file's language '%2'. Ignoring.\n") .arg(sourceLanguage, tor.sourceLanguageCode())); } else { @@ -212,11 +217,11 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil out.normalizeTranslations(cd); if (!cd.errors().isEmpty()) { - printOut(cd.error()); + printErr(cd.error()); cd.clearErrors(); } if (!out.save(fileName, cd, QLatin1String("auto"))) { - printOut(cd.error()); + printErr(cd.error()); *fail = true; } } @@ -278,7 +283,7 @@ static void processSources(Translator &fetchedTor, } loadCPP(fetchedTor, sourceFilesCpp, cd); if (!cd.error().isEmpty()) - printOut(cd.error()); + printErr(cd.error()); } static void processProjects( @@ -298,7 +303,7 @@ static void processProject( if (!tmp.isEmpty()) { codecForSource = tmp.last().toLatin1(); if (!QTextCodec::codecForName(codecForSource)) { - printOut(LU::tr("lupdate warning: Codec for source '%1' is invalid." + printErr(LU::tr("lupdate warning: Codec for source '%1' is invalid." " Falling back to codec for tr().\n") .arg(QString::fromLatin1(codecForSource))); codecForSource.clear(); @@ -365,12 +370,12 @@ static void processProjects( if (visitor.contains(QLatin1String("TRANSLATIONS"))) { if (parentTor) { if (topLevel) { - std::cerr << qPrintable(LU::tr("lupdate warning: TS files from command line " - "will override TRANSLATIONS in %1.\n").arg(proFile)); + printErr(LU::tr("lupdate warning: TS files from command line " + "will override TRANSLATIONS in %1.\n").arg(proFile)); goto noTrans; } else if (nestComplain) { - std::cerr << qPrintable(LU::tr("lupdate warning: TS files from command line " - "prevent recursing into %1.\n").arg(proFile)); + printErr(LU::tr("lupdate warning: TS files from command line " + "prevent recursing into %1.\n").arg(proFile)); continue; } } @@ -401,8 +406,8 @@ static void processProjects( noTrans: if (!parentTor) { if (topLevel) - std::cerr << qPrintable(LU::tr("lupdate warning: no TS files specified. Only diagnostics " - "will be produced for '%1'.\n").arg(proFile)); + printErr(LU::tr("lupdate warning: no TS files specified. Only diagnostics " + "will be produced for '%1'.\n").arg(proFile)); Translator tor; processProject(nestComplain, pfi, visitor, options, codecForSource, targetLanguage, sourceLanguage, &tor, fail); @@ -471,7 +476,7 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-target-language")) { ++i; if (i == argc) { - printOut(LU::tr("The option -target-language requires a parameter.\n")); + printErr(LU::tr("The option -target-language requires a parameter.\n")); return 1; } targetLanguage = args[i]; @@ -479,7 +484,7 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-source-language")) { ++i; if (i == argc) { - printOut(LU::tr("The option -source-language requires a parameter.\n")); + printErr(LU::tr("The option -source-language requires a parameter.\n")); return 1; } sourceLanguage = args[i]; @@ -487,7 +492,7 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-disable-heuristic")) { ++i; if (i == argc) { - printOut(LU::tr("The option -disable-heuristic requires a parameter.\n")); + printErr(LU::tr("The option -disable-heuristic requires a parameter.\n")); return 1; } arg = args[i]; @@ -498,14 +503,14 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("number")) { options &= ~HeuristicNumber; } else { - printOut(LU::tr("Invalid heuristic name passed to -disable-heuristic.\n")); + printErr(LU::tr("Invalid heuristic name passed to -disable-heuristic.\n")); return 1; } continue; } else if (arg == QLatin1String("-locations")) { ++i; if (i == argc) { - printOut(LU::tr("The option -locations requires a parameter.\n")); + printErr(LU::tr("The option -locations requires a parameter.\n")); return 1; } if (args[i] == QLatin1String("none")) { @@ -515,7 +520,7 @@ int main(int argc, char **argv) } else if (args[i] == QLatin1String("absolute")) { options |= AbsoluteLocations; } else { - printOut(LU::tr("Invalid parameter passed to -locations.\n")); + printErr(LU::tr("Invalid parameter passed to -locations.\n")); return 1; } continue; @@ -541,7 +546,7 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-codecfortr")) { ++i; if (i == argc) { - printOut(LU::tr("The -codecfortr option should be followed by a codec name.\n")); + printErr(LU::tr("The -codecfortr option should be followed by a codec name.\n")); return 1; } codecForTr = args[i].toLatin1(); @@ -552,7 +557,7 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-extensions")) { ++i; if (i == argc) { - printOut(LU::tr("The -extensions option should be followed by an extension list.\n")); + printErr(LU::tr("The -extensions option should be followed by an extension list.\n")); return 1; } extensions = args[i]; @@ -560,7 +565,7 @@ int main(int argc, char **argv) } else if (arg == QLatin1String("-pro")) { ++i; if (i == argc) { - printOut(LU::tr("The -pro option should be followed by a filename of .pro file.\n")); + printErr(LU::tr("The -pro option should be followed by a filename of .pro file.\n")); return 1; } proFiles += args[i]; @@ -570,7 +575,7 @@ int main(int argc, char **argv) if (arg.length() == 2) { ++i; if (i == argc) { - printOut(LU::tr("The -I option should be followed by a path.\n")); + printErr(LU::tr("The -I option should be followed by a path.\n")); return 1; } includePath += args[i]; @@ -579,7 +584,7 @@ int main(int argc, char **argv) } continue; } else if (arg.startsWith(QLatin1String("-")) && arg != QLatin1String("-")) { - printOut(LU::tr("Unrecognized option '%1'.\n").arg(arg)); + printErr(LU::tr("Unrecognized option '%1'.\n").arg(arg)); return 1; } @@ -587,7 +592,7 @@ int main(int argc, char **argv) if (arg.startsWith(QLatin1String("@"))) { QFile lstFile(arg.mid(1)); if (!lstFile.open(QIODevice::ReadOnly)) { - printOut(LU::tr("lupdate error: List file '%1' is not readable.\n") + printErr(LU::tr("lupdate error: List file '%1' is not readable.\n") .arg(lstFile.fileName())); return 1; } @@ -605,7 +610,7 @@ int main(int argc, char **argv) if (!fi.exists() || fi.isWritable()) { tsFileNames.append(QFileInfo(file).absoluteFilePath()); } else { - printOut(LU::tr("lupdate warning: For some reason, '%1' is not writable.\n") + printErr(LU::tr("lupdate warning: For some reason, '%1' is not writable.\n") .arg(file)); } found = true; @@ -613,7 +618,7 @@ int main(int argc, char **argv) } } if (!found) { - printOut(LU::tr("lupdate error: File '%1' has no recognized extension.\n") + printErr(LU::tr("lupdate error: File '%1' has no recognized extension.\n") .arg(file)); return 1; } @@ -623,7 +628,7 @@ int main(int argc, char **argv) foreach (const QString &file, files) { QFileInfo fi(file); if (!fi.exists()) { - printOut(LU::tr("lupdate error: File '%1' does not exist.\n").arg(file)); + printErr(LU::tr("lupdate error: File '%1' does not exist.\n").arg(file)); return 1; } if (file.endsWith(QLatin1String(".pro"), Qt::CaseInsensitive) @@ -682,15 +687,15 @@ int main(int argc, char **argv) } if (!targetLanguage.isEmpty() && tsFileNames.count() != 1) - printOut(LU::tr("lupdate warning: -target-language usually only" + printErr(LU::tr("lupdate warning: -target-language usually only" " makes sense with exactly one TS file.\n")); if (!codecForTr.isEmpty() && tsFileNames.isEmpty()) - printOut(LU::tr("lupdate warning: -codecfortr has no effect without -ts.\n")); + printErr(LU::tr("lupdate warning: -codecfortr has no effect without -ts.\n")); bool fail = false; if (proFiles.isEmpty()) { if (tsFileNames.isEmpty()) - printOut(LU::tr("lupdate warning:" + printErr(LU::tr("lupdate warning:" " no TS files specified. Only diagnostics will be produced.\n")); Translator fetchedTor; @@ -705,7 +710,7 @@ int main(int argc, char **argv) sourceLanguage, targetLanguage, options, &fail); } else { if (!sourceFiles.isEmpty() || !includePath.isEmpty()) { - printOut(LU::tr("lupdate error:" + printErr(LU::tr("lupdate error:" " Both project and source files / include paths specified.\n")); return 1; } diff --git a/tools/qdoc3/config.cpp b/tools/qdoc3/config.cpp index 08a8187..267a09c 100644 --- a/tools/qdoc3/config.cpp +++ b/tools/qdoc3/config.cpp @@ -329,7 +329,10 @@ QList<QRegExp> Config::getRegExpList(const QString& var) const } /*! - This function is slower than it could be. + This function is slower than it could be. What it does is + find all the keys that begin with \a var + dot and return + the matching keys in a set, stripped of the matching prefix + and dot. */ QSet<QString> Config::subVars(const QString& var) const { @@ -350,6 +353,27 @@ QSet<QString> Config::subVars(const QString& var) const } /*! + Same as subVars(), but in this case we return a string map + with the matching keys (stripped of the prefix \a var and + mapped to their values. The pairs are inserted into \a t + */ +void Config::subVarsAndValues(const QString& var, QStringMap& t) const +{ + QString varDot = var + QLatin1Char('.'); + QMap<QString, QString>::ConstIterator v = stringValueMap.begin(); + while (v != stringValueMap.end()) { + if (v.key().startsWith(varDot)) { + QString subVar = v.key().mid(varDot.length()); + int dot = subVar.indexOf(QLatin1Char('.')); + if (dot != -1) + subVar.truncate(dot); + t.insert(subVar,v.value()); + } + ++v; + } +} + +/*! 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/tools/qdoc3/config.h b/tools/qdoc3/config.h index 9ebc0f8..767acb1 100644 --- a/tools/qdoc3/config.h +++ b/tools/qdoc3/config.h @@ -54,6 +54,8 @@ QT_BEGIN_NAMESPACE +typedef QMap<QString,QString> QStringMap; + class Config { public: @@ -74,6 +76,7 @@ class Config QRegExp getRegExp(const QString& var) const; QList<QRegExp> getRegExpList(const QString& var) const; QSet<QString> subVars(const QString& var) const; + void subVarsAndValues(const QString& var, QStringMap& t) const; QStringList getAllFiles(const QString& filesVar, const QString& dirsVar, const QSet<QString> &excludedDirs = QSet<QString>()); diff --git a/tools/qdoc3/ditaxmlgenerator.cpp b/tools/qdoc3/ditaxmlgenerator.cpp index 018cbc7..4b4f776 100644 --- a/tools/qdoc3/ditaxmlgenerator.cpp +++ b/tools/qdoc3/ditaxmlgenerator.cpp @@ -482,6 +482,7 @@ void DitaXmlGenerator::initializeGenerator(const Config &config) if (naturalLanguage.isEmpty()) naturalLanguage = QLatin1String("en"); + config.subVarsAndValues("dita.metadata.default",metadataDefaults); QSet<QString> editionNames = config.subVars(CONFIG_EDITION); QSet<QString>::ConstIterator edition = editionNames.begin(); while (edition != editionNames.end()) { @@ -5577,7 +5578,7 @@ bool DitaXmlGenerator::writeMetadataElement(const InnerNode* inner, QStringMap& metaTagMap = const_cast<QStringMap&>(inner->doc().metaTagMap()); QStringMap::iterator i = metaTagMap.find(ditaTags[t]); if (i == metaTagMap.end()) { - // get the default author, if there is one. + s = metadataDefault(t); } else { s = i.value(); @@ -5610,10 +5611,22 @@ QString DitaXmlGenerator::getMetadataElement(const InnerNode* inner, DitaXmlGene s = i.value(); metaTagMap.erase(i); } + else { + s = metadataDefault(t); + } return s; } /*! + Returns the value of key \a t or an empty string + if \a t is not found in the map. + */ +QString DitaXmlGenerator::metadataDefault(DitaTag t) const +{ + return metadataDefaults.value(ditaTags[t]); +} + +/*! Writes the <prolog> element for the \a inner node using the \a marker. The <prolog> element contains the <metadata> element, plus some others. This @@ -5625,10 +5638,10 @@ QString DitaXmlGenerator::getMetadataElement(const InnerNode* inner, DitaXmlGene \o <brand> \o <category> * \o <compomnent> * - \o <copyrholder> - \o <copyright> + \o <copyrholder> * + \o <copyright> * \o <created> - \o <copyryear> + \o <copyryear> * \o <critdates> \o <keyword> \o <keywords> @@ -5661,24 +5674,18 @@ DitaXmlGenerator::writeProlog(const InnerNode* inner, CodeMarker* marker) writeMetadataElement(inner,DT_author); writeMetadataElement(inner,DT_publisher); QString s = getMetadataElement(inner,DT_copyryear); - if (s.isEmpty()) { - s = "2011"; // zzz - } QString t = getMetadataElement(inner,DT_copyrholder); - if (t.isEmpty()) { - t = "Nokia"; // zzz - } writeStartTag(DT_copyright); writeStartTag(DT_copyryear); - xmlWriter().writeAttribute("year",s); + if (!s.isEmpty()) + xmlWriter().writeAttribute("year",s); writeEndTag(); // </copyryear> writeStartTag(DT_copyrholder); - xmlWriter().writeCharacters(t); + if (!s.isEmpty()) + xmlWriter().writeCharacters(t); writeEndTag(); // </copyrholder> writeEndTag(); // </copyright> s = getMetadataElement(inner,DT_permissions); - if (s.isEmpty()) - s = "all"; writeStartTag(DT_permissions); xmlWriter().writeAttribute("view",s); writeEndTag(); // </permissions> diff --git a/tools/qdoc3/ditaxmlgenerator.h b/tools/qdoc3/ditaxmlgenerator.h index 972688a..c7400bb 100644 --- a/tools/qdoc3/ditaxmlgenerator.h +++ b/tools/qdoc3/ditaxmlgenerator.h @@ -447,7 +447,7 @@ class DitaXmlGenerator : public PageGenerator int leaveSection(); bool inSection() const { return (sectionNestingLevel > 0); } int currentSectionNestingLevel() const { return sectionNestingLevel; } - + QString metadataDefault(DitaTag t) const; private: /* @@ -516,6 +516,7 @@ class DitaXmlGenerator : public PageGenerator static QString ditaTags[]; QStack<QXmlStreamWriter*> xmlWriterStack; QStack<DitaTag> tagStack; + QStringMap metadataDefaults; }; #define DITAXMLGENERATOR_ADDRESS "address" diff --git a/tools/qdoc3/doc/qdoc-manual.qdoc b/tools/qdoc3/doc/qdoc-manual.qdoc index 712dcea..0fbd4b7 100644 --- a/tools/qdoc3/doc/qdoc-manual.qdoc +++ b/tools/qdoc3/doc/qdoc-manual.qdoc @@ -141,13 +141,16 @@ \c {/current/dir$ ../../bin/qdoc3 ./config.qdocconf} \endquotation - \c{config.qdocconf} is your \l{The QDoc Configuration File} {QDoc - configuration file}. The configuration file is where tell QDoc - where to find the source files from which it will extract the QDoc - comments it will use to generate the documentation. It is also - where you tell QDoc what kind of output to generate (HTML, DITA - XML,...), and where to put the generated output. The configuration - file also contains other information for QDoc. + In the command line above, \c{config.qdocconf} is a \l{The QDoc + Configuration File} {QDoc configuration file}. The configuration + file is where you tell QDoc where to find the source files that + contain the QDoc comments that will become the documentation. It + is also where you tell QDoc what kind of output to generate (HTML, + DITA XML,...), and where to put the generated output. The + configuration file also contains other information for QDoc. + + See \l{The QDoc Configuration File} for a instructions on how ro + build a Qdoc configuration file. \section1 Command Types @@ -6740,59 +6743,41 @@ \title The QDoc Configuration File - Before running QDoc to to extract and format your QDOC comments, - you must create a QDoc configuration file to tell QDoc where to find - them. + Before running QDoc, you must create a QDoc configuration file to + tell QDoc where to find the source files that contain the QDoc + comments. The pathname to your configuration file is passed to + QDoc on the command line: - \list - \o \l {Supporting Derived Projects} - \o \l {Compatibility Issues} - \endlist - - When running QDoc to generate the documentation, you must specify - a configuration file on the command line: + \quotation + \c {/current/dir$ ../../bin/qdoc3 ./config.qdocconf} + \endquotation \section1 General Description - The configuration file is a list of entries of entries of the form - \e {"variable = value"}. Using the configuration variables, you - can define where QDoc should find the various source files, images - and examples, where to put generated documentation etc. The + The configuration file is a list of entries of the form \e + {"variable = value"}. Using the configuration variables, you can + define where QDoc should find the various source files, images and + examples, where to put generated documentation etc. The configuration file can also contain directives like \c include. For an example, see the \l minimum.qdocconf file. - In addition, you can use some particular configuration variables - to make QDoc support derived projects, i.e make the projects, for - example Qt Solutions, contain links to the online Qt - documentation. These variables are documented in the \l - {Supporting Derived projects} section. In this section you can - also find out how to use these variables to support your derived - projects. - - If some of the variable keys have the same values, they can be set - at the same time. - - \code - {header, source}dirs = kernel - \endcode - - is equivalent to - - \code - headerdirs = kernel - sourcedirs = kernel - \endcode - - A variable's value can be set using either '=' or '+='. The - difference is that '=' overrides any previously set value, while - '+=' only adds the value to the previously set ones. - - In general, some of the variables accepts a list of strings as - their value, while others only accept a single string. If you - provide a variable of the latter type with several strings they - will simply be concatenated. The quotes around the value string - are optional. But applying them allows you to use special - characters like '=' and ' \" ' within the string. + You can also use configuration variables to get QDoc to support + \l{Supporting Derived Projects} {derived projects}, i.e QDoc can + generate links in your project's documentation to elements in the + Qt online documentation. See the \l {Supporting Derived projects} + section. + + The value of a configuration variable can be set using either '=' + or '+='. The difference is that '=' overrides the previous value, + while '+=' adds a new value to the current one. + + Some configuration variables accept a list of strings as their + value, e.g. + \l {22-qdoc-configuration-generalvariables.html#sourcedirs-variable} + {\c{sourcedirs}}, while others accept only a single string. Double + quotes around a value string are optional, but including them allows + you to use special characters like '=' and ' \" ' within the valuem + string, e.g.: \code HTML.postheader = "<a href=\"index.html\">Home</a>" diff --git a/tools/qdoc3/main.cpp b/tools/qdoc3/main.cpp index 7eb8067..52715a3 100644 --- a/tools/qdoc3/main.cpp +++ b/tools/qdoc3/main.cpp @@ -235,6 +235,26 @@ static void processQdocconfFile(const QString &fileName) QStringList indexFiles = config.getStringList(CONFIG_INDEXES); tree->readIndexes(indexFiles); +#if 0 + /* + I think we won't beusing this... + + Read the list of DITA excluded directories. + */ + QSet<QString> ditaExcludedDirs; + QStringList ditaExcludedDirsList = config.getStringList("dita.metadata.excludedirs"); + foreach (const QString &t, ditaExcludedDirsList) + ditaExcludedDirs.insert(QDir::fromNativeSeparators(t)); + + if (!ditaExcludedDirs.isEmpty()) { + QSet<QString>::iterator i = ditaExcludedDirs.begin(); + while (i != ditaExcludedDirs.end()) { + qDebug() << "DITA EXCLUDED DIR:" << (*i); + ++i; + } + } +#endif + /* Read the list of excluded directories. */ diff --git a/tools/qdoc3/test/qt-project.qdocconf b/tools/qdoc3/test/qt-project.qdocconf index 2f6ab9d..9c18608 100644 --- a/tools/qdoc3/test/qt-project.qdocconf +++ b/tools/qdoc3/test/qt-project.qdocconf @@ -35,6 +35,13 @@ qhp.Qt.subprojects.examples.title = Tutorials and Examples qhp.Qt.subprojects.examples.indexTitle = Qt Examples qhp.Qt.subprojects.examples.selectors = fake:example +dita.metadata.default.author = Qt Development Frameworks +dita.metadata.default.permissions = all +dita.metadata.default.publisher = Nokia +dita.metadata.default.copyryear = 2011 +dita.metadata.default.copyrholder = Nokia +dita.metadata.default.audience = programmer + language = Cpp headerdirs = $QT_SOURCE_TREE/src \ |