Doc: Added \qtvariable command to QDoc.

Specifies the QT variable needed in the .pro file.
The argument of the command is the qmake QT variable.

To use, add "\qtvariable <value>" to a QDoc comment
which contains the \module command.
QDoc will then associate the class with the QT variable.

Only supported for C++ classes at the moment.
Part of work done for QTBUG-32172

Task-number: QTBUG-32172
Change-Id: Ia8eea30fcfc771191c23a5f5994a48732959ea49
Reviewed-by: Martin Smith <martin.smith@digia.com>
This commit is contained in:
Jerome Pasion 2013-07-31 18:43:42 +02:00 committed by The Qt Project
parent 0ace311213
commit e4f99e0285
4 changed files with 36 additions and 7 deletions

View File

@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE
#define COMMAND_PAGEKEYWORDS Doc::alias(QLatin1String("pagekeywords"))
#define COMMAND_PRELIMINARY Doc::alias(QLatin1String("preliminary"))
#define COMMAND_INPUBLICGROUP Doc::alias(QLatin1String("inpublicgroup"))
#define COMMAND_QTVARIABLE Doc::alias(QLatin1String("qtvariable"))
#define COMMAND_REENTRANT Doc::alias(QLatin1String("reentrant"))
#define COMMAND_SINCE Doc::alias(QLatin1String("since"))
#define COMMAND_SUBTITLE Doc::alias(QLatin1String("subtitle"))
@ -218,6 +219,7 @@ const QSet<QString>& CodeParser::commonMetaCommands()
<< COMMAND_PAGEKEYWORDS
<< COMMAND_PRELIMINARY
<< COMMAND_INPUBLICGROUP
<< COMMAND_QTVARIABLE
<< COMMAND_REENTRANT
<< COMMAND_SINCE
<< COMMAND_SUBTITLE
@ -321,6 +323,15 @@ void CodeParser::processCommonMetaCommand(const Location& location,
else
location.warning(tr("Ignored '\\%1'").arg(COMMAND_TITLE));
}
else if (command == COMMAND_QTVARIABLE) {
if (node->subType() == Node::Module) {
DocNode *dn = static_cast<DocNode *>(node);
dn->setQtVariable(arg.first);
}
else
location.warning(tr("Command '\\%1' found outside of '\\module'. It can only be used within a module page.")
.arg(COMMAND_QTVARIABLE));
}
}
/*!

View File

@ -241,6 +241,7 @@ protected:
#define COMMAND_LICENSENAME Doc::alias("licensename")
#define COMMAND_LICENSEDESCRIPTION Doc::alias("licensedescription")
#define COMMAND_RELEASEDATE Doc::alias("releasedate")
#define COMMAND_QTVARIABLE Doc::alias("qtvariable")
QT_END_NAMESPACE

View File

@ -1835,11 +1835,12 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker)
QMap<QString, Text> requisites;
Text text;
const QString headerText = "Header:";
const QString sinceText = "Since:";
const QString inheritedBytext = "Inherited By:";
const QString inheritsText = "Inherits:";
const QString instantiatedByText = "Instantiated By:";
const QString headerText = "Header";
const QString sinceText = "Since";
const QString inheritedBytext = "Inherited By";
const QString inheritsText = "Inherits";
const QString instantiatedByText = "Instantiated By";
const QString qtVariableText = "qmake";
//add the includes to the map
if (!inner->includes().isEmpty()) {
@ -1856,6 +1857,7 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker)
//The order of the requisites matter
QStringList requisiteorder;
requisiteorder << headerText
<< qtVariableText
<< sinceText
<< instantiatedByText
<< inheritsText
@ -1932,6 +1934,16 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker)
requisites.insert(inheritedBytext, text);
}
//add the QT variable to the map
DocNode * moduleNode = qdb_->findModule(classe->moduleName());
if (moduleNode || !moduleNode->qtVariable().isEmpty()) {
text.clear();
text << Atom(Atom::FormattingLeft, ATOM_FORMATTING_TELETYPE)
<< "QT += " + moduleNode->qtVariable()
<< Atom(Atom::FormattingRight, ATOM_FORMATTING_TELETYPE);
requisites.insert(qtVariableText, text);
}
}
if (!requisites.isEmpty()) {
@ -1944,7 +1956,7 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker)
if (requisites.contains(*i)) {
out() << "<tr>"
<< "<td class=\"memItemLeft rightAlign topAlign\"> "
<< *i
<< *i << ":"
<< "</td><td class=\"memItemRight bottomAlign\"> ";
if (*i == headerText)

View File

@ -455,7 +455,7 @@ public:
virtual bool isClass() const { return true; }
virtual bool isWrapper() const { return wrapper_; }
virtual QString obsoleteLink() const { return obsoleteLink_; }
virtual void setObsoleteLink(const QString& t) { obsoleteLink_ = t; };
virtual void setObsoleteLink(const QString& t) { obsoleteLink_ = t; }
virtual void setWrapper() { wrapper_ = true; }
void addBaseClass(Access access,
@ -497,9 +497,11 @@ public:
PageType ptype);
virtual ~DocNode() { }
void setQtVariable(const QString &variable) { qtVariable_ = variable; }
void setTitle(const QString &title) { title_ = title; }
void setSubTitle(const QString &subTitle) { subtitle_ = subTitle; }
QString qtVariable() const { return qtVariable_; }
SubType subType() const { return nodeSubtype_; }
virtual QString title() const;
virtual QString fullTitle() const;
@ -513,6 +515,9 @@ protected:
SubType nodeSubtype_;
QString title_;
QString subtitle_;
private:
QString qtVariable_;
};
class NameCollisionNode : public DocNode