19#include <QtCore/qfileinfo.h>
23using namespace Qt::StringLiterals;
26
27
28
29
30
31
32
33
34
37
38
39
42
43
44
47
48
49
50
51
52
55
56
57
60
61
62
63
64
67
68
69
72
73
74
77
78
79
80
81
82
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
104
105
106
107
111QString genusKey(
const Node *node)
124
125
126
127
128const Node *locationTarget(
const Node *node)
131 const auto *fn =
static_cast<
const FunctionNode *>(node);
132 switch (fn->metaness()) {
142 if (
const auto *p = fn->primaryAssociatedProperty(); p && fn->doc().isEmpty())
147 const auto *tdef =
static_cast<
const TypedefNode *>(node);
148 if (tdef->associatedEnum())
149 return tdef->associatedEnum();
155
156
157
158QString fragmentOf(
const Node *node)
162 const auto *fn =
static_cast<
const FunctionNode *>(node);
163 switch (fn->metaness()) {
165 return node->name() +
"-signal"_L1;
167 return node->name() +
"-signal-handler"_L1;
169 QString ref = node->name() +
"-method"_L1;
170 if (fn->overloadNumber() > 0)
171 ref += u'-' + QString::number(fn->overloadNumber());
176 return "dtor."_L1 + fn->name().mid(1);
177 if (fn->overloadNumber() > 0)
178 return TextUtils::cleanAnchorRef(fn->name()) + u'-'
179 + QString::number(fn->overloadNumber());
180 return TextUtils::cleanAnchorRef(fn->name());
184
185
186
189 return node->name() +
"-enum"_L1;
192 return node->name() +
"-typedef"_L1;
194 return node->name() +
"-prop"_L1;
201 return node->name() +
"-attached-prop"_L1;
202 return node->name() +
"-prop"_L1;
204 return node->name() +
"-var"_L1;
213
214
215
216
217
218
222 rules.fileExtension = fileExtension;
225 for (
const QString &prefix : prefixes)
226 rules.outputPrefixes[prefix] =
228 if (!prefixes.contains(u"QML"_s))
229 rules.outputPrefixes[u"QML"_s] = u"qml-"_s;
231 for (
const QString &suffix : suffixes)
232 rules.outputSuffixes[suffix] =
238
239
240
243 if (node->isPageNode() && !node->isCollectionNode())
244 return outputPrefixes.value(genusKey(node));
249
250
253 if (node->isPageNode())
254 return outputSuffixes.value(genusKey(node));
259
260
261
262
263
264
271 const std::function<
void(
const Node *)> walk = [&](
const Node *node) {
273 if (!node->isAggregate())
275 const auto *aggregate =
static_cast<
const Aggregate *>(node);
276 for (
const Node *child : aggregate->childNodes())
280 for (
const CNMap *collections : { &tree->groups(), &tree->modules(), &tree->qmlModules(),
281 &tree->concepts() }) {
282 for (
auto it = collections->constBegin(); it != collections->constEnd(); ++it)
283 plan.record(it.value());
285 for (
const Node *proxy : tree->proxies())
291
292
293
294
296 const InclusionPolicy &policy)
299 for (
auto it = plan.m_entities.begin(); it != plan.m_entities.end();) {
300 const Node *target = locationTarget(it.key());
301 const Node *page = target;
311 const auto *collection =
static_cast<
const CollectionNode *>(page);
312 published = collection->wasSeen() || collection->isGenericCollection();
317 it = plan.m_entities.erase(it);
321 it.value() = { plan.fileName(target), resolveFragment(target),
false };
329
330
331
332
339 const auto addPublication = [&](
const QString &format,
const QString &extension,
340 const QString &directory) {
341 result.add(format, directory,
346 if (config.getOutputFormats().contains(u"HTML"_s))
347 addPublication(u"HTML"_s, u"html"_s, config.getOutputDir(u"HTML"_s));
349 for (
const auto &format : output.formats) {
350 if (format.requested)
351 addPublication(format.format, format.fileExtension, output.destination(format));
358
359
360
361
362
363
364
365
366
367
368
369
370
371
373 const QString &fileExtension)
377 if (!node->url().isEmpty())
379 if (
const Node *target = locationTarget(node); target != node)
380 return resolveDocumentLocation(target, fileBase, fileExtension);
386
387
388
389 if (!fileBase(node).isEmpty())
390 parentName = fileBase(node) + QLatin1Char(
'.') + fileExtension;
394 return fileBase(node) + QLatin1Char(
'.') + fileExtension;
396 parentName = fileBase(node) + QLatin1Char(
'.') + fileExtension;
397 }
else if (fileBase(node).isEmpty())
403 parentName = resolveDocumentLocation(node->parent(), fileBase, fileExtension);
412 parentName = fileBase(node) + QLatin1Char(
'.') + fileExtension;
420 parentName = fileBase(node);
421 parentName.replace(QLatin1Char(
'/'), QLatin1Char(
'-'))
422 .replace(QLatin1Char(
'.'), QLatin1Char(
'-'));
423 parentName += QLatin1Char(
'.') + fileExtension;
429 const QString fragment = fragmentOf(node);
430 const QString anchorRef = fragment.isEmpty() ? QString() : u'#' + fragment;
433 parentName.replace(u'.' + fileExtension,
"-obsolete."_L1 + fileExtension);
435 return parentName.toLower() + anchorRef;
439
440
441
442
443
444
445
446
451 return fragmentOf(locationTarget(node));
455
456
459 return Utilities::linkForExampleFile(file, m_rules.project, m_rules.fileExtension);
463
464
465
466
467
468
469
470
482 result = node->fileNameBase();
483 }
else if (
const auto it = m_fileBases.constFind(node); it != m_fileBases.constEnd()) {
486 result = Utilities::computeFileBase(
487 node, m_rules.project, [
this](
const Node *n) {
return m_rules.outputPrefix(n); },
488 [
this](
const Node *n) {
return m_rules.outputSuffix(n); });
489 m_fileBases.insert(node, result);
492 result +=
"-obsolete"_L1;
497
498
499
500
501
502
503
504
507 if (!node->url().isEmpty())
509 const QString base = fileBase(node);
513 const QString suffix = QFileInfo(node->name()).suffix();
514 if (!suffix.isEmpty() && suffix !=
"html"_L1)
515 return base + u'.' + suffix;
517 return base + u'.' + m_rules.fileExtension;
522 if (
const auto location = compute(node))
523 m_entities.insert(node, *location);
530 if (!node->url().isEmpty())
532 const QString href = resolveDocumentLocation(
533 node, [
this](
const Node *n) {
return fileBase(n); }, m_rules.fileExtension);
536 const qsizetype hash = href.indexOf(u'#');
The Config class contains the configuration variables for controlling how qdoc produces documentation...
InclusionPolicy createInclusionPolicy() const
static bool isIncluded(const InclusionPolicy &policy, const NodeContext &context)
static LocationPlanSet build(const Config &config, const Tree *tree, const OutputConfiguration &output)
Builds plans for requested publications in output.
\variable PublicationLocation::path
QString fileName(const Node *node) const
Returns the file name of the page that documents node: its explicit URL if it has one,...
static LocationPlan build(LocationRules rules, const Tree *tree)
Plans the locations of every entity in tree under rules.
static LocationPlan buildPublished(LocationRules rules, const Tree *tree, const InclusionPolicy &policy)
Plans the entities whose pages are produced under policy.
QString fileBase(const Node *node) const
Returns the file name stem of the page that documents node.
This class constructs and maintains a tree of instances of the subclasses of Node.
#define CONFIG_OUTPUTSUFFIXES
#define CONFIG_OUTPUTPREFIXES
Metaness
Specifies the kind of function a FunctionNode represents.
Combined button and popup list for selecting options.
Holds the configuration a format needs to name its published files.
QString outputSuffix(const Node *node) const
Returns the file name suffix for node.
QString outputPrefix(const Node *node) const
Returns the file name prefix for node.
The Node class is the base class for all the nodes in QDoc's parse tree.
bool isExternalPage() const
Returns true if the node type is ExternalPage.
virtual bool docMustBeGenerated() const
This function is called to perform a test to decide if the node must have documentation generated.
bool isNamespace() const
Returns true if the node type is Namespace.
bool hasFileNameBase() const
Returns true if the node's file name base has been set.
bool isQmlType() const
Returns true if the node type is QmlType or QmlValueType.
bool isHeader() const
Returns true if the node type is HeaderFile.
NodeType nodeType() const override
Returns this node's type.
Genus genus() const override
Returns this node's Genus.
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, that is, the aggregate under which the node is documented.
virtual bool isDeprecated() const
Returns true if this node's status is Deprecated.
virtual bool isAggregate() const
Returns true if this node is an aggregate, which means it inherits Aggregate and can therefore have c...
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
NodeContext createContext() const
virtual bool isPropertyGroup() const
Returns true if the node is a SharedCommentNode for documenting multiple C++ properties or multiple Q...
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
virtual bool isCollectionNode() const
Returns true if this is an instance of CollectionNode.
bool isIndexNode() const
Returns true if this node was created from something in an index file.
Adds publication destinations to a resolved output selection.
bool hasErrors() const
Returns true if a selection or layout diagnostic blocks publication.
OutputSelection::Mode Mode
\variable LocationRules::fileExtension