diff options
author | David Boddie <david.boddie@nokia.com> | 2011-03-29 11:10:47 (GMT) |
---|---|---|
committer | David Boddie <david.boddie@nokia.com> | 2011-03-29 11:10:47 (GMT) |
commit | 0ea9bd7d6100993bb4b06b4dedb799ae768cacdf (patch) | |
tree | 42f3d106fc104607d2e49a5196596baafee48c2a /tools/qdoc3 | |
parent | d38664f2ca736560a129a8ff09b293ecb83efac2 (diff) | |
parent | 5466b2eae16f55602b01021acb3e9e93184d44fa (diff) | |
download | Qt-0ea9bd7d6100993bb4b06b4dedb799ae768cacdf.zip Qt-0ea9bd7d6100993bb4b06b4dedb799ae768cacdf.tar.gz Qt-0ea9bd7d6100993bb4b06b4dedb799ae768cacdf.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-doc-team into 4.7
Diffstat (limited to 'tools/qdoc3')
-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 |
7 files changed, 116 insertions, 69 deletions
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 \ |