summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@nokia.com>2011-03-25 11:29:10 (GMT)
committerMartin Smith <martin.smith@nokia.com>2011-03-25 11:29:10 (GMT)
commitfc90a00874ee01d84237a9b0e0fda706da258fdb (patch)
treeb34189842958568cb1d1bb3e4da5f047f37a4cc8
parenteee16e58aa0255552a5dab7aa46dae66470e04a5 (diff)
downloadQt-fc90a00874ee01d84237a9b0e0fda706da258fdb.zip
Qt-fc90a00874ee01d84237a9b0e0fda706da258fdb.tar.gz
Qt-fc90a00874ee01d84237a9b0e0fda706da258fdb.tar.bz2
qdoc: Added default values to config file for DITA
Also added the handling of these default values: 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
-rw-r--r--src/gui/kernel/qwidget.cpp3
-rw-r--r--tools/qdoc3/config.cpp26
-rw-r--r--tools/qdoc3/config.h3
-rw-r--r--tools/qdoc3/ditaxmlgenerator.cpp35
-rw-r--r--tools/qdoc3/ditaxmlgenerator.h3
-rw-r--r--tools/qdoc3/test/qt-project.qdocconf7
6 files changed, 61 insertions, 16 deletions
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 18255a1..6a44bcc 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -598,6 +598,9 @@ void QWidget::setAutoFillBackground(bool enabled)
\ingroup basicwidgets
+ \meta {technology} {User Interface}
+ \meta {platform} {all}
+
The widget is the atom of the user interface: it receives mouse, keyboard
and other events from the window system, and paints a representation of
itself on the screen. Every widget is rectangular, and they are sorted in a
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/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 \