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 ")
109 + QLatin1String(relative->nodeType() == Node::Property ?
"property" :
"variable")
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 if (lookAhead->string().at(0).isDigit())
168 t += QLatin1String(
"Qt ");
169 t += lookAhead->string() + QLatin1String(
")");
174 return std::pair<QString,
int>(t, skipAhead);
178
179
180
181
182
186 QString attr =
"generic";
188 if (atom->count() > 0) {
189 p0 = atom->string(0);
190 if (atom->count() > 1)
191 p1 = atom->string(1);
194 if (p0 == QLatin1String(
"borderless"))
196 else if (p0.contains(QLatin1Char(
'%')))
200 if (p1 == QLatin1String(
"borderless"))
202 else if (p1.contains(QLatin1Char(
'%')))
208 if (width == QLatin1String(
"%")) {
211 int widthPercentage = p0.toInt(&ok);
213 width = QString::number(widthPercentage) +
"%";
219 return {width, attr};
223
224
225
226
227
228
229QString
XmlGenerator::registerRef(
const QString &ref,
bool xmlCompliant)
231 QString cleanRef = Generator::cleanRef(ref, xmlCompliant);
234 QString &prevRef = refMap[cleanRef.toLower()];
235 if (prevRef.isEmpty()) {
239 }
else if (prevRef == ref) {
243 cleanRef += QLatin1Char(
'x');
249
250
251
252
258 ref = node->name() +
"-enum";
261 const auto *tdf =
static_cast<
const TypedefNode *>(node);
262 if (tdf->associatedEnum())
263 return refForNode(tdf->associatedEnum());
266 ref = node->name() +
"-typedef";
269 const auto fn =
static_cast<
const FunctionNode *>(node);
272 ref = fn->name() +
"-signal";
275 ref = fn->name() +
"-signal-handler";
278 ref = fn->name() +
"-method";
279 if (fn->overloadNumber() != 0)
280 ref += QLatin1Char(
'-') + QString::number(fn->overloadNumber());
284 return refForNode(p);
287 if (fn->overloadNumber() != 0)
288 ref += QLatin1Char(
'-') + QString::number(fn->overloadNumber());
299 ref = node->name() +
"-attached-prop";
301 ref = node->name() +
"-prop";
304 ref = node->name() +
"-prop";
307 ref = node->name() +
"-var";
312 return registerRef(ref);
316
317
318
319
320
321
322
327 if (!node->url().isNull())
329 if (fileBase(node).isEmpty())
334 QString fn = fileName(node);
338 fn = fileName(Generator::qmlTypeContext());
341 QStringLiteral(
"Cannot link to property in internal type '%1'")
351 QString ref = refForNode(node);
352 if (relative && fn == fileName(relative) && ref == refForNode(relative))
355 link += QLatin1Char(
'#');
360
361
362
363
364 if (relative && (node != relative)) {
365 if (useOutputSubdirs() && !node->isExternalPage() && node->isIndexNode())
366 link.prepend(
"../%1/"_L1.arg(node->tree()->physicalModuleName()));
372
373
374
375
376
377
378
379
380
381
382
385 const QString &t = atom->string();
390 if (t.at(0) == QChar(
'h')) {
391 if (t.startsWith(
"http:") || t.startsWith(
"https:"))
393 }
else if (t.at(0) == QChar(
'f')) {
394 if (t.startsWith(
"file:") || t.startsWith(
"ftp:"))
396 }
else if (t.at(0) == QChar(
'm')) {
397 if (t.startsWith(
"mailto:"))
400 return getAutoLink(atom, relative, node);
404
405
406
407
408
409
410
411
412
413
419 *node =
m_qdb->findNodeForAtom(atom, relative, ref, genus);
423 QString link = (*node)->url();
425 link = linkForNode(*node, relative);
426 }
else if (link.isEmpty()) {
429 if (!ref.isEmpty()) {
430 qsizetype hashtag = link.lastIndexOf(QChar(
'#'));
432 link.truncate(hashtag);
433 link += QLatin1Char(
'#') + ref;
440 std::pair<QString, QString> anchorPair;
442 anchorPair.first = Generator::fileName(node);
444 anchorPair.second = node->title();
450
451
455 return QStringLiteral(
"external");
459 return QStringLiteral(
"namespace");
463 return QStringLiteral(
"class");
466 return QStringLiteral(
"page");
468 return QStringLiteral(
"enum");
470 return QStringLiteral(
"alias");
472 return QStringLiteral(
"typedef");
474 return QStringLiteral(
"property");
476 return QStringLiteral(
"function");
478 return QStringLiteral(
"variable");
480 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.