13using namespace Qt::Literals::StringLiterals;
17const QRegularExpression XmlGenerator::m_funcLeftParen(QStringLiteral(
"^\\S+(\\(.*\\))"));
22
23
30
31
32
44
45
65
66
93
94
95
104 const QString firstWord =
105 atom->string().toLower().section(
' ', 0, 0, QString::SectionSkipEmpty);
106 const QStringList words{
"the",
"a",
"an",
"whether",
"which" };
107 if (words.contains(firstWord)) {
108 QString str = QLatin1String(
"This ")
110 + QLatin1String(
" holds ") + atom->string().left(1).toLower()
111 + atom->string().mid(1);
112 const_cast<
Atom *>(atom)->setString(str);
117
118
121 const auto &name = atom->string();
122 if (name.startsWith(QLatin1String(
"qml")))
124 else if (name.startsWith(QLatin1String(
"groups")))
131
132
133
137 const auto cen =
static_cast<
const ExampleNode *>(relative);
138 if (cen->imageFileName().isEmpty()) {
140 en->setImageFileName(fileName);
146
147
148
149
154 return std::pair<QString,
int>(QString(), 1);
156 QString t = lookAhead->string();
158 if (!lookAhead || lookAhead->type() != Atom::ListTagRight)
159 return std::pair<QString,
int>(QString(), 1);
166 t += QLatin1String(
" (since ");
167 const QString sinceString = lookAhead->string();
168 if (sinceString.at(0).isDigit()) {
170 t += productName.isEmpty() ? sinceString : productName +
" " + sinceString;
174 t += QLatin1String(
")");
179 return std::pair<QString,
int>(t, skipAhead);
183
184
185
186
187
191 QString attr =
"generic";
193 if (atom->count() > 0) {
194 p0 = atom->string(0);
195 if (atom->count() > 1)
196 p1 = atom->string(1);
199 if (p0 == QLatin1String(
"borderless"))
201 else if (p0.contains(QLatin1Char(
'%')))
205 if (p1 == QLatin1String(
"borderless"))
207 else if (p1.contains(QLatin1Char(
'%')))
213 if (width == QLatin1String(
"%")) {
216 int widthPercentage = p0.toInt(&ok);
218 width = QString::number(widthPercentage) +
"%";
224 return {width, attr};
228
229
230
231
232
233
234QString
XmlGenerator::registerRef(
const QString &ref,
bool xmlCompliant)
236 QString cleanRef = Generator::cleanRef(ref, xmlCompliant);
239 QString &prevRef = refMap[cleanRef.toLower()];
240 if (prevRef.isEmpty()) {
244 }
else if (prevRef == ref) {
248 cleanRef += QLatin1Char(
'x');
254
255
256
257
263 ref = node->name() +
"-enum";
266 const auto *tdf =
static_cast<
const TypedefNode *>(node);
267 if (tdf->associatedEnum())
268 return refForNode(tdf->associatedEnum());
271 ref = node->name() +
"-typedef";
274 const auto fn =
static_cast<
const FunctionNode *>(node);
277 ref = fn->name() +
"-signal";
280 ref = fn->name() +
"-signal-handler";
283 ref = fn->name() +
"-method";
284 if (fn->overloadNumber() != 0)
285 ref += QLatin1Char(
'-') + QString::number(fn->overloadNumber());
289 return refForNode(p);
292 if (fn->overloadNumber() != 0)
293 ref += QLatin1Char(
'-') + QString::number(fn->overloadNumber());
304 ref = node->name() +
"-attached-prop";
306 ref = node->name() +
"-prop";
309 ref = node->name() +
"-prop";
312 ref = node->name() +
"-var";
317 return registerRef(ref);
321
322
323
324
325
326
327
332 if (!node->url().isNull())
334 if (fileBase(node).isEmpty())
339 QString fn = fileName(node);
343 fn = fileName(Generator::qmlTypeContext());
346 QStringLiteral(
"Cannot link to property in internal type '%1'")
356 QString ref = refForNode(node);
357 if (relative && fn == fileName(relative) && ref == refForNode(relative))
360 link += QLatin1Char(
'#');
365
366
367
368
369 if (relative && (node != relative)) {
370 if (useOutputSubdirs() && !node->isExternalPage() && node->isIndexNode())
371 link.prepend(
"../%1/"_L1.arg(node->tree()->physicalModuleName()));
377
378
379
380
381
382
383
384
385
386
387
390 const QString &t = atom->string();
395 if (t.at(0) == QChar(
'h')) {
396 if (t.startsWith(
"http:") || t.startsWith(
"https:"))
398 }
else if (t.at(0) == QChar(
'f')) {
399 if (t.startsWith(
"file:") || t.startsWith(
"ftp:"))
401 }
else if (t.at(0) == QChar(
'm')) {
402 if (t.startsWith(
"mailto:"))
405 return getAutoLink(atom, relative, node);
409
410
411
412
413
414
415
416
417
418
424 *node =
m_qdb->findNodeForAtom(atom, relative, ref, genus);
428 QString link = (*node)->url();
430 link = linkForNode(*node, relative);
431 }
else if (link.isEmpty()) {
434 if (!ref.isEmpty()) {
435 qsizetype hashtag = link.lastIndexOf(QChar(
'#'));
437 link.truncate(hashtag);
438 link += QLatin1Char(
'#') + ref;
445 std::pair<QString, QString> anchorPair;
447 anchorPair.first = Generator::fileName(node);
449 anchorPair.second = node->title();
455
456
460 return QStringLiteral(
"external");
464 return QStringLiteral(
"namespace");
468 return QStringLiteral(
"class");
471 return QStringLiteral(
"page");
473 return QStringLiteral(
"enum");
475 return QStringLiteral(
"alias");
477 return QStringLiteral(
"typedef");
479 return QStringLiteral(
"property");
481 return QStringLiteral(
"function");
483 return QStringLiteral(
"variable");
485 return QStringLiteral(
"module");
The Atom class is the fundamental unit for representing documents internally.
AtomType type() const
Return the type of this atom.
const Atom * next() const
Return the next atom in the atom list.
const Location & location() const
Returns the starting location of a qdoc comment.
Encapsulate the logic that QDoc uses to find files whose path is provided by the user and that are re...
This node is used to represent any kind of function being documented.
const PropertyNode * primaryAssociatedProperty() const
Returns the primary associated property, if this is an access function for one or more properties.
Metaness metaness() const
Generator(FileResolver &file_resolver)
Constructs the generator base class.
static bool noLinkErrors()
static bool matchAhead(const Atom *atom, Atom::AtomType expectedAtomType)
static QmlTypeNode * qmlTypeContext()
const Doc & doc() const
Returns a reference to the node's Doc data member.
bool isPrivate() const
Returns true if this node's access is Private.
virtual bool isAbstract() const
Returns true if the ClassNode or QmlTypeNode is marked abstract.
NodeType
An unsigned char value that identifies an object as a particular subclass of Node.
bool isQmlType() const
Returns true if the node type is QmlType or QmlValueType.
virtual bool isInternal() const
Returns true if the node's status is Internal, or if its parent is a class with Internal status.
virtual bool isPageNode() const
Returns true if this node represents something that generates a documentation page.
virtual bool isTextPageNode() const
Returns true if the node is a PageNode but not an Aggregate.
virtual bool isAttached() const
Returns true if the QML property or QML method node is marked as attached.
Aggregate * parent() const
Returns the node's parent pointer.
NodeType nodeType() const
Returns this node's type.
Genus
An unsigned char value that specifies whether the Node represents a C++ element, a QML element,...
virtual bool isPropertyGroup() const
Returns true if the node is a SharedCommentNode for documenting multiple C++ properties or multiple Q...
LinkType
An unsigned char value that probably should be moved out of the Node base class.
virtual bool isCollectionNode() const
Returns true if this is an instance of CollectionNode.
bool isExample() const
Returns true if the node type is Example.
bool inherits(Aggregate *type)
Returns true if this QML type inherits type.
std::pair< QString, QString > anchorForNode(const Node *node)
static bool isThreeColumnEnumValueTable(const Atom *atom)
Determines whether the list atom should be shown with three columns (constant-value-description).
QString getLink(const Atom *atom, const Node *relative, const Node **node)
This function is called for links, i.e.
static Node::NodeType typeFromString(const Atom *atom)
Returns the type of this atom as an enumeration.
QString refForNode(const Node *node)
Generates a clean and unique reference for the given node.
static bool isOneColumnValueTable(const Atom *atom)
Determines whether the list atom should be shown with just one column (value).
QString linkForNode(const Node *node, const Node *relative)
Construct the link string for the node and return it.
static void rewritePropertyBrief(const Atom *atom, const Node *relative)
Rewrites the brief of this node depending on its first word.
static int hOffset(const Node *node)
Header offset depending on the type of the node.
static bool hasBrief(const Node *node)
Do not display.
XmlGenerator(FileResolver &file_resolver)
QString getAutoLink(const Atom *atom, const Node *relative, const Node **node, Node::Genus=Node::DontCare)
This function is called for autolinks, i.e.
#define CONFIG_PRODUCTNAME