Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
htmlgenerator.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
5
6#include "access.h"
7#include "aggregate.h"
8#include "classnode.h"
10#include "config.h"
11#include "codemarker.h"
12#include "codeparser.h"
13#include "enumnode.h"
14#include "functionnode.h"
17#include "manifestwriter.h"
18#include "node.h"
19#include "propertynode.h"
21#include "qdocdatabase.h"
23#include "tagfilewriter.h"
24#include "tocwriter.h"
25#include "tree.h"
26#include "quoter.h"
27#include "utilities.h"
28#include "textutils.h"
29
30#include <QtCore/qlist.h>
31#include <QtCore/qmap.h>
32#include <QtCore/quuid.h>
33#include <QtCore/qversionnumber.h>
34#include <QtCore/qregularexpression.h>
35
36#include <algorithm>
37#include <cctype>
38#include <deque>
39#include <utility>
40
41QT_BEGIN_NAMESPACE
42
43using namespace Qt::StringLiterals;
44
45bool HtmlGenerator::s_inUnorderedList { false };
46
49// Template for <h3> API item headings
50static const auto headingStart = "<h3 class=\"%1\" translate=\"no\" id=\"%2\">"_L1;
51static const auto headingEnd = "</h3>\n"_L1;
52
53HtmlGenerator::HtmlGenerator(FileResolver& file_resolver) : XmlGenerator(file_resolver) {}
54
55static void addLink(const QString &linkTarget, QStringView nestedStuff, QString *res)
56{
57 if (!linkTarget.isEmpty()) {
58 *res += QLatin1String("<a href=\"");
59 *res += linkTarget;
60 *res += QLatin1String("\" translate=\"no\">");
61 *res += nestedStuff;
62 *res += QLatin1String("</a>");
63 } else {
64 *res += nestedStuff;
65 }
66}
67
68// Forward declaration: parameter emission may recurse into nested
69// template-template parameter declarations.
70static void appendTemplateParametersAtoms(Text &out, const TemplateDeclarationStorage &storage);
71
72// Emits one template parameter as an atom chain. Concept references on
73// type-template parameters become Atom::AutoLink so the autolink resolver
74// picks them up (same path the ancestor names in nested-type subtitles use).
76{
77 const auto &decl = param.valued_declaration;
78
79 // Template-template parameters carry a nested template declaration that
80 // appears before the parameter kind keyword (such as
81 // "template <typename> typename X").
82 if (param.template_declaration) {
83 appendTemplateParametersAtoms(out, *param.template_declaration);
84 out << " "_L1;
85 }
86
87 switch (param.kind) {
89 if (param.concept_name) {
90 const QString fq = QString::fromStdString(*param.concept_name);
91 // Autolink the fully-qualified name so a namespaced concept
92 // resolves. Atom::AutoLink carries a single string, so the
93 // displayed text is the qualified name; the marker-based paths
94 // that can split target from display render the short spelling.
95 out << Atom(Atom::AutoLink, fq);
96 } else {
97 out << "typename"_L1;
98 }
99 break;
101 if (!decl.type.empty())
102 out << Atom(Atom::AutoLink, QString::fromStdString(decl.type));
103 break;
105 out << "typename"_L1;
106 break;
107 }
108
109 if (param.is_parameter_pack)
110 out << "..."_L1;
111
112 if (!decl.name.empty())
113 out << " "_L1 << QString::fromStdString(decl.name);
114}
115
117{
118 out << "template <"_L1;
119
120 bool first = true;
121 for (const auto &param : storage.parameters) {
122 if (param.sfinae_constraint)
123 continue;
124 if (!first)
125 out << ", "_L1;
126 first = false;
127 appendTemplateParameterAtoms(out, param);
128 }
129
130 out << ">"_L1;
131}
132
133// Appends the rendered form of \a templateDecl to \a out as an atom chain.
134// Concept references — both direct-on-parameter (concept_name) and inside the
135// requires clause (referenced_concepts) — are emitted as Atom::AutoLink atoms.
136// The resolver links a concept named by a simple identifier (the common case);
137// a namespace-qualified name renders as faithful text but does not link, the
138// limit of a single-string autolink atom that can't separate target from
139// display.
140static void appendTemplateDeclAtoms(Text &out, const RelaxedTemplateDeclaration &templateDecl)
141{
142 appendTemplateParametersAtoms(out, templateDecl);
143
144 if (!templateDecl.requires_clause || templateDecl.requires_clause->empty())
145 return;
146
147 out << " requires "_L1;
148 const QString text = QString::fromStdString(*templateDecl.requires_clause);
149
150 QStringList concepts;
151 concepts.reserve(int(templateDecl.referenced_concepts.size()));
152 for (const auto &s : templateDecl.referenced_concepts)
153 concepts.append(QString::fromStdString(s));
154
155 if (concepts.isEmpty()) {
156 out << text;
157 return;
158 }
159
160 // Longest-first so prefix-shared concept names disambiguate; the bitmap
161 // tracks already-claimed character ranges so a shorter name can't match
162 // inside a longer one's span.
163 std::sort(concepts.begin(), concepts.end(),
164 [](const QString &a, const QString &b) { return a.size() > b.size(); });
165
166 struct Match { qsizetype offset; qsizetype length; QString name; };
167 QList<Match> matches;
168 QList<bool> occupied(text.size(), false);
169
170 for (const QString &concept_name : concepts) {
171 const QString unqualified = concept_name.section("::"_L1, -1);
172 QRegularExpression re("\\b"_L1 + QRegularExpression::escape(unqualified) + "\\b"_L1);
173 auto it = re.globalMatch(text);
174 while (it.hasNext()) {
175 const auto m = it.next();
176 const qsizetype start = m.capturedStart();
177 const qsizetype len = m.capturedLength();
178 bool clear = true;
179 for (qsizetype i = start; i < start + len; ++i)
180 if (occupied[i]) { clear = false; break; }
181 if (!clear)
182 continue;
183 for (qsizetype i = start; i < start + len; ++i)
184 occupied[i] = true;
185 matches.append({start, len, unqualified});
186 }
187 }
188
189 std::sort(matches.begin(), matches.end(),
190 [](const Match &a, const Match &b) { return a.offset < b.offset; });
191
192 qsizetype pos = 0;
193 for (const auto &m : matches) {
194 if (m.offset > pos)
195 out << text.mid(pos, m.offset - pos);
196 out << Atom(Atom::AutoLink, m.name);
197 pos = m.offset + m.length;
198 }
199 if (pos < text.size())
200 out << text.mid(pos);
201}
202
203/*!
204 Extends the `class` HTML attribute generated for \a node.
205 Returns \a classSet string extended with `internal` for
206 nodes marked internal.
207*/
208static QString getClassAttr(const Node *node, const QString &classSet)
209{
210 auto result{classSet};
211 if (node->isInternal())
212 result += " internal"_L1;
213 return result;
214}
215
216/*!
217 \internal
218 Convenience method that starts an unordered list if not in one.
219 */
220inline void HtmlGenerator::openUnorderedList()
221{
222 if (!s_inUnorderedList) {
223 out() << "<ul>\n";
224 s_inUnorderedList = true;
225 }
226}
227
228/*!
229 \internal
230 Convenience method that closes an unordered list if in one.
231 */
232inline void HtmlGenerator::closeUnorderedList()
233{
234 if (s_inUnorderedList) {
235 out() << "</ul>\n";
236 s_inUnorderedList = false;
237 }
238}
239
240/*!
241 Destroys the HTML output generator. Deletes the singleton
242 instance of HelpProjectWriter and the ManifestWriter instance.
243 */
245{
246 if (m_helpProjectWriter) {
247 delete m_helpProjectWriter;
248 m_helpProjectWriter = nullptr;
249 }
250
251 if (m_manifestWriter) {
252 delete m_manifestWriter;
253 m_manifestWriter = nullptr;
254 }
255}
256
257/*!
258 Initializes the HTML output generator's data structures
259 from the configuration (Config) singleton.
260 */
262{
263 static const struct
264 {
265 const char *key;
266 const char *left;
267 const char *right;
268 } defaults[] = { { ATOM_FORMATTING_BOLD, "<b>", "</b>" },
269 { ATOM_FORMATTING_INDEX, "<!--", "-->" },
270 { ATOM_FORMATTING_ITALIC, "<i>", "</i>" },
271 { ATOM_FORMATTING_PARAMETER, "<i translate=\"no\">", "</i>" },
272 { ATOM_FORMATTING_SUBSCRIPT, "<sub>", "</sub>" },
273 { ATOM_FORMATTING_SUPERSCRIPT, "<sup>", "</sup>" },
274 { ATOM_FORMATTING_TELETYPE, "<code translate=\"no\">",
275 "</code>" }, // <tt> tag is not supported in HTML5
276 { ATOM_FORMATTING_TRADEMARK, "<span translate=\"no\">", "&#8482;" },
277 { ATOM_FORMATTING_NOTRANSLATE, "<span translate=\"no\">", "</span>" },
278 { ATOM_FORMATTING_UICONTROL, "<b translate=\"no\">", "</b>" },
279 { ATOM_FORMATTING_UNDERLINE, "<u>", "</u>" },
280 { nullptr, nullptr, nullptr } };
281
283 config = &Config::instance();
284
285 /*
286 The formatting maps are owned by Generator. They are cleared in
287 Generator::terminate().
288 */
289 for (int i = 0; defaults[i].key; ++i) {
290 formattingLeftMap().insert(QLatin1String(defaults[i].key), QLatin1String(defaults[i].left));
291 formattingRightMap().insert(QLatin1String(defaults[i].key),
292 QLatin1String(defaults[i].right));
293 }
294
295 QString formatDot{HtmlGenerator::format() + Config::dot};
296 m_endHeader = config->get(formatDot + CONFIG_ENDHEADER).asString("</head>\n<body>\n"_L1);
297 m_postHeader = config->get(formatDot + HTMLGENERATOR_POSTHEADER).asString("<ul class=\"breadcrumb\">\n"_L1);
298 m_postPostHeader = config->get(formatDot + HTMLGENERATOR_POSTPOSTHEADER).asString("</ul>\n"_L1);
299 m_prologue = config->get(formatDot + HTMLGENERATOR_PROLOGUE).asString();
300
301 m_footer = config->get(formatDot + HTMLGENERATOR_FOOTER).asString();
302 m_address = config->get(formatDot + HTMLGENERATOR_ADDRESS).asString();
303 m_noNavigationBar = config->get(formatDot + HTMLGENERATOR_NONAVIGATIONBAR).asBool();
304 m_navigationSeparator = config->get(formatDot + HTMLGENERATOR_NAVIGATIONSEPARATOR).asString();
305 tocDepth = config->get(formatDot + HTMLGENERATOR_TOCDEPTH).asInt();
306
307 m_project = config->get(CONFIG_PROJECT).asString();
308 m_productName = config->get(CONFIG_PRODUCTNAME).asString();
309 m_projectDescription = config->get(CONFIG_DESCRIPTION)
310 .asString(m_project + " Reference Documentation"_L1);
311
312 m_projectUrl = config->get(CONFIG_URL).asString();
313 tagFile_ = config->get(CONFIG_TAGFILE).asString();
314 naturalLanguage = config->get(CONFIG_NATURALLANGUAGE).asString("en"_L1);
315
316 m_codeIndent = config->get(CONFIG_CODEINDENT).asInt();
317 m_codePrefix = config->get(CONFIG_CODEPREFIX).asString();
318 m_codeSuffix = config->get(CONFIG_CODESUFFIX).asString();
319
320 /*
321 The help file write should be allocated once and only once
322 per QDoc execution, and only for output formats that write
323 a help project file.
324 */
326 delete m_helpProjectWriter;
327 m_helpProjectWriter = nullptr;
328 } else if (m_helpProjectWriter) {
329 m_helpProjectWriter->reset(m_project.toLower() + ".qhp", this);
330 } else {
331 m_helpProjectWriter = new HelpProjectWriter(m_project.toLower() + ".qhp", this);
332 }
333
334 if (!m_manifestWriter)
335 m_manifestWriter = new ManifestWriter();
336
337 // Documentation template handling
338 m_headerScripts = config->get(formatDot + CONFIG_HEADERSCRIPTS).asString();
339 m_headerStyles = config->get(formatDot + CONFIG_HEADERSTYLES).asString();
340
341 // Retrieve the config for the navigation bar
342 m_homepage = config->get(CONFIG_NAVIGATION
343 + Config::dot + CONFIG_HOMEPAGE).asString();
344
345 m_hometitle = config->get(CONFIG_NAVIGATION
346 + Config::dot + CONFIG_HOMETITLE)
347 .asString(m_homepage);
348
349 m_landingpage = config->get(CONFIG_NAVIGATION
350 + Config::dot + CONFIG_LANDINGPAGE).asString();
351
352 m_landingtitle = config->get(CONFIG_NAVIGATION
353 + Config::dot + CONFIG_LANDINGTITLE)
354 .asString(m_landingpage);
355
356 m_cppclassespage = config->get(CONFIG_NAVIGATION
357 + Config::dot + CONFIG_CPPCLASSESPAGE).asString();
358
359 m_cppclassestitle = config->get(CONFIG_NAVIGATION
360 + Config::dot + CONFIG_CPPCLASSESTITLE)
361 .asString("C++ Classes"_L1);
362
363 m_qmltypespage = config->get(CONFIG_NAVIGATION
364 + Config::dot + CONFIG_QMLTYPESPAGE).asString();
365
366 m_qmltypestitle = config->get(CONFIG_NAVIGATION
367 + Config::dot + CONFIG_QMLTYPESTITLE)
368 .asString("QML Types"_L1);
369
370 m_trademarkspage = config->get(CONFIG_NAVIGATION
371 + Config::dot + CONFIG_TRADEMARKSPAGE).asString();
372
373 m_buildversion = config->get(CONFIG_BUILDVERSION).asString();
374}
375
376/*!
377 Gracefully terminates the HTML output generator.
378 */
383
384QString HtmlGenerator::format() const
385{
386 return "HTML";
387}
388
389/*!
390 If qdoc is in the \c {-prepare} phase, traverse the primary
391 tree to generate the index file for the current module.
392
393 If qdoc is in the \c {-generate} phase, traverse the primary
394 tree to generate all the HTML documentation for the current
395 module. Then generate the help file and the tag file.
396 */
398{
400 return;
401
402 Node *qflags = m_qdb->findClassNode(QStringList("QFlags"_L1));
403 if (qflags)
404 m_qflagsHref = linkForNode(qflags, nullptr);
405 if (!config->preparing())
407
408 const QString fileBase = "%1/%2"_L1.arg(
409 outputDir(),
410 m_project.toLower().simplified().replace(' '_L1, '-'_L1)
411 );
412
413 if (!config->preparing()) {
414 if (m_helpProjectWriter)
415 m_helpProjectWriter->generate();
416 m_manifestWriter->generateManifestFiles();
417 TOCWriter tocWriter(this, m_project);
418 const QString &rootTitle = m_landingpage.isEmpty() ? m_homepage : m_landingpage;
419 tocWriter.generateTOC("%1_toc.xml"_L1.arg(fileBase), rootTitle);
420 /*
421 Generate the XML tag file, if it was requested.
422 */
423 if (!tagFile_.isEmpty()) {
424 TagFileWriter tagFileWriter;
425 tagFileWriter.generateTagFile(tagFile_, this);
426 }
427 }
428}
429
430/*!
431 Generate an html file with the contents of a C++ or QML source file.
432 */
434{
435 SubTitleSize subTitleSize = LargeSubTitle;
436 QString fullTitle = en->fullTitle();
437
438 beginSubPage(en, linkForExampleFile(resolved_file.get_query()));
439 generateHeader(fullTitle, en, marker, u"auto-generated"_s);
440 generateTitle(en->doc().title(), Text() << en->subtitle(), subTitleSize, en, marker);
441
442 Text text;
443 Quoter quoter;
444 Doc::quoteFromFile(en->doc().location(), quoter, resolved_file);
445 QString code = quoter.quoteTo(en->location(), QString(), QString());
446 CodeMarker *codeMarker = CodeMarker::markerForFileName(resolved_file.get_path());
447 text << Atom(codeMarker->atomType(), code);
448 Atom a(codeMarker->atomType(), code);
449
450 generateText(text, en, codeMarker);
451 endSubPage();
452}
453
454/*!
455 Generate html from an instance of Atom.
456 */
457qsizetype HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker)
458{
459 qsizetype idx, skipAhead = 0;
460 static bool in_para = false;
461 Genus genus = Genus::DontCare;
462
463 if (!m_inSectionHeading && atom->type() != Atom::Target
464 && atom->type() != Atom::SectionHeadingRight)
465 m_recentSectionRef.clear();
466
467 switch (atom->type()) {
468 case Atom::AutoLink: {
469 QString name = atom->string();
470 if (relative && relative->name() == name.replace(QLatin1String("()"), QLatin1String())) {
471 out() << protectEnc(atom->string());
472 break;
473 }
474 // Allow auto-linking to nodes in API reference
475 genus = Genus::API;
476 }
477 Q_FALLTHROUGH();
479 if (!m_inLink && !m_inContents && !m_inSectionHeading) {
480 const Node *node = nullptr;
481 QString link = getAutoLink(atom, relative, &node, genus);
482 if (link.isEmpty()) {
483 // Warn if warnings are enabled, linking occurs from a relative
484 // node and no target is found. Do not warn about self-linking.
485 if (autolinkErrors() && relative && relative != node)
486 relative->doc().location().warning(
487 QStringLiteral("Can't autolink to '%1'").arg(atom->string()));
488 } else if (node && node->isDeprecated()) {
489 if (relative && (relative->parent() != node) && !relative->isDeprecated())
490 link.clear();
491 }
492 if (link.isEmpty()) {
493 out() << protectEnc(atom->string());
494 } else {
495 beginLink(link, node, relative);
496 generateLink(atom);
497 endLink();
498 }
499 } else {
500 out() << protectEnc(atom->string());
501 }
502 break;
503 case Atom::BaseName:
504 break;
506 if ((relative->isTextPageNode() && !relative->isCollectionNode())
507 || (relative->isCollectionNode()
508 && (relative->genus() == Genus::DOC || relative->genus() == Genus::DontCare))) {
509 // These pages have no generated status notice.
510 out() << "<p>";
511 } else {
512 skipAhead = skipAtoms(atom, Atom::DeprecatedRight) + 1;
513 }
514 break;
516 out() << "</p>\n";
517 break;
518 case Atom::BriefLeft:
519 if (!hasBrief(relative)) {
520 skipAhead = skipAtoms(atom, Atom::BriefRight);
521 break;
522 }
523 out() << "<p>";
524 rewritePropertyBrief(atom, relative);
525 break;
526 case Atom::BriefRight:
527 if (hasBrief(relative))
528 out() << "</p>\n";
529 break;
530 case Atom::C:
531 // This may at one time have been used to mark up C++ code but it is
532 // now widely used to write teletype text. As a result, text marked
533 // with the \c command is not passed to a code marker.
534 out() << formattingLeftMap()[ATOM_FORMATTING_TELETYPE];
535 out() << protectEnc(plainCode(atom->string()));
536 out() << formattingRightMap()[ATOM_FORMATTING_TELETYPE];
537 break;
539 out() << "<p class=\"figCaption\">";
540 in_para = true;
541 break;
543 endLink();
544 if (in_para) {
545 out() << "</p>\n";
546 in_para = false;
547 }
548 break;
549 case Atom::Qml:
550 out() << "<pre class=\"qml\" translate=\"no\"><code class=\"qml\">"
551 << trimmedTrailing(highlightedCode(indent(m_codeIndent, atom->string()), relative,
552 false, Genus::QML),
553 m_codePrefix, m_codeSuffix)
554 << "</code></pre>\n";
555 break;
556 case Atom::Code:
557 // Recover an additional string containing the code language, if present.
558 if (atom->strings().count() == 2)
559 out() << "<pre class=\"" << atom->string(1) << "\" translate=\"no\"><code class=\"" << atom->string(1) << "\">";
560 else
561 out() << "<pre class=\"cpp\" translate=\"no\"><code class=\"cpp\">";
562
563 out() << trimmedTrailing(highlightedCode(indent(m_codeIndent, atom->string()), relative),
564 m_codePrefix, m_codeSuffix)
565 << "</code></pre>\n";
566 break;
567 case Atom::CodeBad:
568 out() << "<pre class=\"cpp plain\" translate=\"no\"><code class=\"text\">"
569 << trimmedTrailing(protectEnc(plainCode(indent(m_codeIndent, atom->string()))),
570 m_codePrefix, m_codeSuffix)
571 << "</code></pre>\n";
572 break;
574 out() << "<details>\n";
576 out() << "<summary>...</summary>\n"; // Default summary string
577 break;
579 out() << "<summary>";
580 break;
582 out() << "</summary>\n";
583 break;
585 out() << "</details>\n";
586 break;
587 case Atom::DivLeft:
588 out() << "<div";
589 if (!atom->string().isEmpty())
590 out() << ' ' << atom->string();
591 out() << '>';
592 break;
593 case Atom::DivRight:
594 out() << "</div>";
595 break;
597 // ### For now
598 if (in_para) {
599 out() << "</p>\n";
600 in_para = false;
601 }
602 out() << "<!-- ";
603 break;
605 // ### For now
606 out() << "-->\n";
607 break;
608 case Atom::FormatElse:
610 case Atom::FormatIf:
611 break;
613 if (atom->string().startsWith("span "))
614 out() << '<' + atom->string() << '>';
615 else
616 out() << formattingLeftMap()[atom->string()];
617 break;
619 if (atom->string() == ATOM_FORMATTING_LINK) {
620 endLink();
621 } else if (atom->string() == ATOM_FORMATTING_TRADEMARK) {
622 if (appendTrademark(atom)) {
623 // Make the trademark symbol a link to navigation.trademarkspage (if set)
624 const Node *node{nullptr};
625 const Atom tm_link(Atom::NavLink, m_trademarkspage);
626 if (const auto &link = getLink(&tm_link, relative, &node);
627 !link.isEmpty() && node != relative)
628 out() << "<a href=\"%1\">%2</a>"_L1.arg(link, formattingRightMap()[atom->string()]);
629 else
630 out() << formattingRightMap()[atom->string()];
631 }
632 out() << "</span>";
633 } else if (atom->string().startsWith("span ")) {
634 out() << "</span>";
635 } else {
636 out() << formattingRightMap()[atom->string()];
637 }
638 break;
639 case Atom::AnnotatedList: {
640 if (const auto *cn = m_qdb->getCollectionNode(atom->string(), NodeType::Group); cn)
641 generateList(cn, marker, atom->string(), Generator::sortOrder(atom->strings().last()));
642 } break;
643 case Atom::GeneratedList: {
644 const auto sortOrder{Generator::sortOrder(atom->strings().last())};
645 if (atom->string() == QLatin1String("annotatedclasses")) {
646 generateAnnotatedList(relative, marker, m_qdb->getCppClasses().values(), sortOrder);
647 } else if (atom->string() == QLatin1String("annotatedexamples")) {
648 generateAnnotatedLists(relative, marker, m_qdb->getExamples());
649 } else if (atom->string() == QLatin1String("annotatedattributions")) {
650 generateAnnotatedLists(relative, marker, m_qdb->getAttributions());
651 } else if (atom->string() == QLatin1String("classes")) {
652 generateCompactList(Generic, relative, m_qdb->getCppClasses(), true,
653 QStringLiteral(""));
654 } else if (atom->string().contains("classes ")) {
655 QString rootName = atom->string().mid(atom->string().indexOf("classes") + 7).trimmed();
656 generateCompactList(Generic, relative, m_qdb->getCppClasses(), true, rootName);
657 } else if (atom->string() == QLatin1String("qmlvaluetypes")
658 || atom->string() == QLatin1String("qmlbasictypes")) {
659 generateCompactList(Generic, relative, m_qdb->getQmlValueTypes(), true,
660 QStringLiteral(""));
661 } else if (atom->string() == QLatin1String("qmltypes")) {
662 generateCompactList(Generic, relative, m_qdb->getQmlTypes(), true, QStringLiteral(""));
663 } else if ((idx = atom->string().indexOf(QStringLiteral("bymodule"))) != -1) {
665 QString moduleName = atom->string().mid(idx + 8).trimmed();
666 NodeType moduleType = typeFromString(atom);
667 if (const auto *cn = qdb->getCollectionNode(moduleName, moduleType)) {
668 NodeMap map;
669 switch (moduleType) {
670 case NodeType::Module:
671 // classesbymodule <module_name>
672 map = cn->getMembers([](const Node *n) { return n->isClassNode(); });
673 generateAnnotatedList(relative, marker, map.values(), sortOrder);
674 break;
676 if (atom->string().contains(QLatin1String("qmlvaluetypes")))
677 map = cn->getMembers(NodeType::QmlValueType); // qmlvaluetypesbymodule <module_name>
678 else
679 map = cn->getMembers(NodeType::QmlType); // qmltypesbymodule <module_name>
680 generateAnnotatedList(relative, marker, map.values(), sortOrder);
681 break;
682 default: // fall back to listing all members
683 generateAnnotatedList(relative, marker, cn->members(), sortOrder);
684 break;
685 }
686 }
687 } else if (atom->string() == QLatin1String("classhierarchy")) {
688 generateClassHierarchy(relative, m_qdb->getCppClasses());
689 } else if (atom->string() == QLatin1String("obsoleteclasses")) {
690 generateCompactList(Generic, relative, m_qdb->getObsoleteClasses(), false,
691 QStringLiteral("Q"));
692 } else if (atom->string() == QLatin1String("obsoleteqmltypes")) {
693 generateCompactList(Generic, relative, m_qdb->getObsoleteQmlTypes(), false,
694 QStringLiteral(""));
695 } else if (atom->string() == QLatin1String("obsoletecppmembers")) {
696 generateCompactList(Obsolete, relative, m_qdb->getClassesWithObsoleteMembers(), false,
697 QStringLiteral("Q"));
698 } else if (atom->string() == QLatin1String("obsoleteqmlmembers")) {
699 generateCompactList(Obsolete, relative, m_qdb->getQmlTypesWithObsoleteMembers(), false,
700 QStringLiteral(""));
701 } else if (atom->string() == QLatin1String("functionindex")) {
702 generateFunctionIndex(relative);
703 } else if (atom->string() == QLatin1String("attributions")) {
704 generateAnnotatedList(relative, marker, m_qdb->getAttributions().values(), sortOrder);
705 } else if (atom->string() == QLatin1String("legalese")) {
706 generateLegaleseList(relative, marker);
707 } else if (atom->string() == QLatin1String("overviews")) {
708 generateList(relative, marker, "overviews", sortOrder);
709 } else if (atom->string() == QLatin1String("cpp-modules")) {
710 generateList(relative, marker, "cpp-modules", sortOrder);
711 } else if (atom->string() == QLatin1String("qml-modules")) {
712 generateList(relative, marker, "qml-modules", sortOrder);
713 } else if (atom->string() == QLatin1String("namespaces")) {
714 generateAnnotatedList(relative, marker, m_qdb->getNamespaces().values(), sortOrder);
715 } else if (atom->string() == QLatin1String("related")) {
716 generateList(relative, marker, "related", sortOrder);
717 } else {
718 const CollectionNode *cn = m_qdb->getCollectionNode(atom->string(), NodeType::Group);
719 if (cn) {
720 if (!generateGroupList(const_cast<CollectionNode *>(cn), sortOrder))
721 relative->location().warning(
722 QString("'\\generatelist %1' group is empty").arg(atom->string()));
723 } else {
724 relative->location().warning(
725 QString("'\\generatelist %1' no such group").arg(atom->string()));
726 }
727 }
728 } break;
729 case Atom::SinceList: {
730 const NodeMultiMap &nsmap = m_qdb->getSinceMap(atom->string());
731 if (nsmap.isEmpty())
732 break;
733
734 const NodeMultiMap &ncmap = m_qdb->getClassMap(atom->string());
735 const NodeMultiMap &nqcmap = m_qdb->getQmlTypeMap(atom->string());
736
737 Sections sections(nsmap);
738 out() << "<ul>\n";
739 const QList<Section> sinceSections = sections.sinceSections();
740 for (const auto &section : sinceSections) {
741 if (!section.members().isEmpty()) {
742 out() << "<li>"
743 << "<a href=\"#" << TextUtils::asAsciiPrintable(section.title()) << "\">"
744 << section.title() << "</a></li>\n";
745 }
746 }
747 out() << "</ul>\n";
748
749 int index = 0;
750 for (const auto &section : sinceSections) {
751 if (!section.members().isEmpty()) {
752 out() << "<h3 id=\"" << TextUtils::asAsciiPrintable(section.title()) << "\">"
753 << protectEnc(section.title()) << "</h3>\n";
754 if (index == Sections::SinceClasses)
755 generateCompactList(Generic, relative, ncmap, false, QStringLiteral("Q"));
756 else if (index == Sections::SinceQmlTypes)
757 generateCompactList(Generic, relative, nqcmap, false, QStringLiteral(""));
758 else if (index == Sections::SinceMemberFunctions
759 || index == Sections::SinceQmlMethods
760 || index == Sections::SinceQmlProperties) {
761
762 QMap<QString, NodeMultiMap> parentmaps;
763
764 const QList<Node *> &members = section.members();
765 for (const auto &member : members) {
766 QString parent_full_name = (*member).parent()->fullName();
767
768 auto parent_entry = parentmaps.find(parent_full_name);
769 if (parent_entry == parentmaps.end())
770 parent_entry = parentmaps.insert(parent_full_name, NodeMultiMap());
771 parent_entry->insert(member->name(), member);
772 }
773
774 for (auto map = parentmaps.begin(); map != parentmaps.end(); ++map) {
775 NodeVector nv = map->values().toVector();
776 auto parent = nv.front()->parent();
777
778 out() << ((index == Sections::SinceMemberFunctions) ? "<p>Class " : "<p>QML Type ");
779
780 out() << "<a href=\"" << linkForNode(parent, relative) << "\" translate=\"no\">";
781 QStringList pieces = parent->fullName().split("::");
782 out() << protectEnc(pieces.last());
783 out() << "</a>"
784 << ":</p>\n";
785
786 generateSection(nv, relative, marker);
787 out() << "<br/>";
788 }
789 } else if (index == Sections::SinceEnumValues) {
790 out() << "<div class=\"table\"><table class=\"alignedsummary\" translate=\"no\">\n";
791 const auto map_it = m_qdb->newEnumValueMaps().constFind(atom->string());
792 for (auto it = map_it->cbegin(); it != map_it->cend(); ++it) {
793 out() << "<tr><td class=\"memItemLeft\"> enum value </td><td class=\"memItemRight\">"
794 << "<b><a href=\"" << linkForNode(it.value(), nullptr) << "\">"
795 << it.key() << "</a></b></td></tr>\n";
796 }
797 out() << "</table></div>\n";
798 } else {
799 generateSection(section.members(), relative, marker);
800 }
801 }
802 ++index;
803 }
804 } break;
805 case Atom::BR:
806 out() << "<br />\n";
807 break;
808 case Atom::HR:
809 out() << "<hr />\n";
810 break;
811 case Atom::Image:
812 case Atom::InlineImage: {
813 QString text;
814 if (atom->next() && atom->next()->type() == Atom::ImageText)
815 text = atom->next()->string();
816 if (atom->type() == Atom::Image)
817 out() << "<p class=\"centerAlign\">";
818
819 auto maybe_resolved_file{file_resolver.resolve(atom->string())};
820 if (!maybe_resolved_file) {
821 // TODO: [uncentralized-admonition]
822 relative->location().warning(
823 QStringLiteral("Missing image: %1").arg(protectEnc(atom->string())));
824 out() << "<font color=\"red\">[Missing image " << protectEnc(atom->string())
825 << "]</font>";
826 } else {
827 ResolvedFile file{*maybe_resolved_file};
828 QString file_name{QFileInfo{file.get_path()}.fileName()};
829
830 // TODO: [operation-can-fail-making-the-output-incorrect]
831 // The operation of copying the file can fail, making the
832 // output refer to an image that does not exist.
833 // This should be fine as HTML will take care of managing
834 // the rendering of a missing image, but what html will
835 // render is in stark contrast with what we do when the
836 // image does not exist at all.
837 // It may be more correct to unify the behavior between
838 // the two either by considering images that cannot be
839 // copied as missing or letting the HTML renderer
840 // always taking care of the two cases.
841 // Do notice that effectively doing this might be
842 // unnecessary as extracting the output directory logic
843 // should ensure that a safe assumption for copy should be
844 // made at the API boundary.
845
846 // TODO: [uncentralized-output-directory-structure]
847 Config::copyFile(relative->doc().location(), file.get_path(), file_name,
848 "%1/%2"_L1.arg(outputDir(), imagesOutputDir()));
849
850 const auto &imgPath = "%1/%2"_L1.arg(imagesOutputDir(), file_name);
851 // TODO: [uncentralized-output-directory-structure]
852 out() << "<img src=\"%1\""_L1.arg(protectEnc(imgPath));
853
854 const QString altAndTitleText = protectEnc(text);
855 out() << " alt=\"" << altAndTitleText;
856 if (Config::instance().get(CONFIG_USEALTTEXTASTITLE).asBool())
857 out() << "\" title=\"" << altAndTitleText;
858 out() << "\" />";
859
860 // TODO: [uncentralized-output-directory-structure]
861 if (m_helpProjectWriter)
862 m_helpProjectWriter->addExtraFile(imgPath);
863 setImageFileName(relative, imgPath);
864 }
865
866 if (atom->type() == Atom::Image)
867 out() << "</p>";
868 } break;
869 case Atom::ImageText:
870 break;
871 // Admonitions
873 case Atom::NoteLeft:
874 case Atom::WarningLeft: {
875 QString admonType = atom->typeString();
876 // Remove 'Left' from atom type to get the admonition type
877 admonType.chop(4);
878 out() << "<div class=\"admonition " << admonType.toLower() << "\">\n"
879 << "<p>";
880 out() << formattingLeftMap()[ATOM_FORMATTING_BOLD];
881 out() << admonType << ": ";
882 out() << formattingRightMap()[ATOM_FORMATTING_BOLD];
883 } break;
885 case Atom::NoteRight:
887 out() << "</p>\n"
888 << "</div>\n";
889 break;
891 out() << "<div class=\"LegaleseLeft\">";
892 break;
894 out() << "</div>";
895 break;
896 case Atom::LineBreak:
897 out() << "<br/>";
898 break;
899 case Atom::Link:
900 // Prevent nested links in table of contents
901 if (m_inContents)
902 break;
903 Q_FALLTHROUGH();
904 case Atom::NavLink: {
905 const Node *node = nullptr;
906 QString link = getLink(atom, relative, &node);
907 if (link.isEmpty() && (node != relative) && !noLinkErrors()) {
908 Location location = atom->isLinkAtom() ? static_cast<const LinkAtom*>(atom)->location
909 : relative->doc().location();
910 location.warning(
911 QStringLiteral("Can't link to '%1'").arg(atom->string()));
912 }
913 beginLink(link, node, relative);
914 skipAhead = 1;
915 } break;
917 QString link = linkForExampleFile(atom->string());
918 beginLink(link);
919 skipAhead = 1;
920 } break;
922 QString link = atom->string();
923 link = "images/used-in-examples/" + link;
924 beginLink(link);
925 skipAhead = 1;
926 } break;
927 case Atom::LinkNode: {
928 const Node *node = static_cast<const Node*>(Utilities::nodeForString(atom->string()));
929 beginLink(linkForNode(node, relative), node, relative);
930 skipAhead = 1;
931 } break;
932 case Atom::ListLeft:
933 if (in_para) {
934 out() << "</p>\n";
935 in_para = false;
936 }
937 if (atom->string() == ATOM_LIST_BULLET) {
938 out() << "<ul>\n";
939 } else if (atom->string() == ATOM_LIST_TAG) {
940 out() << "<dl>\n";
941 } else if (atom->string() == ATOM_LIST_VALUE) {
942 out() << R"(<div class="table"><table class="valuelist">)";
943 m_threeColumnEnumValueTable = isThreeColumnEnumValueTable(atom);
944 if (m_threeColumnEnumValueTable) {
945 if (++m_numTableRows % 2 == 1)
946 out() << R"(<tr valign="top" class="odd">)";
947 else
948 out() << R"(<tr valign="top" class="even">)";
949
950 out() << "<th class=\"tblConst\">Constant</th>";
951
952 // If not in \enum topic, skip the value column
953 if (relative->isEnumType(Genus::CPP))
954 out() << "<th class=\"tblval\">Value</th>";
955
956 out() << "<th class=\"tbldscr\">Description</th></tr>\n";
957 } else {
958 out() << "<tr><th class=\"tblConst\">Constant</th><th "
959 "class=\"tblVal\">Value</th></tr>\n";
960 }
961 } else {
962 QString olType;
963 if (atom->string() == ATOM_LIST_UPPERALPHA) {
964 olType = "A";
965 } else if (atom->string() == ATOM_LIST_LOWERALPHA) {
966 olType = "a";
967 } else if (atom->string() == ATOM_LIST_UPPERROMAN) {
968 olType = "I";
969 } else if (atom->string() == ATOM_LIST_LOWERROMAN) {
970 olType = "i";
971 } else { // (atom->string() == ATOM_LIST_NUMERIC)
972 olType = "1";
973 }
974
975 if (atom->next() != nullptr && atom->next()->string().toInt() != 1) {
976 out() << QString(R"(<ol class="%1" type="%1" start="%2">)")
977 .arg(olType, atom->next()->string());
978 } else
979 out() << QString(R"(<ol class="%1" type="%1">)").arg(olType);
980 }
981 break;
983 break;
985 if (atom->string() == ATOM_LIST_TAG) {
986 out() << "<dt>";
987 } else { // (atom->string() == ATOM_LIST_VALUE)
988 std::pair<QString, int> pair = getAtomListValue(atom);
989 skipAhead = pair.second;
990 QString t = protectEnc(plainCode(marker->markedUpEnumValue(pair.first, relative)));
991 out() << "<tr><td class=\"topAlign\"><code translate=\"no\">" << t << "</code>";
992
993 if (relative->isEnumType(Genus::CPP)) {
994 out() << "</td><td class=\"topAlign tblval\">";
995 const auto *enume = static_cast<const EnumNode *>(relative);
996 QString itemValue = enume->itemValue(atom->next()->string());
997 if (itemValue.isEmpty())
998 out() << '?';
999 else
1000 out() << "<code translate=\"no\">" << protectEnc(itemValue) << "</code>";
1001 }
1002 }
1003 break;
1005 case Atom::ListTagRight:
1006 if (atom->string() == ATOM_LIST_TAG)
1007 out() << "</dt>\n";
1008 break;
1009 case Atom::ListItemLeft:
1010 if (atom->string() == ATOM_LIST_TAG) {
1011 out() << "<dd>";
1012 } else if (atom->string() == ATOM_LIST_VALUE) {
1013 if (m_threeColumnEnumValueTable) {
1014 out() << "</td><td class=\"topAlign\">";
1016 out() << "&nbsp;";
1017 }
1018 } else {
1019 out() << "<li>";
1020 }
1021 if (matchAhead(atom, Atom::ParaLeft))
1022 skipAhead = 1;
1023 break;
1025 if (atom->string() == ATOM_LIST_TAG) {
1026 out() << "</dd>\n";
1027 } else if (atom->string() == ATOM_LIST_VALUE) {
1028 out() << "</td></tr>\n";
1029 } else {
1030 out() << "</li>\n";
1031 }
1032 break;
1033 case Atom::ListRight:
1034 if (atom->string() == ATOM_LIST_BULLET) {
1035 out() << "</ul>\n";
1036 } else if (atom->string() == ATOM_LIST_TAG) {
1037 out() << "</dl>\n";
1038 } else if (atom->string() == ATOM_LIST_VALUE) {
1039 out() << "</table></div>\n";
1040 } else {
1041 out() << "</ol>\n";
1042 }
1043 break;
1044 case Atom::Nop:
1045 break;
1046 case Atom::ParaLeft:
1047 out() << "<p>";
1048 in_para = true;
1049 break;
1050 case Atom::ParaRight:
1051 endLink();
1052 if (in_para) {
1053 out() << "</p>\n";
1054 in_para = false;
1055 }
1056 // if (!matchAhead(atom, Atom::ListItemRight) && !matchAhead(atom, Atom::TableItemRight))
1057 // out() << "</p>\n";
1058 break;
1060 out() << "<blockquote>";
1061 break;
1063 out() << "</blockquote>\n";
1064 break;
1065 case Atom::RawString:
1066 out() << atom->string();
1067 break;
1068 case Atom::SectionLeft:
1069 case Atom::SectionRight:
1070 break;
1072 int unit = atom->string().toInt() + hOffset(relative);
1073 m_recentSectionRef = Tree::refForAtom(atom);
1074 out() << "<h" + QString::number(unit) + QLatin1Char(' ') << "id=\""
1075 << m_recentSectionRef << "\">";
1076 m_inSectionHeading = true;
1077 break;
1078 }
1080 out() << "</h" + QString::number(atom->string().toInt() + hOffset(relative)) + ">\n";
1081 m_inSectionHeading = false;
1082 break;
1083 case Atom::SidebarLeft:
1084 Q_FALLTHROUGH();
1085 case Atom::SidebarRight:
1086 break;
1087 case Atom::String:
1088 if (m_inLink && !m_inContents && !m_inSectionHeading) {
1089 generateLink(atom);
1090 } else {
1091 out() << protectEnc(atom->string());
1092 }
1093 break;
1094 case Atom::TableLeft: {
1095 std::pair<QString, QString> pair = getTableWidthAttr(atom);
1096 QString attr = pair.second;
1097 QString width = pair.first;
1098
1099 if (in_para) {
1100 out() << "</p>\n";
1101 in_para = false;
1102 }
1103
1104 out() << R"(<div class="table"><table class=")" << attr << '"';
1105 if (!width.isEmpty())
1106 out() << " style=\"width: " << width << '"';
1107 out() << ">\n ";
1108 m_numTableRows = 0;
1109 } break;
1110 case Atom::TableRight:
1111 out() << "</table></div>\n";
1112 break;
1114 out() << "<thead><tr class=\"qt-style\">";
1115 m_inTableHeader = true;
1116 break;
1118 out() << "</tr>";
1120 skipAhead = 1;
1121 out() << "\n<tr class=\"qt-style\">";
1122 } else {
1123 out() << "</thead>\n";
1124 m_inTableHeader = false;
1125 }
1126 break;
1127 case Atom::TableRowLeft:
1128 if (!atom->string().isEmpty())
1129 out() << "<tr " << atom->string() << '>';
1130 else if (++m_numTableRows % 2 == 1)
1131 out() << R"(<tr valign="top" class="odd">)";
1132 else
1133 out() << R"(<tr valign="top" class="even">)";
1134 break;
1136 out() << "</tr>\n";
1137 break;
1138 case Atom::TableItemLeft: {
1139 if (m_inTableHeader)
1140 out() << "<th ";
1141 else
1142 out() << "<td ";
1143
1144 for (int i = 0; i < atom->count(); ++i) {
1145 if (i > 0)
1146 out() << ' ';
1147 const QString &p = atom->string(i);
1148 if (p.contains('=')) {
1149 out() << p;
1150 } else {
1151 QStringList spans = p.split(QLatin1Char(','));
1152 if (spans.size() == 2) {
1153 if (spans.at(0) != "1")
1154 out() << " colspan=\"" << spans.at(0) << '"';
1155 if (spans.at(1) != "1")
1156 out() << " rowspan=\"" << spans.at(1) << '"';
1157 }
1158 }
1159 }
1160 out() << '>';
1161 if (matchAhead(atom, Atom::ParaLeft))
1162 skipAhead = 1;
1163 } break;
1165 if (m_inTableHeader)
1166 out() << "</th>";
1167 else {
1168 out() << "</td>";
1169 }
1170 if (matchAhead(atom, Atom::ParaLeft))
1171 skipAhead = 1;
1172 break;
1174 // Skip \toc .. \endtoc content, handled separately by TOCWriter
1175 std::ignore = atom->find(Atom::TableOfContentsRight, &skipAhead);
1176 break;
1177 case Atom::Keyword:
1178 break;
1179 case Atom::Target: {
1180 const QString ref = atom->count() == 2 ? atom->string(1)
1181 : TextUtils::asAsciiPrintable(atom->string());
1182 const Atom *next = atom;
1183 while (next->next(Atom::SectionRight))
1184 next = next->next();
1185 const Atom *section = next->next(Atom::SectionLeft);
1186 if (ref != m_recentSectionRef && (!section || Tree::refForAtom(section) != ref))
1187 out() << "<span id=\"" << ref << "\"></span>";
1188 break;
1189 }
1191 out() << "<b class=\"redFont\">&lt;Missing HTML&gt;</b>";
1192 break;
1193 case Atom::UnknownCommand:
1194 out() << R"(<b class="redFont"><code translate=\"no\">\‍)" << protectEnc(atom->string()) << "</code></b>";
1195 break;
1198 case Atom::ComparesLeft:
1203 // no HTML output (ignore)
1204 break;
1205 default:
1206 unknownAtom(atom);
1207 }
1208 return skipAhead;
1209}
1210
1211/*!
1212 * Return a string representing a text that exposes information about
1213 * the user-visible groups that the \a node is part of. A user-visible
1214 * group is a group that generates an output page, that is, a \\group
1215 * topic exists for the group and can be linked to.
1216 *
1217 * The returned string is composed of comma separated links to the
1218 * groups, with their title as the user-facing text, surrounded by
1219 * some introductory text.
1220 *
1221 * For example, if a node named N is part of the groups with title A
1222 * and B, the line rendered form of the line will be "N is part of the
1223 * A, B groups", where A and B are clickable links that target the
1224 * respective page of each group.
1225 *
1226 * If a node has a single group, the comma is removed for readability
1227 * pusposes and "groups" is expressed as a singular noun.
1228 * For example, "N is part of the A group".
1229 *
1230 * The returned string is empty when the node is not linked to any
1231 * group that has a valid link target.
1232 *
1233 * This string is used in the summary of c++ classes or qml types to
1234 * link them to some of the overview documentation that is generated
1235 * through the "\group" command.
1236 *
1237 * Note that this is currently, incorrectly, a member of
1238 * HtmlGenerator as it requires access to some protected/private
1239 * members for escaping and linking.
1240 */
1241QString HtmlGenerator::groupReferenceText(PageNode* node) {
1242 auto link_for_group = [this](const CollectionNode *group) -> QString {
1243 QString target{linkForNode(group, nullptr)};
1244 return (target.isEmpty()) ? protectEnc(group->name()) : "<a href=\"" + target + "\">" + protectEnc(group->fullTitle()) + "</a>";
1245 };
1246
1247 QString text{};
1248
1249 const QStringList &groups_names{node->groupNames()};
1250 if (groups_names.isEmpty())
1251 return text;
1252
1253 std::vector<CollectionNode *> groups_nodes(groups_names.size(), nullptr);
1254 std::transform(groups_names.cbegin(), groups_names.cend(), groups_nodes.begin(),
1255 [this](const QString &group_name) -> CollectionNode* {
1256 CollectionNode *group{m_qdb->groups()[group_name]};
1257 m_qdb->mergeCollections(group);
1258 return (group && group->wasSeen()) ? group : nullptr;
1259 });
1260 groups_nodes.erase(std::remove(groups_nodes.begin(), groups_nodes.end(), nullptr), groups_nodes.end());
1261
1262 if (!groups_nodes.empty()) {
1263 text += node->name() + " is part of ";
1264
1265 for (std::vector<CollectionNode *>::size_type index{0}; index < groups_nodes.size(); ++index) {
1266 text += link_for_group(groups_nodes[index]) + TextUtils::separator(index, groups_nodes.size());
1267 }
1268 }
1269 return text;
1270}
1271
1272/*!
1273 Generate a reference page for the C++ class, namespace, or
1274 header file documented in \a node using the code \a marker
1275 provided.
1276 */
1278{
1279 QString title;
1280 QString fullTitle;
1281 Text titleText;
1282 NamespaceNode *ns = nullptr;
1283 Sections sections(aggregate);
1284 const SectionVector &summarySections = sections.summarySections();
1285 const SectionVector &detailsSections = sections.detailsSections();
1286
1287 QString typeWord = aggregate->typeWord(true);
1288 auto templateDecl = aggregate->templateDecl();
1289 if (aggregate->isNamespace()) {
1290 fullTitle = aggregate->plainFullName();
1291 title = "%1 %2"_L1.arg(fullTitle, typeWord);
1292 ns = static_cast<NamespaceNode *>(aggregate);
1293 } else if (aggregate->isClassNode()) {
1294 fullTitle = aggregate->plainFullName();
1295 title = "%1 %2"_L1.arg(fullTitle, typeWord);
1296 } else if (aggregate->isHeader()) {
1297 title = fullTitle = aggregate->fullTitle();
1298 if (!aggregate->doc().title().isEmpty())
1299 titleText << aggregate->name() << " - "_L1 << aggregate->doc().title();
1300 }
1301
1302 Text subtitleText;
1303 // Generate a subtitle if there are parents to link to, or a template declaration
1304 if (aggregate->parent()->isInAPI() || templateDecl) {
1305 if (templateDecl) {
1306 appendTemplateDeclAtoms(subtitleText, *templateDecl);
1307 subtitleText << " "_L1;
1308 }
1309 subtitleText << aggregate->typeWord(false) << " "_L1;
1310 auto ancestors = fullTitle.split("::"_L1);
1311 ancestors.pop_back();
1312 for (const auto &a : ancestors)
1313 subtitleText << Atom(Atom::AutoLink, a) << "::"_L1;
1314 subtitleText << aggregate->plainName();
1315 }
1316
1317 generateHeader(title, aggregate, marker);
1318 generateTableOfContents(aggregate, marker, &summarySections);
1319 if (!titleText.isEmpty())
1320 generateTitle(titleText, subtitleText, SmallSubTitle, aggregate, marker);
1321 else
1322 generateTitle(title, subtitleText, SmallSubTitle, aggregate, marker);
1323 if (ns && !ns->hasDoc() && ns->docNode()) {
1324 NamespaceNode *fullNamespace = ns->docNode();
1325 Text brief;
1326 brief << "The " << ns->name() << " namespace includes the following elements from module "
1327 << ns->tree()->camelCaseModuleName() << ". The full namespace is "
1328 << "documented in module " << fullNamespace->tree()->camelCaseModuleName();
1329 addNodeLink(brief, fullNamespace, " here.");
1330 out() << "<p>";
1331 generateText(brief, ns, marker);
1332 out() << "</p>\n";
1333 } else
1334 generateBrief(aggregate, marker);
1335
1336 const auto parentIsClass = aggregate->parent()->isClassNode();
1337
1338 if (!parentIsClass)
1339 generateRequisites(aggregate, marker);
1340 generateStatus(aggregate, marker);
1341 if (parentIsClass)
1342 generateSince(aggregate, marker);
1343
1344 QString membersLink = generateAllMembersFile(sections.allMembersSection(), marker);
1345 if (!membersLink.isEmpty()) {
1346 openUnorderedList();
1347 out() << "<li><a href=\"" << membersLink << "\">"
1348 << "List of all members, including inherited members</a></li>\n";
1349 }
1350 QString obsoleteLink = generateObsoleteMembersFile(sections, marker);
1351 if (!obsoleteLink.isEmpty()) {
1352 openUnorderedList();
1353 out() << "<li><a href=\"" << obsoleteLink << "\">"
1354 << "Deprecated members</a></li>\n";
1355 }
1356
1357 if (QString groups_text{groupReferenceText(aggregate)}; !groups_text.isEmpty()) {
1358 openUnorderedList();
1359
1360 out() << "<li>" << groups_text << "</li>\n";
1361 }
1362
1363 closeUnorderedList();
1364
1365 generateThreadSafeness(aggregate, marker);
1366 generateComparisonTable(aggregate);
1367
1368 bool needOtherSection = false;
1369
1370 for (const auto &section : summarySections) {
1371 if (section.members().isEmpty() && section.reimplementedMembers().isEmpty()) {
1372 if (!section.inheritedMembers().isEmpty())
1373 needOtherSection = true;
1374 } else {
1375 if (!section.members().isEmpty()) {
1376 QString ref = registerRef(section.title().toLower());
1377 out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n";
1378 generateSection(section.members(), aggregate, marker);
1379 }
1380 if (!section.reimplementedMembers().isEmpty()) {
1381 QString name = QString("Reimplemented ") + section.title();
1382 QString ref = registerRef(name.toLower());
1383 out() << "<h2 id=\"" << ref << "\">" << protectEnc(name) << "</h2>\n";
1384 generateSection(section.reimplementedMembers(), aggregate, marker);
1385 }
1386
1387 if (!section.inheritedMembers().isEmpty()) {
1388 out() << "<ul>\n";
1389 generateSectionInheritedList(section, aggregate);
1390 out() << "</ul>\n";
1391 }
1392 }
1393 }
1394
1395 if (needOtherSection) {
1396 out() << "<h3>Additional Inherited Members</h3>\n"
1397 "<ul>\n";
1398
1399 for (const auto &section : summarySections) {
1400 if (section.members().isEmpty() && !section.inheritedMembers().isEmpty())
1401 generateSectionInheritedList(section, aggregate);
1402 }
1403 out() << "</ul>\n";
1404 }
1405
1406 if (aggregate->doc().isEmpty()) {
1407 QString command = "documentation";
1408 if (aggregate->isClassNode())
1409 command = R"('\class' comment)";
1410 if (!ns || ns->isDocumentedHere()) {
1411 aggregate->location().warning(
1412 QStringLiteral("No %1 for '%2'").arg(command, aggregate->plainSignature()));
1413 }
1414 } else {
1415 generateExtractionMark(aggregate, DetailedDescriptionMark);
1416 out() << "<div class=\"descr\">\n"
1417 << "<h2 id=\"" << registerRef("details") << "\">"
1418 << "Detailed Description"
1419 << "</h2>\n";
1420 generateBody(aggregate, marker);
1421 out() << "</div>\n";
1422 generateAlsoList(aggregate, marker);
1423 generateExtractionMark(aggregate, EndMark);
1424 }
1425
1426 for (const auto &section : detailsSections) {
1427 bool headerGenerated = false;
1428 if (section.isEmpty())
1429 continue;
1430
1431 const QList<Node *> &members = section.members();
1432 for (const auto &member : members) {
1433 if (!headerGenerated) {
1434 if (!section.divClass().isEmpty())
1435 out() << "<div class=\"" << section.divClass() << "\">\n";
1436 out() << "<h2>" << protectEnc(section.title()) << "</h2>\n";
1437 headerGenerated = true;
1438 }
1439 if (!member->isClassNode())
1440 generateDetailedMember(member, aggregate, marker);
1441 else {
1442 out() << "<h3";
1443 if (const auto &attrs = getClassAttr(member, ""_L1); !attrs.isEmpty())
1444 out() << " class=\"%1\""_L1.arg(attrs);
1445 out() << "> class ";
1446 generateFullName(member, aggregate);
1447 out() << "</h3>";
1448 generateBrief(member, marker, aggregate);
1449 }
1450 }
1451 if (headerGenerated && !section.divClass().isEmpty())
1452 out() << "</div>\n";
1453 }
1454 generateFooter(aggregate);
1455}
1456
1458{
1459 Q_ASSERT(aggregate->isProxyNode());
1460
1461 Text subtitleText;
1462
1463 Sections sections(aggregate);
1464 const SectionVector &summarySections = sections.summarySections();
1465 const SectionVector &detailsSections = sections.detailsSections();
1466
1467 QString rawTitle = aggregate->plainName();
1468 QString fullTitle = aggregate->plainFullName();
1469 QString title = rawTitle + " Proxy Page";
1470 generateHeader(title, aggregate, marker, u"auto-generated"_s);
1471 generateTitle(title, subtitleText, SmallSubTitle, aggregate, marker);
1472 generateBrief(aggregate, marker);
1473 for (const auto &section : summarySections) {
1474 if (!section.members().isEmpty()) {
1475 QString ref = registerRef(section.title().toLower());
1476 out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n";
1477 generateSection(section.members(), aggregate, marker);
1478 }
1479 }
1480
1481 if (!aggregate->doc().isEmpty()) {
1482 generateExtractionMark(aggregate, DetailedDescriptionMark);
1483 out() << "<div class=\"descr\">\n"
1484 << "<h2 id=\"" << registerRef("details") << "\">"
1485 << "Detailed Description"
1486 << "</h2>\n";
1487 generateBody(aggregate, marker);
1488 out() << "</div>\n";
1489 generateAlsoList(aggregate, marker);
1490 generateExtractionMark(aggregate, EndMark);
1491 }
1492
1493 for (const auto &section : detailsSections) {
1494 if (section.isEmpty())
1495 continue;
1496
1497 if (!section.divClass().isEmpty())
1498 out() << "<div class=\"" << section.divClass() << "\">\n";
1499 out() << "<h2>" << protectEnc(section.title()) << "</h2>\n";
1500
1501 const QList<Node *> &members = section.members();
1502 for (const auto &member : members) {
1503 if (!member->isClassNode()) {
1504 generateDetailedMember(member, aggregate, marker);
1505 } else {
1506 out() << "<h3";
1507 if (const auto &attrs = getClassAttr(member, ""_L1); !attrs.isEmpty())
1508 out() << " class=\"%1\""_L1.arg(attrs);
1509 out() << "> class ";
1510 generateFullName(member, aggregate);
1511 out() << "</h3>";
1512 generateBrief(member, marker, aggregate);
1513 }
1514 }
1515 if (!section.divClass().isEmpty())
1516 out() << "</div>\n";
1517 }
1518 generateFooter(aggregate);
1519}
1520
1521/*!
1522 Generate the HTML page for a QML type. \qcn is the QML type.
1523 \marker is the code markeup object.
1524 */
1526{
1528 SubTitleSize subTitleSize = LargeSubTitle;
1529 QString htmlTitle = qcn->name();
1530 if (qcn->isQmlBasicType())
1531 htmlTitle.append(" QML Value Type");
1532 else
1533 htmlTitle.append(" QML Type");
1534
1535 if (qcn->isSingleton())
1536 htmlTitle.append(" (Singleton)"_L1);
1537 else if (qcn->isUncreatable())
1538 htmlTitle.append(" (Uncreatable)"_L1);
1539
1540 generateHeader(htmlTitle, qcn, marker);
1541 Sections sections(qcn);
1542 generateTableOfContents(qcn, marker, &sections.summarySections());
1543 marker = CodeMarker::markerForLanguage(QLatin1String("QML"));
1544 generateTitle(htmlTitle, Text() << qcn->subtitle(), subTitleSize, qcn, marker);
1545 generateBrief(qcn, marker);
1546 generateQmlRequisites(qcn, marker);
1547 generateStatus(qcn, marker);
1548
1549 if (qcn->isSingleton()) {
1550 out() << "<p><strong>Note:</strong> This type is a QML singleton. "_L1
1551 << "There is only one instance of this type in the QML engine.</p>\n"_L1;
1552 } else if (qcn->isUncreatable()) {
1553 out() << "<p><strong>Note:</strong> This is an uncreatable type. "_L1
1554 << "It cannot be instantiated in QML.</p>\n"_L1;
1555 }
1556
1557 QString allQmlMembersLink;
1558
1559 // No 'All Members' file for QML value types
1560 if (!qcn->isQmlBasicType())
1561 allQmlMembersLink = generateAllQmlMembersFile(sections, marker);
1562 QString obsoleteLink = generateObsoleteQmlMembersFile(sections, marker);
1563 if (!allQmlMembersLink.isEmpty() || !obsoleteLink.isEmpty()) {
1564 openUnorderedList();
1565
1566 if (!allQmlMembersLink.isEmpty()) {
1567 out() << "<li><a href=\"" << allQmlMembersLink << "\">"
1568 << "List of all members, including inherited members</a></li>\n";
1569 }
1570 if (!obsoleteLink.isEmpty()) {
1571 out() << "<li><a href=\"" << obsoleteLink << "\">"
1572 << "Deprecated members</a></li>\n";
1573 }
1574 }
1575
1576 if (QString groups_text{groupReferenceText(qcn)}; !groups_text.isEmpty()) {
1577 openUnorderedList();
1578
1579 out() << "<li>" << groups_text << "</li>\n";
1580 }
1581
1582 closeUnorderedList();
1583
1584 const SectionVector &qmlSummarySections = sections.summarySections();
1585 for (const auto &section : qmlSummarySections) {
1586 if (!section.isEmpty()) {
1587 QString ref = registerRef(section.title().toLower());
1588 out() << "<h2 id=\"" << ref << "\">" << protectEnc(section.title()) << "</h2>\n";
1589 generateQmlSummary(section.members(), qcn, marker);
1590 }
1591 }
1592
1593 generateExtractionMark(qcn, DetailedDescriptionMark);
1594 out() << "<h2 id=\"" << registerRef("details") << "\">"
1595 << "Detailed Description"
1596 << "</h2>\n";
1597 generateBody(qcn, marker);
1598 generateAlsoList(qcn, marker);
1599 generateExtractionMark(qcn, EndMark);
1600
1601 const SectionVector &qmlDetailsSections = sections.detailsSections();
1602 for (const auto &section : qmlDetailsSections) {
1603 if (section.isEmpty())
1604 continue;
1605 out() << "<h2>" << protectEnc(section.title()) << "</h2>\n";
1606 const QList<Node *> &members = section.members();
1607 for (const auto member : members)
1608 generateDetailedQmlMember(member, qcn, marker);
1609 }
1610 generateFooter(qcn);
1612}
1613
1614/*!
1615 Generate the HTML page for an entity that doesn't map
1616 to any underlying parsable C++ or QML element.
1617 */
1619{
1620 generateHeader(pn->fullTitle(), pn, marker);
1621 /*
1622 Generate the TOC for the new doc format.
1623 Don't generate a TOC for the home page.
1624 */
1625 if ((pn->name() != QLatin1String("index.html")))
1626 generateTableOfContents(pn, marker, nullptr);
1627
1628 generateTitle(pn->doc().title(), Text() << pn->subtitle(), LargeSubTitle, pn, marker);
1629 if (pn->isExample()) {
1630 generateBrief(pn, marker, nullptr, false);
1631 }
1632
1633 generateExtractionMark(pn, DetailedDescriptionMark);
1634 out() << R"(<div class="descr" id=")" << registerRef("details")
1635 << "\">\n";
1636
1637 generateBody(pn, marker);
1638 out() << "</div>\n";
1639 generateAlsoList(pn, marker);
1640 generateExtractionMark(pn, EndMark);
1641
1642 generateFooter(pn);
1643}
1644
1645/*!
1646 Generate the HTML page for a group, module, or QML module.
1647 */
1649{
1650 SubTitleSize subTitleSize = LargeSubTitle;
1651 QString ref;
1652
1653 generateHeader(cn->fullTitle(), cn, marker);
1654 generateTableOfContents(cn, marker, nullptr);
1655 generateTitle(cn->doc().title(), Text() << cn->subtitle(), subTitleSize, cn, marker);
1656
1657 // Generate brief for C++ modules, status for all modules.
1658 if (cn->genus() != Genus::DOC && cn->genus() != Genus::DontCare) {
1659 if (cn->isModule() || cn->isConcept())
1660 generateBrief(cn, marker);
1661 generateStatus(cn, marker);
1662 generateSince(cn, marker);
1663 }
1664
1665 if (cn->isModule()) {
1666 if (!cn->noAutoList()) {
1668 if (!nmm.isEmpty()) {
1669 ref = registerRef("namespaces");
1670 out() << "<h2 id=\"" << ref << "\">Namespaces</h2>\n";
1671 generateAnnotatedList(cn, marker, nmm.values());
1672 }
1673 nmm = cn->getMembers([](const Node *n){ return n->isClassNode(); });
1674 if (!nmm.isEmpty()) {
1675 ref = registerRef("classes");
1676 out() << "<h2 id=\"" << ref << "\">Classes</h2>\n";
1677 generateAnnotatedList(cn, marker, nmm.values());
1678 }
1679 }
1680 }
1681
1682 if ((cn->isModule() || cn->isConcept()) && !cn->doc().briefText().isEmpty()) {
1683 generateExtractionMark(cn, DetailedDescriptionMark);
1684 ref = registerRef("details");
1685 out() << "<div class=\"descr\">\n";
1686 out() << "<h2 id=\"" << ref << "\">"
1687 << "Detailed Description"
1688 << "</h2>\n";
1689 } else {
1690 generateExtractionMark(cn, DetailedDescriptionMark);
1691 out() << R"(<div class="descr" id=")" << registerRef("details")
1692 << "\">\n";
1693 }
1694
1695 generateBody(cn, marker);
1696 out() << "</div>\n";
1697 generateAlsoList(cn, marker);
1698 generateExtractionMark(cn, EndMark);
1699
1700 if (!cn->noAutoList()) {
1701 if (cn->isConcept()) {
1702 const NodeMultiMap users = includedAnnotatedMembers(cn, cn->members());
1703 if (!users.isEmpty()) {
1704 ref = registerRef("users");
1705 out() << "<h2 id=\"" << ref << "\">Used by</h2>\n";
1706 generateAnnotatedList(cn, marker, users);
1707 }
1708 } else if (cn->isGroup() || cn->isQmlModule()) {
1709 generateAnnotatedList(cn, marker, cn->members());
1710 }
1711 }
1712 generateFooter(cn);
1713}
1714
1715/*!
1716 Generate the HTML page for a generic collection. This is usually
1717 a collection of C++ elements that are related to an element in
1718 a different module.
1719 */
1721{
1722 SubTitleSize subTitleSize = LargeSubTitle;
1723 QString fullTitle = cn->name();
1724
1725 generateHeader(fullTitle, cn, marker, u"auto-generated"_s);
1726 generateTitle(fullTitle, Text() << cn->subtitle(), subTitleSize, cn, marker);
1727
1728 Text brief;
1729 brief << "Each function or type documented here is related to a class or "
1730 << "namespace that is documented in a different module. The reference "
1731 << "page for that class or namespace will link to the function or type "
1732 << "on this page.";
1733 out() << "<p>";
1734 generateText(brief, cn, marker);
1735 out() << "</p>\n";
1736
1737 const QList<Node *> members = cn->members();
1738 for (const auto &member : members)
1739 generateDetailedMember(member, cn, marker);
1740
1741 generateFooter(cn);
1742}
1743
1744/*!
1745 Returns "html" for this subclass of Generator.
1746 */
1748{
1749 return "html";
1750}
1751
1752/*!
1753 Output a navigation bar (breadcrumbs) for the html file.
1754 For API reference pages, items for the navigation bar are (in order):
1755 \table
1756 \header \li Item \li Related configuration variable \li Notes
1757 \row \li home \li navigation.homepage \li e.g. 'Qt 6.2'
1758 \row \li landing \li navigation.landingpage \li Module landing page
1759 \row \li types \li navigation.cppclassespage (C++)\br
1760 navigation.qmltypespage (QML) \li Types only
1761 \row \li module \li n/a (automatic) \li Module page if different
1762 from previous item; labeled
1763 with the module name after
1764 a types item, otherwise
1765 with the module title
1766 \row \li page \li n/a \li Current page title
1767 \endtable
1768
1769 For other page types (page nodes) the navigation bar is constructed from home
1770 page, landing page, and the chain of PageNode::navigationParent() items (if one exists).
1771 This chain is constructed from the \\list structure on a page or pages defined in
1772 \c navigation.toctitles configuration variable.
1773
1774 Finally, if no other navigation data exists for a page but it is a member of a
1775 single group (using \\ingroup), add that group page to the navigation bar.
1776 */
1777void HtmlGenerator::generateNavigationBar(const QString &title, const Node *node,
1778 CodeMarker *marker, const QString &buildversion,
1779 bool tableItems)
1780{
1781 if (m_noNavigationBar || node == nullptr)
1782 return;
1783
1784 Text navigationbar;
1785
1786 // Set list item types based on the navigation bar type
1787 // TODO: Do we still need table items?
1788 Atom::AtomType itemLeft = tableItems ? Atom::TableItemLeft : Atom::ListItemLeft;
1789 Atom::AtomType itemRight = tableItems ? Atom::TableItemRight : Atom::ListItemRight;
1790
1791 // Helper to add an item to navigation bar based on a string link target
1792 auto addNavItem = [&](const QString &link, const QString &title) {
1793 navigationbar << Atom(itemLeft) << Atom(Atom::NavLink, link)
1795 << Atom(Atom::String, title)
1796 << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK) << Atom(itemRight);
1797 };
1798
1799 // Helper to add an item to navigation bar based on a target node
1800 auto addNavItemNode = [&](const Node *node, const QString &title) {
1801 navigationbar << Atom(itemLeft);
1802 addNodeLink(navigationbar, node, title);
1803 navigationbar << Atom(itemRight);
1804 };
1805
1806 // Resolve the associated module (collection) node and its 'state' description
1807 const auto *moduleNode = m_qdb->getModuleNode(node);
1808 QString moduleState;
1809 if (moduleNode && !moduleNode->state().isEmpty())
1810 moduleState = QStringLiteral(" (%1)").arg(moduleNode->state());
1811
1812 if (m_hometitle == title)
1813 return;
1814 if (!m_homepage.isEmpty())
1815 addNavItem(m_homepage, m_hometitle);
1816 if (!m_landingpage.isEmpty() && m_landingtitle != title)
1817 addNavItem(m_landingpage, m_landingtitle);
1818
1819 if (node->isClassNode()) {
1820 const bool hasClassesItem = !m_cppclassespage.isEmpty() && !m_cppclassestitle.isEmpty();
1821 if (hasClassesItem)
1822 addNavItem(m_cppclassespage, m_cppclassestitle);
1823 if (!node->physicalModuleName().isEmpty()) {
1824 // Add explicit link to the \module page if:
1825 // - It's not the C++ classes page that's already added, OR
1826 // - It has a \modulestate associated with it
1827 if (moduleNode && (!moduleState.isEmpty() || moduleNode->title() != m_cppclassespage)) {
1828 const QString moduleText = hasClassesItem || moduleNode->title().isEmpty()
1829 ? moduleNode->name() : moduleNode->title();
1830 addNavItemNode(moduleNode, moduleText + moduleState);
1831 }
1832 }
1833 navigationbar << Atom(itemLeft) << Atom(Atom::String, node->name()) << Atom(itemRight);
1834 } else if (node->isQmlType()) {
1835 const bool hasTypesItem = !m_qmltypespage.isEmpty() && !m_qmltypestitle.isEmpty();
1836 if (hasTypesItem)
1837 addNavItem(m_qmltypespage, m_qmltypestitle);
1838 // Add explicit link to the \qmlmodule page if:
1839 // - It's not the QML types page that's already added, OR
1840 // - It has a \modulestate associated with it
1841 if (moduleNode && (!moduleState.isEmpty() || moduleNode->title() != m_qmltypespage)) {
1842 const QString moduleText = hasTypesItem || moduleNode->title().isEmpty()
1843 ? moduleNode->name() : moduleNode->title();
1844 addNavItemNode(moduleNode, moduleText + moduleState);
1845 }
1846 navigationbar << Atom(itemLeft) << Atom(Atom::String, node->name()) << Atom(itemRight);
1847 } else {
1848 if (node->isPageNode()) {
1849 auto currentNode{static_cast<const PageNode*>(node)};
1850 std::deque<const Node *> navNodes;
1851 // Cutoff at 16 items in case there's a circular dependency
1852 qsizetype navItems = 0;
1853 while (currentNode->navigationParent() && ++navItems < 16) {
1854 if (std::find(navNodes.cbegin(), navNodes.cend(),
1855 currentNode->navigationParent()) == navNodes.cend())
1856 navNodes.push_front(currentNode->navigationParent());
1857 currentNode = currentNode->navigationParent();
1858 }
1859 // If no nav. parent was found but the page is a \group member, add a link to the
1860 // (first) group page.
1861 if (navNodes.empty()) {
1862 const QStringList groups = static_cast<const PageNode *>(node)->groupNames();
1863 for (const auto &groupName : groups) {
1864 const auto *groupNode = m_qdb->findNodeByNameAndType(QStringList{groupName}, &Node::isGroup);
1865 if (groupNode && !groupNode->title().isEmpty()) {
1866 navNodes.push_front(groupNode);
1867 break;
1868 }
1869 }
1870 }
1871 while (!navNodes.empty()) {
1872 if (navNodes.front()->isPageNode())
1873 addNavItemNode(navNodes.front(), navNodes.front()->title());
1874 navNodes.pop_front();
1875 }
1876 }
1877 if (!navigationbar.isEmpty()) {
1878 navigationbar << Atom(itemLeft) << Atom(Atom::String, title) << Atom(itemRight);
1879 }
1880 }
1881
1882 generateText(navigationbar, node, marker);
1883
1884 if (buildversion.isEmpty())
1885 return;
1886
1887 navigationbar.clear();
1888
1889 if (tableItems) {
1890 out() << "</tr></table><table class=\"buildversion\"><tr>\n"
1891 << R"(<td id="buildversion" width="100%" align="right">)";
1892 } else {
1893 out() << "<li id=\"buildversion\">";
1894 }
1895
1896 // Link buildversion string to navigation.landingpage
1897 if (!m_landingpage.isEmpty() && m_landingtitle != title) {
1898 navigationbar << Atom(Atom::NavLink, m_landingpage)
1899 << Atom(Atom::FormattingLeft, ATOM_FORMATTING_LINK)
1900 << Atom(Atom::String, buildversion)
1901 << Atom(Atom::FormattingRight, ATOM_FORMATTING_LINK);
1902 generateText(navigationbar, node, marker);
1903 } else {
1904 out() << buildversion;
1905 }
1906 if (tableItems)
1907 out() << "</td>\n";
1908 else
1909 out() << "</li>\n";
1910}
1911
1912void HtmlGenerator::generateHeader(const QString &title, const Node *node, CodeMarker *marker,
1913 const QString &metaKeyword)
1914{
1915 out() << "<!DOCTYPE html>\n";
1916 out() << QString("<html lang=\"%1\">\n").arg(naturalLanguage);
1917 out() << "<head>\n";
1918 out() << " <meta charset=\"utf-8\">\n";
1919 if (node && !node->doc().location().isEmpty())
1920 out() << "<!-- " << node->doc().location().fileName() << " -->\n";
1921
1922 if (node && !node->doc().briefText().isEmpty()) {
1923 out() << " <meta name=\"description\" content=\""
1924 << protectEnc(node->doc().briefText().toString())
1925 << "\">\n";
1926 }
1927
1928 if (!metaKeyword.isEmpty()) {
1929 // If provided, write meta-content keyword(s) as-is
1930 out() << " <meta name=\"keywords\" content=\"%1\">\n"_L1.arg(protectEnc(metaKeyword));
1931 } else if (node) {
1932 // Otherwise, add entries from `\meta keywords` as a comma-separated list
1933 QStringList keywords;
1934 if (const auto *metaTags = node->doc().metaTagMap()) {
1935 for (const auto &kw : metaTags->values(u"keywords"_s))
1936 keywords << kw.split(','_L1, Qt::SkipEmptyParts);
1937 }
1938
1939 // For API reference pages and examples, also add the Node type string as a keyword
1940 if (isApiGenus(node->genus()) || node->isExample())
1941 keywords << node->nodeTypeString().toLower().remove(' '_L1);
1942
1943 if (!keywords.isEmpty()) {
1944 std::transform(keywords.begin(), keywords.end(), keywords.begin(),
1945 [](const QString &k) { return k.trimmed(); });
1946 keywords.removeDuplicates();
1947 out() << " <meta name=\"keywords\" content=\"" << protectEnc(keywords.join(','_L1))
1948 << "\">\n";
1949 }
1950 }
1951
1952 // determine the rest of the <title> element content: "title | titleSuffix version"
1953 QString titleSuffix;
1954 if (!m_landingtitle.isEmpty()) {
1955 // for normal pages: "title | landingtitle version"
1956 titleSuffix = m_landingtitle;
1957 } else if (!m_hometitle.isEmpty()) {
1958 // for pages that set the homepage title but not landing page title:
1959 // "title | hometitle version"
1960 if (title != m_hometitle)
1961 titleSuffix = m_hometitle;
1962 } else {
1963 // "title | productname version"
1964 titleSuffix = m_productName.isEmpty() ? m_project : m_productName;
1965 }
1966 if (title == titleSuffix)
1967 titleSuffix.clear();
1968
1969 out() << " <title>";
1970 if (!titleSuffix.isEmpty() && !title.isEmpty()) {
1971 out() << "%1 | %2"_L1.arg(protectEnc(title), titleSuffix);
1972 } else {
1973 out() << protectEnc(title);
1974 }
1975
1976 // append a full version to the suffix if neither suffix nor title
1977 // include (a prefix of) version information
1978 QVersionNumber projectVersion = QVersionNumber::fromString(m_qdb->version());
1979 if (!projectVersion.isNull()) {
1980 QVersionNumber titleVersion;
1981 static const QRegularExpression re(QLatin1String(R"(\d+\.\d+)"));
1982 const QString &versionedTitle = titleSuffix.isEmpty() ? title : titleSuffix;
1983 auto match = re.match(versionedTitle);
1984 if (match.hasMatch())
1985 titleVersion = QVersionNumber::fromString(match.captured());
1986 if (titleVersion.isNull() || !titleVersion.isPrefixOf(projectVersion)) {
1987 // Prefix with product name if one exists
1988 if (!m_productName.isEmpty() && titleSuffix != m_productName)
1989 out() << " | %1"_L1.arg(m_productName);
1990 out() << " %1"_L1.arg(projectVersion.toString());
1991 }
1992 }
1993 out() << "</title>\n";
1994
1995 // Include style sheet and script links.
1996 out() << m_headerStyles;
1997 out() << m_headerScripts;
1998 out() << m_endHeader;
1999
2000 out() << QString(m_postHeader).replace("\\" + COMMAND_VERSION, m_qdb->version());
2001 bool usingTable = m_postHeader.trimmed().endsWith(QLatin1String("<tr>"));
2002 generateNavigationBar(title, node, marker, m_buildversion, usingTable);
2003 out() << QString(m_postPostHeader).replace("\\" + COMMAND_VERSION, m_qdb->version());
2004
2005 m_navigationLinks.clear();
2006 refMap.clear();
2007 m_recentSectionRef.clear();
2008 m_emittedMemberRefs.clear();
2009
2010 if (node && !node->links().empty()) {
2011 std::pair<QString, QString> linkPair;
2012 std::pair<QString, QString> anchorPair;
2013 const Node *linkNode;
2014 bool useSeparator = false;
2015
2016 if (node->links().contains(Node::PreviousLink)) {
2017 linkPair = node->links()[Node::PreviousLink];
2018 linkNode = m_qdb->findNodeForTarget(linkPair.first, node);
2019 if (linkNode == nullptr && !noLinkErrors())
2020 node->doc().location().warning(
2021 QStringLiteral("Cannot link to '%1'").arg(linkPair.first));
2022 if (linkNode == nullptr || linkNode == node)
2023 anchorPair = linkPair;
2024 else
2025 anchorPair = anchorForNode(linkNode);
2026
2027 out() << R"( <link rel="prev" href=")" << anchorPair.first << "\" />\n";
2028
2029 m_navigationLinks += R"(<a class="prevPage" href=")" + anchorPair.first + "\">";
2030 if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty())
2031 m_navigationLinks += protect(anchorPair.second);
2032 else
2033 m_navigationLinks += protect(linkPair.second);
2034 m_navigationLinks += "</a>\n";
2035 useSeparator = !m_navigationSeparator.isEmpty();
2036 }
2037 if (node->links().contains(Node::NextLink)) {
2038 linkPair = node->links()[Node::NextLink];
2039 linkNode = m_qdb->findNodeForTarget(linkPair.first, node);
2040 if (linkNode == nullptr && !noLinkErrors())
2041 node->doc().location().warning(
2042 QStringLiteral("Cannot link to '%1'").arg(linkPair.first));
2043 if (linkNode == nullptr || linkNode == node)
2044 anchorPair = linkPair;
2045 else
2046 anchorPair = anchorForNode(linkNode);
2047
2048 out() << R"( <link rel="next" href=")" << anchorPair.first << "\" />\n";
2049
2050 if (useSeparator)
2051 m_navigationLinks += m_navigationSeparator;
2052
2053 m_navigationLinks += R"(<a class="nextPage" href=")" + anchorPair.first + "\">";
2054 if (linkPair.first == linkPair.second && !anchorPair.second.isEmpty())
2055 m_navigationLinks += protect(anchorPair.second);
2056 else
2057 m_navigationLinks += protect(linkPair.second);
2058 m_navigationLinks += "</a>\n";
2059 }
2060 if (node->links().contains(Node::StartLink)) {
2061 linkPair = node->links()[Node::StartLink];
2062 linkNode = m_qdb->findNodeForTarget(linkPair.first, node);
2063 if (linkNode == nullptr && !noLinkErrors())
2064 node->doc().location().warning(
2065 QStringLiteral("Cannot link to '%1'").arg(linkPair.first));
2066 if (linkNode == nullptr || linkNode == node)
2067 anchorPair = std::move(linkPair);
2068 else
2069 anchorPair = anchorForNode(linkNode);
2070 out() << R"( <link rel="start" href=")" << anchorPair.first << "\" />\n";
2071 }
2072 }
2073
2074 if (node && !node->links().empty())
2075 out() << "<p class=\"naviNextPrevious headerNavi\">\n" << m_navigationLinks << "</p>\n";
2076}
2077
2078void HtmlGenerator::generateTitle(const Text &title, const Text &subtitle,
2079 SubTitleSize subTitleSize, const Node *relative,
2080 CodeMarker *marker)
2081{
2082 out() << QString(m_prologue).replace("\\" + COMMAND_VERSION, m_qdb->version());
2083 QString attribute;
2084 if (isApiGenus(relative->genus()))
2085 attribute = R"( translate="no")";
2086
2087 if (!title.isEmpty()) {
2088 out() << "<h1 class=\"title\"" << attribute << ">";
2089 generateText(title, relative, marker);
2090 out() << "</h1>\n";
2091 }
2092 if (!subtitle.isEmpty()) {
2093 out() << "<span";
2094 if (subTitleSize == SmallSubTitle)
2095 out() << " class=\"small-subtitle\"" << attribute << ">";
2096 else
2097 out() << " class=\"subtitle\"" << attribute << ">";
2098 generateText(subtitle, relative, marker);
2099 out() << "</span>\n";
2100 }
2101}
2102
2103void HtmlGenerator::generateFooter(const Node *node)
2104{
2105 if (node && !node->links().empty())
2106 out() << "<p class=\"naviNextPrevious footerNavi\">\n" << m_navigationLinks << "</p>\n";
2107
2108 out() << QString(m_footer).replace("\\" + COMMAND_VERSION, m_qdb->version())
2109 << QString(m_address).replace("\\" + COMMAND_VERSION, m_qdb->version());
2110
2111 out() << "</body>\n";
2112 out() << "</html>\n";
2113}
2114
2115/*!
2116 Lists the required imports and includes in a table.
2117 The number of rows is known.
2118*/
2119void HtmlGenerator::generateRequisites(Aggregate *aggregate, CodeMarker *marker)
2120{
2121 QMap<QString, Text> requisites;
2122 Text text;
2123
2124 const QString headerText = "Header";
2125 const QString sinceText = "Since";
2126 const QString inheritedByText = "Inherited By";
2127 const QString inheritsText = "Inherits";
2128 const QString nativeTypeText = "In QML";
2129 const QString qtVariableText = "qmake";
2130 const QString cmakeText = "CMake";
2131 const QString statusText = "Status";
2132
2133 // The order of the requisites matter
2134 const QStringList requisiteorder { headerText, cmakeText, qtVariableText, sinceText,
2135 nativeTypeText, inheritsText, inheritedByText, statusText };
2136
2137 addIncludeFileToMap(aggregate, requisites, text, headerText);
2138 addSinceToMap(aggregate, requisites, &text, sinceText);
2139
2140 if (aggregate->isClassNode() || aggregate->isNamespace()) {
2141 addCMakeInfoToMap(aggregate, requisites, &text, cmakeText);
2142 addQtVariableToMap(aggregate, requisites, &text, qtVariableText);
2143 }
2144
2145 if (aggregate->isClassNode()) {
2146 auto *classe = dynamic_cast<ClassNode *>(aggregate);
2147 if (classe && classe->isQmlNativeType()) {
2148 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
2149 const NodeContext context = classe->createContext();
2150 if (InclusionFilter::isIncluded(policy, context))
2151 addQmlNativeTypesToMap(requisites, &text, nativeTypeText, classe);
2152 }
2153
2154 const auto *metaTags = classe ? classe->doc().metaTagMap() : nullptr;
2155 if (!metaTags || !metaTags->contains(u"qdoc-suppress-inheritance"_s))
2156 addInheritsToMap(requisites, &text, inheritsText, classe);
2157 addInheritedByToMap(requisites, &text, inheritedByText, classe);
2158 }
2159
2160 // Add the state description (if any) to the map
2161 addStatusToMap(aggregate, requisites, text, statusText);
2162
2163 if (!requisites.isEmpty()) {
2164 // generate the table
2165 generateTheTable(requisiteorder, requisites, aggregate, marker);
2166 }
2167}
2168
2169/*!
2170 * \internal
2171 */
2172void HtmlGenerator::generateTheTable(const QStringList &requisiteOrder,
2173 const QMap<QString, Text> &requisites,
2174 const Aggregate *aggregate, CodeMarker *marker)
2175{
2176 out() << "<div class=\"table\"><table class=\"alignedsummary requisites\" translate=\"no\">\n";
2177
2178 for (auto it = requisiteOrder.constBegin(); it != requisiteOrder.constEnd(); ++it) {
2179
2180 if (requisites.contains(*it)) {
2181 out() << "<tr>"
2182 << "<td class=\"memItemLeft rightAlign topAlign\"> " << *it
2183 << ":"
2184 "</td><td class=\"memItemRight bottomAlign\"> ";
2185
2186 generateText(requisites.value(*it), aggregate, marker);
2187 out() << "</td></tr>\n";
2188 }
2189 }
2190 out() << "</table></div>\n";
2191}
2192
2193/*!
2194 * \internal
2195 * Adds inherited by information to the map.
2196 */
2197void HtmlGenerator::addInheritedByToMap(QMap<QString, Text> &requisites, Text *text,
2198 const QString &inheritedByText, ClassNode *classe)
2199{
2200 if (!classe->derivedClasses().isEmpty()) {
2201 text->clear();
2202 *text << Atom::ParaLeft;
2203 int count = appendSortedNames(*text, classe, classe->derivedClasses());
2204 *text << Atom::ParaRight;
2205 if (count > 0)
2206 requisites.insert(inheritedByText, *text);
2207 }
2208}
2209
2210/*!
2211 * \internal
2212 * Adds base classes to the map.
2213 */
2214void HtmlGenerator::addInheritsToMap(QMap<QString, Text> &requisites, Text *text,
2215 const QString &inheritsText, ClassNode *classe)
2216{
2217 if (!classe->baseClasses().isEmpty()) {
2218 int index = 0;
2219 text->clear();
2220 const auto baseClasses = classe->baseClasses();
2221 for (const auto &cls : baseClasses) {
2222 if (cls.m_node) {
2223 appendFullName(*text, cls.m_node, classe);
2224
2225 if (cls.m_access == Access::Protected) {
2226 *text << " (protected)";
2227 } else if (cls.m_access == Access::Private) {
2228 *text << " (private)";
2229 }
2230 *text << TextUtils::comma(index++, classe->baseClasses().size());
2231 }
2232 }
2233 *text << Atom::ParaRight;
2234 if (index > 0)
2235 requisites.insert(inheritsText, *text);
2236 }
2237}
2238
2239/*!
2240 \internal
2241 Add the QML/C++ native type information to the map.
2242 */
2243void HtmlGenerator::addQmlNativeTypesToMap(QMap<QString, Text> &requisites, Text *text,
2244 const QString &nativeTypeText, ClassNode *classe) const
2245{
2246 if (!text)
2247 return;
2248
2249 text->clear();
2250
2251 QList<QmlTypeNode *> nativeTypes { classe->qmlNativeTypes().cbegin(), classe->qmlNativeTypes().cend()};
2252 std::sort(nativeTypes.begin(), nativeTypes.end(), Node::nodeNameLessThan);
2253 qsizetype index { 0 };
2254
2255 for (const auto &item : std::as_const(nativeTypes)) {
2256 addNodeLink(*text, item);
2257 *text << TextUtils::comma(index++, nativeTypes.size());
2258 }
2259 requisites.insert(nativeTypeText, *text);
2260}
2261
2262/*!
2263 * \internal
2264 * Adds the CMake package and link library information to the map.
2265 */
2266void HtmlGenerator::addCMakeInfoToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites,
2267 Text *text, const QString &CMakeInfo) const
2268{
2269 if (!aggregate->physicalModuleName().isEmpty() && text != nullptr) {
2270 const CollectionNode *cn =
2271 m_qdb->getCollectionNode(aggregate->physicalModuleName(), NodeType::Module);
2272
2273 const auto result = cmakeRequisite(cn);
2274
2275 if (!result) {
2276 return;
2277 }
2278
2279 text->clear();
2280
2281 const Atom lineBreak = Atom(Atom::RawString, "<br/>\n");
2282
2283 *text << openCodeTag << result->first << closeCodeTag << lineBreak
2284 << openCodeTag << result->second << closeCodeTag;
2285
2286 requisites.insert(CMakeInfo, *text);
2287 }
2288}
2289
2290/*!
2291 * \internal
2292 * Adds the Qt variable (from the \\qtvariable command) to the map.
2293 */
2294void HtmlGenerator::addQtVariableToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites,
2295 Text *text, const QString &qtVariableText) const
2296{
2297 if (!aggregate->physicalModuleName().isEmpty()) {
2298 const CollectionNode *cn =
2299 m_qdb->getCollectionNode(aggregate->physicalModuleName(), NodeType::Module);
2300
2301 if (cn && !cn->qtVariable().isEmpty()) {
2302 text->clear();
2303 *text << openCodeTag << "QT += " + cn->qtVariable() << closeCodeTag;
2304 requisites.insert(qtVariableText, *text);
2305 }
2306 }
2307}
2308
2309/*!
2310 * \internal
2311 * Adds the since information (from the \\since command) to the map.
2312 *
2313 */
2314void HtmlGenerator::addSinceToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites,
2315 Text *text, const QString &sinceText) const
2316{
2317 if (!aggregate->since().isEmpty() && text != nullptr) {
2318 text->clear();
2319 *text << formatSince(aggregate) << Atom::ParaRight;
2320 requisites.insert(sinceText, *text);
2321 }
2322}
2323
2324/*!
2325 * \internal
2326 * Adds the status description for \a aggregate, together with a <span> element, to the \a
2327 * requisites map.
2328 *
2329 * The span element can be used for adding CSS styling/icon associated with a specific status.
2330 * The span class name is constructed by converting the description (sans \\deprecated
2331 * version info) to lowercase and replacing all non-alphanum characters with hyphens. In
2332 * addition, the span has a class \c status. For example,
2333 * 'Tech Preview' -> class="status tech-preview"
2334*/
2335void HtmlGenerator::addStatusToMap(const Aggregate *aggregate, QMap<QString, Text> &requisites,
2336 Text &text, const QString &statusText) const
2337{
2338 auto status{formatStatus(aggregate, m_qdb)};
2339 if (!status)
2340 return;
2341
2342 QString spanClass;
2343 if (aggregate->status() == Status::Deprecated)
2344 spanClass = u"deprecated"_s; // Disregard any version info
2345 else
2346 spanClass = TextUtils::asAsciiPrintable(status.value());
2347
2348 text.clear();
2349 text << Atom(Atom::String, status.value())
2350 << Atom(Atom::FormattingLeft, ATOM_FORMATTING_SPAN +
2351 "class=\"status %1\""_L1.arg(spanClass))
2352 << Atom(Atom::FormattingRight, ATOM_FORMATTING_SPAN);
2353 requisites.insert(statusText, text);
2354}
2355
2356/*!
2357 * \internal
2358 * Adds the include file (resolved automatically or set with the
2359 * \\inheaderfile command) to the map.
2360 */
2361void HtmlGenerator::addIncludeFileToMap(const Aggregate *aggregate,
2362 QMap<QString, Text> &requisites, Text& text,
2363 const QString &headerText)
2364{
2365 if (aggregate->includeFile()) {
2366 text.clear();
2367 text << openCodeTag << "#include <%1>"_L1.arg(*aggregate->includeFile()) << closeCodeTag;
2368 requisites.insert(headerText, text);
2369 }
2370}
2371
2372/*!
2373 Lists the required imports and includes in a table.
2374 The number of rows is known.
2375*/
2376void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker)
2377{
2378 if (qcn == nullptr)
2379 return;
2380
2381 QMap<QString, Text> requisites;
2382 Text text;
2383
2384 const QString importText = "Import Statement";
2385 const QString sinceText = "Since";
2386 const QString inheritedByText = "Inherited By";
2387 const QString inheritsText = "Inherits";
2388 const QString nativeTypeText = "In C++";
2389 const QString statusText = "Status";
2390
2391 // add the module name and version to the map
2392 QString logicalModuleVersion;
2393 const CollectionNode *collection = qcn->logicalModule();
2394
2395 // skip import statement of \internal collections
2396 if (!qcn->logicalModuleName().isEmpty()) {
2397 bool generate_import = true;
2398 if (collection) {
2399 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
2400 const NodeContext context = collection->createContext();
2401 generate_import = InclusionFilter::isIncluded(policy, context);
2402 }
2403 if (generate_import) {
2404 QStringList parts = QStringList() << "import" << qcn->logicalModuleName() << qcn->logicalModuleVersion();
2405 text.clear();
2406 text << openCodeTag << parts.join(' ').trimmed() << closeCodeTag;
2407 requisites.insert(importText, text);
2408 }
2409 } else if (!qcn->isQmlBasicType() && qcn->logicalModuleName().isEmpty()) {
2410 qcn->doc().location().warning(QStringLiteral("Could not resolve QML import statement for type '%1'").arg(qcn->name()),
2411 QStringLiteral("Maybe you forgot to use the '\\%1' command?").arg(COMMAND_INQMLMODULE));
2412 }
2413
2414 // add the since and project into the map
2415 if (!qcn->since().isEmpty()) {
2416 text.clear();
2417 text << formatSince(qcn) << Atom::ParaRight;
2418 requisites.insert(sinceText, text);
2419 }
2420
2421 // add the native type to the map
2422 if (ClassNode *cn = qcn->classNode(); cn && cn->isQmlNativeType()) {
2423 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
2424 const NodeContext context = cn->createContext();
2425 if (InclusionFilter::isIncluded(policy, context)) {
2426 text.clear();
2427 addNodeLink(text, cn);
2428 requisites.insert(nativeTypeText, text);
2429 }
2430 }
2431
2432 // add the inherits to the map
2433 QmlTypeNode *base = qcn->qmlBaseNode();
2434 NodeList subs;
2435 QmlTypeNode::subclasses(qcn, subs, true);
2436 QStringList knownTypeNames{qcn->name()};
2437
2438 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
2439 while (base) {
2440 const NodeContext context = base->createContext();
2441 if (InclusionFilter::isIncluded(policy, context))
2442 break;
2443 base = base->qmlBaseNode();
2444 }
2445 if (base) {
2446 knownTypeNames << base->name();
2447 text.clear();
2448 text << Atom::ParaLeft;
2449 addNodeLink(text, base);
2450
2451 // Disambiguate with '(<QML module name>)' if there are clashing type names
2452 for (const auto sub : std::as_const(subs)) {
2453 if (knownTypeNames.contains(sub->name())) {
2454 text << Atom(Atom::String, " (%1)"_L1.arg(base->logicalModuleName()));
2455 break;
2456 }
2457 }
2458 text << Atom::ParaRight;
2459 requisites.insert(inheritsText, text);
2460 }
2461
2462 // add the inherited-by to the map
2463 if (!subs.isEmpty()) {
2464 text.clear();
2465 text << Atom::ParaLeft;
2466 int count = appendSortedQmlNames(text, qcn, knownTypeNames, subs);
2467 text << Atom::ParaRight;
2468 if (count > 0)
2469 requisites.insert(inheritedByText, text);
2470 }
2471
2472 // Add the state description (if any) to the map
2473 addStatusToMap(qcn, requisites, text, statusText);
2474
2475 // The order of the requisites matter
2476 const QStringList requisiteorder {std::move(importText), std::move(sinceText),
2477 std::move(nativeTypeText), std::move(inheritsText),
2478 std::move(inheritedByText), std::move(statusText)};
2479
2480 if (!requisites.isEmpty())
2481 generateTheTable(requisiteorder, requisites, qcn, marker);
2482}
2483
2484void HtmlGenerator::generateBrief(const Node *node, CodeMarker *marker, const Node *relative,
2485 bool addLink)
2486{
2487 Text brief = node->doc().briefText();
2488
2489 if (!brief.isEmpty()) {
2490 if (!brief.lastAtom()->string().endsWith('.')) {
2491 brief << Atom(Atom::String, ".");
2492 node->doc().location().warning(
2493 QStringLiteral("'\\brief' statement does not end with a full stop."));
2494 }
2495 generateExtractionMark(node, BriefMark);
2496 out() << "<p>";
2497 generateText(brief, node, marker);
2498
2499 if (addLink) {
2500 if (!relative || node == relative)
2501 out() << " <a href=\"#";
2502 else
2503 out() << " <a href=\"" << linkForNode(node, relative) << '#';
2504 out() << registerRef("details") << "\">More...</a>";
2505 }
2506
2507 out() << "</p>\n";
2508 generateExtractionMark(node, EndMark);
2509 }
2510}
2511
2512/*!
2513 Revised for the new doc format.
2514 Generates a table of contents beginning at \a node.
2515 */
2516void HtmlGenerator::generateTableOfContents(const Node *node, CodeMarker *marker,
2517 const SectionVector *sections)
2518{
2519 QList<Atom *> toc;
2521 toc = node->doc().tableOfContents();
2522 if (tocDepth == 0 || (toc.isEmpty() && !sections && !node->isModule())) {
2523 generateSidebar();
2524 return;
2525 }
2526
2527 int sectionNumber = 1;
2528 int detailsBase = 0;
2529
2530 // disable nested links in table of contents
2531 m_inContents = true;
2532
2533 out() << "<div class=\"sidebar\">\n";
2534 out() << "<div class=\"toc\">\n";
2535 out() << "<h3 id=\"toc\">Contents</h3>\n";
2536
2537 if (node->isModule()) {
2538 openUnorderedList();
2539 if (!static_cast<const CollectionNode *>(node)->noAutoList()) {
2540 if (node->hasNamespaces()) {
2541 out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
2542 << registerRef("namespaces") << "\">Namespaces</a></li>\n";
2543 }
2544 if (node->hasClasses()) {
2545 out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
2546 << registerRef("classes") << "\">Classes</a></li>\n";
2547 }
2548 }
2549 out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#" << registerRef("details")
2550 << "\">Detailed Description</a></li>\n";
2551 for (const auto &entry : std::as_const(toc)) {
2552 if (entry->string().toInt() == 1) {
2553 detailsBase = 1;
2554 break;
2555 }
2556 }
2557 } else if (sections && (node->isClassNode() || node->isNamespace() || node->isQmlType())) {
2558 for (const auto &section : *sections) {
2559 if (!section.members().isEmpty()) {
2560 openUnorderedList();
2561 out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
2562 << registerRef(section.plural()) << "\">" << section.title() << "</a></li>\n";
2563 }
2564 if (!section.reimplementedMembers().isEmpty()) {
2565 openUnorderedList();
2566 QString ref = QString("Reimplemented ") + section.plural();
2567 out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
2568 << registerRef(ref.toLower()) << "\">"
2569 << QString("Reimplemented ") + section.title() << "</a></li>\n";
2570 }
2571 }
2572 if (!node->isNamespace() || node->hasDoc()) {
2573 openUnorderedList();
2574 out() << "<li class=\"level" << sectionNumber << "\"><a href=\"#"
2575 << registerRef("details") << "\">Detailed Description</a></li>\n";
2576 }
2577 for (const auto &entry : toc) {
2578 if (entry->string().toInt() == 1) {
2579 detailsBase = 1;
2580 break;
2581 }
2582 }
2583 }
2584
2585 for (const auto &atom : toc) {
2586 sectionNumber = atom->string().toInt() + detailsBase;
2587 // restrict the ToC depth to the one set by the HTML.tocdepth variable or
2588 // print all levels if tocDepth is not set.
2589 if (sectionNumber <= tocDepth || tocDepth < 0) {
2590 openUnorderedList();
2591 int numAtoms;
2592 Text headingText = Text::sectionHeading(atom);
2593 out() << "<li class=\"level" << sectionNumber << "\">";
2594 out() << "<a href=\"" << '#' << Tree::refForAtom(atom) << "\">";
2595 generateAtomList(headingText.firstAtom(), node, marker, true, numAtoms);
2596 out() << "</a></li>\n";
2597 }
2598 }
2599 closeUnorderedList();
2600 out() << "</div>\n";
2601 out() << R"(<div class="sidebar-content" id="sidebar-content"></div>)";
2602 out() << "</div>\n";
2603 m_inContents = false;
2604 m_inLink = false;
2605}
2606
2607/*!
2608 Outputs a placeholder div where the style can add customized sidebar content.
2609 */
2610void HtmlGenerator::generateSidebar()
2611{
2612 out() << "<div class=\"sidebar\">";
2613 out() << R"(<div class="sidebar-content" id="sidebar-content"></div>)";
2614 out() << "</div>\n";
2615}
2616
2617QString HtmlGenerator::generateAllMembersFile(const Section &section, CodeMarker *marker)
2618{
2619 if (section.isEmpty())
2620 return QString();
2621
2622 const Aggregate *aggregate = section.aggregate();
2623 QString fileName = fileBase(aggregate) + "-members." + fileExtension();
2624 beginSubPage(aggregate, fileName);
2625 QString title = "List of All Members for " + aggregate->plainFullName();
2626 generateHeader(title, aggregate, marker, u"auto-generated"_s);
2627 generateSidebar();
2628 generateTitle(title, Text(), SmallSubTitle, aggregate, marker);
2629 out() << "<p>This is the complete list of members for ";
2630 generateFullName(aggregate, nullptr);
2631 out() << ", including inherited members.</p>\n";
2632
2633 generateSectionList(section, aggregate, marker);
2634
2635 generateFooter();
2636 endSubPage();
2637 return fileName;
2638}
2639
2640/*!
2641 This function creates an html page on which are listed all
2642 the members of the QML class used to generte the \a sections,
2643 including the inherited members. The \a marker is used for
2644 formatting stuff.
2645 */
2646QString HtmlGenerator::generateAllQmlMembersFile(const Sections &sections, CodeMarker *marker)
2647{
2648
2650 return QString();
2651
2652 const Aggregate *aggregate = sections.aggregate();
2653 QString fileName = fileBase(aggregate) + "-members." + fileExtension();
2654 beginSubPage(aggregate, fileName);
2655 QString title = "List of All Members for " + aggregate->name();
2656 generateHeader(title, aggregate, marker, u"auto-generated"_s);
2657 generateSidebar();
2658 generateTitle(title, Text(), SmallSubTitle, aggregate, marker);
2659 out() << "<p>This is the complete list of members for ";
2660 generateFullName(aggregate, nullptr);
2661 out() << ", including inherited members.</p>\n";
2662
2664 for (int i = 0; i < cknl.size(); i++) {
2665 const auto &ckn = cknl[i];
2666 const QmlTypeNode *qcn = ckn.first;
2667 const NodeVector &nodes = ckn.second;
2668 if (nodes.isEmpty())
2669 continue;
2670 if (i != 0) {
2671 out() << "<p>The following members are inherited from ";
2672 generateFullName(qcn, nullptr);
2673 out() << ".</p>\n";
2674 }
2675 openUnorderedList();
2676 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
2677 for (int j = 0; j < nodes.size(); j++) {
2678 Node *node = nodes[j];
2679 const NodeContext context = node->createContext();
2680 if (!InclusionFilter::isIncluded(policy, context))
2681 continue;
2683 continue;
2684
2685 std::function<void(Node *)> generate = [&](Node *n) {
2686 out() << "<li class=\"fn\" translate=\"no\">";
2687 generateQmlItem(n, aggregate, marker, true);
2688 if (n->isQmlProperty()) {
2689 auto qpn = static_cast<QmlPropertyNode *>(n);
2690 QStringList hints = qpn->hints();
2691 if (qpn->isAttached())
2692 hints << "attached"_L1;
2693 if (!hints.isEmpty())
2694 out() << " [" << hints.join(' '_L1) << "]";
2695 } else if (n->isAttached()) {
2696 // Non-property attached items (signals, methods) show [attached]
2697 out() << " [attached]";
2698 }
2699 // Indent property group members
2700 if (n->isPropertyGroup()) {
2701 out() << "<ul>\n";
2702 const QList<Node *> &collective =
2703 static_cast<SharedCommentNode *>(n)->collective();
2704 std::for_each(collective.begin(), collective.end(), generate);
2705 out() << "</ul>\n";
2706 }
2707 out() << "</li>\n";
2708 };
2709 generate(node);
2710 }
2711 closeUnorderedList();
2712 }
2713
2714
2715 generateFooter();
2716 endSubPage();
2717 return fileName;
2718}
2719
2720QString HtmlGenerator::generateObsoleteMembersFile(const Sections &sections, CodeMarker *marker)
2721{
2722 SectionPtrVector summary_spv;
2723 SectionPtrVector details_spv;
2724 if (!sections.hasObsoleteMembers(&summary_spv, &details_spv))
2725 return QString();
2726
2727 const Aggregate *aggregate = sections.aggregate();
2728 QString title = "Obsolete Members for " + aggregate->plainFullName();
2729 QString fileName = fileBase(aggregate) + "-obsolete." + fileExtension();
2730
2731 beginSubPage(aggregate, fileName);
2732 generateHeader(title, aggregate, marker, u"auto-generated"_s);
2733 generateSidebar();
2734 generateTitle(title, Text(), SmallSubTitle, aggregate, marker);
2735
2736 out() << "<p><b>The following members of class "
2737 << "<a href=\"" << linkForNode(aggregate, nullptr) << "\" translate=\"no\">"
2738 << protectEnc(aggregate->name()) << "</a>"
2739 << " are deprecated.</b> "
2740 << "They are provided to keep old source code working. "
2741 << "We strongly advise against using them in new code.</p>\n";
2742
2743 for (const auto &section : summary_spv) {
2744 out() << "<h2>" << protectEnc(section->title()) << "</h2>\n";
2745 generateSectionList(*section, aggregate, marker, true);
2746 }
2747
2748 for (const auto &section : details_spv) {
2749 out() << "<h2>" << protectEnc(section->title()) << "</h2>\n";
2750
2751 const NodeVector &members = section->obsoleteMembers();
2752 for (const auto &member : members)
2753 generateDetailedMember(member, aggregate, marker);
2754 }
2755
2756 generateFooter();
2757 endSubPage();
2758 return fileName;
2759}
2760
2761/*!
2762 Generates a separate file where deprecated members of the QML
2763 type \a qcn are listed. The \a marker is used to generate
2764 the section lists, which are then traversed and output here.
2765 */
2766QString HtmlGenerator::generateObsoleteQmlMembersFile(const Sections &sections, CodeMarker *marker)
2767{
2768 SectionPtrVector summary_spv;
2769 SectionPtrVector details_spv;
2770 if (!sections.hasObsoleteMembers(&summary_spv, &details_spv))
2771 return QString();
2772
2773 const Aggregate *aggregate = sections.aggregate();
2774 QString title = "Obsolete Members for " + aggregate->name();
2775 QString fileName = fileBase(aggregate) + "-obsolete." + fileExtension();
2776
2777 beginSubPage(aggregate, fileName);
2778 generateHeader(title, aggregate, marker, u"auto-generated"_s);
2779 generateSidebar();
2780 generateTitle(title, Text(), SmallSubTitle, aggregate, marker);
2781
2782 out() << "<p><b>The following members of QML type "
2783 << "<a href=\"" << linkForNode(aggregate, nullptr) << "\">"
2784 << protectEnc(aggregate->name()) << "</a>"
2785 << " are deprecated.</b> "
2786 << "They are provided to keep old source code working. "
2787 << "We strongly advise against using them in new code.</p>\n";
2788
2789 for (const auto &section : summary_spv) {
2790 QString ref = registerRef(section->title().toLower());
2791 out() << "<h2 id=\"" << ref << "\">" << protectEnc(section->title()) << "</h2>\n";
2792 generateQmlSummary(section->obsoleteMembers(), aggregate, marker);
2793 }
2794
2795 for (const auto &section : details_spv) {
2796 out() << "<h2>" << protectEnc(section->title()) << "</h2>\n";
2797 const NodeVector &members = section->obsoleteMembers();
2798 for (const auto &member : members) {
2799 generateDetailedQmlMember(member, aggregate, marker);
2800 out() << "<br/>\n";
2801 }
2802 }
2803
2804 generateFooter();
2805 endSubPage();
2806 return fileName;
2807}
2808
2809void HtmlGenerator::generateClassHierarchy(const Node *relative, NodeMultiMap &classMap)
2810{
2811 if (classMap.isEmpty())
2812 return;
2813
2814 NodeMap topLevel;
2815 for (const auto &it : classMap) {
2816 auto *classe = static_cast<ClassNode *>(it);
2817 if (classe->baseClasses().isEmpty())
2818 topLevel.insert(classe->name(), classe);
2819 }
2820
2821 QStack<NodeMap> stack;
2822 stack.push(topLevel);
2823
2824 out() << "<ul>\n";
2825 while (!stack.isEmpty()) {
2826 if (stack.top().isEmpty()) {
2827 stack.pop();
2828 out() << "</ul>\n";
2829 } else {
2830 ClassNode *child = static_cast<ClassNode *>(*stack.top().begin());
2831 out() << "<li>";
2832 generateFullName(child, relative);
2833 out() << "</li>\n";
2834 stack.top().erase(stack.top().begin());
2835
2836 NodeMap newTop;
2837 const auto derivedClasses = child->derivedClasses();
2838 for (const RelatedClass &d : derivedClasses) {
2839 if (d.m_node && d.m_node->isInAPI())
2840 newTop.insert(d.m_node->name(), d.m_node);
2841 }
2842 if (!newTop.isEmpty()) {
2843 stack.push(newTop);
2844 out() << "<ul>\n";
2845 }
2846 }
2847 }
2848}
2849
2850/*!
2851 Outputs an annotated list of the nodes in \a unsortedNodes.
2852 A two-column table is output.
2853 */
2854NodeMultiMap HtmlGenerator::includedAnnotatedMembers(const Node *relative,
2855 const NodeList &nodes) const
2856{
2857 NodeMultiMap included;
2858 if (relative == nullptr)
2859 return included;
2860
2861 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
2862 for (auto *node : nodes) {
2863 const NodeContext context = node->createContext();
2864 if (InclusionFilter::isIncluded(policy, context) && !node->isDeprecated())
2865 included.insert(node->fullName(relative), node);
2866 }
2867 return included;
2868}
2869
2870void HtmlGenerator::generateAnnotatedList(const Node *relative, CodeMarker *marker,
2871 const NodeList &unsortedNodes, Qt::SortOrder sortOrder)
2872{
2873 generateAnnotatedList(relative, marker, includedAnnotatedMembers(relative, unsortedNodes),
2874 sortOrder);
2875}
2876
2877void HtmlGenerator::generateAnnotatedList(const Node *relative, CodeMarker *marker,
2878 const NodeMultiMap &nodeMap, Qt::SortOrder sortOrder)
2879{
2880 if (nodeMap.isEmpty())
2881 return;
2882 out() << "<div class=\"table\"><table class=\"annotated\">\n";
2883 int row = 0;
2884 NodeList nodes = nodeMap.values();
2885
2886 if (sortOrder == Qt::DescendingOrder)
2887 std::sort(nodes.rbegin(), nodes.rend(), Node::nodeSortKeyOrNameLessThan);
2888 else
2889 std::sort(nodes.begin(), nodes.end(), Node::nodeSortKeyOrNameLessThan);
2890
2891 // Multiple nodes may share a documentation page; list each page only once.
2892 auto sameLocation = [this](const Node *a, const Node *b) {
2893 return fullDocumentLocation(a) == fullDocumentLocation(b);
2894 };
2895 nodes.erase(std::unique(nodes.begin(), nodes.end(), sameLocation), nodes.end());
2896
2897 for (const auto *node : std::as_const(nodes)) {
2898 if (++row % 2 == 1)
2899 out() << "<tr class=\"odd topAlign\">";
2900 else
2901 out() << "<tr class=\"even topAlign\">";
2902 out() << "<td class=\"tblName\" translate=\"no\"><p>";
2903 generateFullName(node, relative);
2904 out() << "</p></td>";
2905
2906 if (!node->isTextPageNode()) {
2907 Text brief = node->doc().trimmedBriefText(node->name());
2908 if (!brief.isEmpty()) {
2909 out() << "<td class=\"tblDescr\"><p>";
2910 generateText(brief, node, marker);
2911 out() << "</p></td>";
2912 } else if (!node->reconstitutedBrief().isEmpty()) {
2913 out() << "<td class=\"tblDescr\"><p>";
2914 out() << node->reconstitutedBrief();
2915 out() << "</p></td>";
2916 }
2917 } else {
2918 out() << "<td class=\"tblDescr\"><p>";
2919 if (!node->reconstitutedBrief().isEmpty()) {
2920 out() << node->reconstitutedBrief();
2921 } else
2922 out() << protectEnc(node->doc().briefText().toString());
2923 out() << "</p></td>";
2924 }
2925 out() << "</tr>\n";
2926 }
2927 out() << "</table></div>\n";
2928}
2929
2930/*!
2931 Outputs a series of annotated lists from the nodes in \a nmm,
2932 divided into sections based by the key names in the multimap.
2933 */
2934void HtmlGenerator::generateAnnotatedLists(const Node *relative, CodeMarker *marker,
2935 const NodeMultiMap &nmm)
2936{
2937 const auto &uniqueKeys = nmm.uniqueKeys();
2938 for (const QString &name : uniqueKeys) {
2939 if (!name.isEmpty()) {
2940 out() << "<h2 id=\"" << registerRef(name.toLower()) << "\">" << protectEnc(name)
2941 << "</h2>\n";
2942 }
2943 generateAnnotatedList(relative, marker, nmm.values(name));
2944 }
2945}
2946
2947/*!
2948 This function finds the common prefix of the names of all
2949 the classes in the class map \a nmm and then generates a
2950 compact list of the class names alphabetized on the part
2951 of the name not including the common prefix. You can tell
2952 the function to use \a commonPrefix as the common prefix,
2953 but normally you let it figure it out itself by looking at
2954 the name of the first and last classes in the class map
2955 \a nmm.
2956 */
2957void HtmlGenerator::generateCompactList(ListType listType, const Node *relative,
2958 const NodeMultiMap &nmm, bool includeAlphabet,
2959 const QString &commonPrefix)
2960{
2961 if (nmm.isEmpty())
2962 return;
2963
2964 const int NumParagraphs = 37; // '0' to '9', 'A' to 'Z', '_'
2965 qsizetype commonPrefixLen = commonPrefix.size();
2966
2967 /*
2968 Divide the data into 37 paragraphs: 0, ..., 9, A, ..., Z,
2969 underscore (_). QAccel will fall in paragraph 10 (A) and
2970 QXtWidget in paragraph 33 (X). This is the only place where we
2971 assume that NumParagraphs is 37. Each paragraph is a NodeMultiMap.
2972 */
2973 NodeMultiMap paragraph[NumParagraphs + 1];
2974 QString paragraphName[NumParagraphs + 1];
2975 QSet<char> usedParagraphNames;
2976
2977 for (auto c = nmm.constBegin(); c != nmm.constEnd(); ++c) {
2978 QStringList pieces = c.key().split("::");
2979 int idx = commonPrefixLen;
2980 if (idx > 0 && !pieces.last().startsWith(commonPrefix, Qt::CaseInsensitive))
2981 idx = 0;
2982 QString last = pieces.last().toLower();
2983 QString key = last.mid(idx);
2984
2985 int paragraphNr = NumParagraphs - 1;
2986
2987 if (key[0].digitValue() != -1) {
2988 paragraphNr = key[0].digitValue();
2989 } else if (key[0] >= QLatin1Char('a') && key[0] <= QLatin1Char('z')) {
2990 paragraphNr = 10 + key[0].unicode() - 'a';
2991 }
2992
2993 paragraphName[paragraphNr] = key[0].toUpper();
2994 usedParagraphNames.insert(key[0].toLower().cell());
2995 paragraph[paragraphNr].insert(last, c.value());
2996 }
2997
2998 /*
2999 Each paragraph j has a size: paragraph[j].count(). In the
3000 discussion, we will assume paragraphs 0 to 5 will have sizes
3001 3, 1, 4, 1, 5, 9.
3002
3003 We now want to compute the paragraph offset. Paragraphs 0 to 6
3004 start at offsets 0, 3, 4, 8, 9, 14, 23.
3005 */
3006 qsizetype paragraphOffset[NumParagraphs + 1]; // 37 + 1
3007 paragraphOffset[0] = 0;
3008 for (int i = 0; i < NumParagraphs; i++) // i = 0..36
3009 paragraphOffset[i + 1] = paragraphOffset[i] + paragraph[i].size();
3010
3011 /*
3012 Output the alphabet as a row of links.
3013 */
3014 if (includeAlphabet) {
3015 out() << "<p class=\"centerAlign functionIndex\" translate=\"no\"><b>";
3016 for (int i = 0; i < 26; i++) {
3017 QChar ch('a' + i);
3018 if (usedParagraphNames.contains(char('a' + i)))
3019 out() << QString("<a href=\"#%1\">%2</a>&nbsp;").arg(ch).arg(ch.toUpper());
3020 }
3021 out() << "</b></p>\n";
3022 }
3023
3024 /*
3025 Output a <div> element to contain all the <dl> elements.
3026 */
3027 out() << "<div class=\"flowListDiv\" translate=\"no\">\n";
3028 m_numTableRows = 0;
3029
3030 // Build a map of all duplicate names across the entire list
3031 QHash<QString, int> nameOccurrences;
3032 for (const auto &[key, node] : nmm.asKeyValueRange()) {
3033 QStringList pieces{node->fullName(relative).split("::"_L1)};
3034 const QString &name{pieces.last()};
3035 nameOccurrences[name]++;
3036 }
3037
3038 int curParNr = 0;
3039 int curParOffset = 0;
3040
3041 for (int i = 0; i < nmm.size(); i++) {
3042 while ((curParNr < NumParagraphs) && (curParOffset == paragraph[curParNr].size())) {
3043 ++curParNr;
3044 curParOffset = 0;
3045 }
3046
3047 /*
3048 Starting a new paragraph means starting a new <dl>.
3049 */
3050 if (curParOffset == 0) {
3051 if (i > 0)
3052 out() << "</dl>\n";
3053 if (++m_numTableRows % 2 == 1)
3054 out() << "<dl class=\"flowList odd\">";
3055 else
3056 out() << "<dl class=\"flowList even\">";
3057 out() << "<dt class=\"alphaChar\"";
3058 if (includeAlphabet)
3059 out() << QString(" id=\"%1\"").arg(paragraphName[curParNr][0].toLower());
3060 out() << "><b>" << paragraphName[curParNr] << "</b></dt>\n";
3061 }
3062
3063 /*
3064 Output a <dd> for the current offset in the current paragraph.
3065 */
3066 out() << "<dd>";
3067 if ((curParNr < NumParagraphs) && !paragraphName[curParNr].isEmpty()) {
3068 NodeMultiMap::Iterator it;
3069 NodeMultiMap::Iterator next;
3070 it = paragraph[curParNr].begin();
3071 for (int j = 0; j < curParOffset; j++)
3072 ++it;
3073
3074 if (listType == Generic) {
3075 /*
3076 Previously, we used generateFullName() for this, but we
3077 require some special formatting.
3078 */
3079 out() << "<a href=\"" << linkForNode(it.value(), relative) << "\">";
3080 } else if (listType == Obsolete) {
3081 QString fileName = fileBase(it.value()) + "-obsolete." + fileExtension();
3082 QString link;
3084 link = "../%1/"_L1.arg(it.value()->tree()->physicalModuleName());
3085 link += fileName;
3086 out() << "<a href=\"" << link << "\">";
3087 }
3088
3089 QStringList pieces{it.value()->fullName(relative).split("::"_L1)};
3090 const auto &name{pieces.last()};
3091
3092 // Add module disambiguation if there are multiple types with the same name
3093 if (nameOccurrences[name] > 1) {
3094 const QString moduleName = it.value()->isQmlNode() ? it.value()->logicalModuleName()
3095 : it.value()->tree()->camelCaseModuleName();
3096 pieces.last().append(": %1"_L1.arg(moduleName));
3097 }
3098
3099 out() << protectEnc(pieces.last());
3100 out() << "</a>";
3101 if (pieces.size() > 1) {
3102 out() << " (";
3103 generateFullName(it.value()->parent(), relative);
3104 out() << ')';
3105 }
3106 }
3107 out() << "</dd>\n";
3108 curParOffset++;
3109 }
3110 if (nmm.size() > 0)
3111 out() << "</dl>\n";
3112
3113 out() << "</div>\n";
3114}
3115
3116void HtmlGenerator::generateFunctionIndex(const Node *relative)
3117{
3118 out() << "<p class=\"centerAlign functionIndex\" translate=\"no\"><b>";
3119 for (int i = 0; i < 26; i++) {
3120 QChar ch('a' + i);
3121 out() << QString("<a href=\"#%1\">%2</a>&nbsp;").arg(ch).arg(ch.toUpper());
3122 }
3123 out() << "</b></p>\n";
3124
3125 char nextLetter = 'a';
3126
3127 out() << "<ul translate=\"no\">\n";
3128 NodeMapMap &funcIndex = m_qdb->getFunctionIndex();
3129 for (auto fnMap = funcIndex.constBegin(); fnMap != funcIndex.constEnd(); ++fnMap) {
3130 const QString &key = fnMap.key();
3131 const QChar firstLetter = key.isEmpty() ? QChar('A') : key.front();
3132 Q_ASSERT_X(firstLetter.unicode() < 256, "generateFunctionIndex",
3133 "Only valid C++ identifiers were expected");
3134 const char currentLetter = firstLetter.isLower() ? firstLetter.unicode() : nextLetter - 1;
3135
3136 if (currentLetter < nextLetter) {
3137 out() << "<li>";
3138 } else {
3139 // TODO: This is not covered by our tests
3140 while (nextLetter < currentLetter)
3141 out() << QStringLiteral("<li id=\"%1\"></li>").arg(nextLetter++);
3142 Q_ASSERT(nextLetter == currentLetter);
3143 out() << QStringLiteral("<li id=\"%1\">").arg(nextLetter++);
3144 }
3145 out() << protectEnc(key) << ':';
3146
3147 for (auto it = (*fnMap).constBegin(); it != (*fnMap).constEnd(); ++it) {
3148 out() << ' ';
3149 generateFullName((*it)->parent(), relative, *it);
3150 }
3151 out() << "</li>\n";
3152 }
3153 while (nextLetter <= 'z')
3154 out() << QStringLiteral("<li id=\"%1\"></li>").arg(nextLetter++);
3155 out() << "</ul>\n";
3156}
3157
3158void HtmlGenerator::generateLegaleseList(const Node *relative, CodeMarker *marker)
3159{
3160 TextToNodeMap &legaleseTexts = m_qdb->getLegaleseTexts();
3161 for (auto it = legaleseTexts.cbegin(), end = legaleseTexts.cend(); it != end; ++it) {
3162 Text text = it.key();
3163 generateText(text, relative, marker);
3164 out() << "<ul>\n";
3165 do {
3166 out() << "<li>";
3167 generateFullName(it.value(), relative);
3168 out() << "</li>\n";
3169 ++it;
3170 } while (it != legaleseTexts.constEnd() && it.key() == text);
3171 out() << "</ul>\n";
3172 }
3173}
3174
3175void HtmlGenerator::generateQmlItem(const Node *node, const Node *relative, CodeMarker *marker,
3176 bool summary)
3177{
3178 QString marked = marker->markedUpQmlItem(node, summary);
3179 marked.replace("@param>", "i>");
3180
3181 marked.replace("<@extra>", "<code class=\"%1 extra\" translate=\"no\">"_L1
3182 .arg(summary ? "summary"_L1 : "details"_L1));
3183 marked.replace("</@extra>", "</code>");
3184
3185
3186 if (summary) {
3187 marked.remove("<@name>");
3188 marked.remove("</@name>");
3189 marked.remove("<@type>");
3190 marked.remove("</@type>");
3191 }
3192 out() << highlightedCode(marked, relative, false, Genus::QML);
3193}
3194
3195/*!
3196 This function generates a simple list (without annotations) for
3197 the members of collection node \a {cn}. The list is sorted
3198 according to \a sortOrder.
3199
3200 Returns \c true if the list was generated (collection has members),
3201 \c false otherwise.
3202 */
3203bool HtmlGenerator::generateGroupList(CollectionNode *cn, Qt::SortOrder sortOrder)
3204{
3205 m_qdb->mergeCollections(cn);
3206 if (cn->members().isEmpty())
3207 return false;
3208
3209 NodeList members{cn->members()};
3210 if (sortOrder == Qt::DescendingOrder)
3211 std::sort(members.rbegin(), members.rend(), Node::nodeSortKeyOrNameLessThan);
3212 else
3213 std::sort(members.begin(), members.end(), Node::nodeSortKeyOrNameLessThan);
3214 out() << "<ul>\n";
3215 for (const auto *node : std::as_const(members)) {
3216 out() << "<li translate=\"no\">";
3217 generateFullName(node, nullptr);
3218 out() << "</li>\n";
3219 }
3220 out() << "</ul>\n";
3221 return true;
3222}
3223
3224void HtmlGenerator::generateList(const Node *relative, CodeMarker *marker,
3225 const QString &selector, Qt::SortOrder sortOrder)
3226{
3227 CNMap cnm;
3229 if (selector == QLatin1String("overviews"))
3230 type = NodeType::Group;
3231 else if (selector == QLatin1String("cpp-modules"))
3232 type = NodeType::Module;
3233 else if (selector == QLatin1String("qml-modules"))
3234 type = NodeType::QmlModule;
3235 if (type != NodeType::NoType) {
3236 NodeList nodeList;
3237 m_qdb->mergeCollections(type, cnm, relative);
3238 const auto collectionList = cnm.values();
3239 nodeList.reserve(collectionList.size());
3240 for (auto *collectionNode : collectionList)
3241 nodeList.append(collectionNode);
3242 generateAnnotatedList(relative, marker, nodeList, sortOrder);
3243 } else {
3244 /*
3245 \generatelist {selector} is only allowed in a
3246 comment where the topic is \group, \module, or
3247 \qmlmodule.
3248 */
3249 if (relative && !relative->isCollectionNode()) {
3250 relative->doc().location().warning(
3251 QStringLiteral("\\generatelist {%1} is only allowed in \\group, "
3252 "\\module and \\qmlmodule comments.")
3253 .arg(selector));
3254 return;
3255 }
3256 auto *node = const_cast<Node *>(relative);
3257 auto *collectionNode = static_cast<CollectionNode *>(node);
3258 if (!collectionNode)
3259 return;
3260 m_qdb->mergeCollections(collectionNode);
3261 generateAnnotatedList(collectionNode, marker, collectionNode->members(), sortOrder);
3262 }
3263}
3264
3265void HtmlGenerator::generateSection(const NodeVector &nv, const Node *relative, CodeMarker *marker)
3266{
3267 bool alignNames = true;
3268 if (!nv.isEmpty()) {
3269 bool twoColumn = false;
3270 if (nv.first()->isProperty()) {
3271 twoColumn = (nv.size() >= 5);
3272 alignNames = false;
3273 }
3274 if (alignNames) {
3275 out() << "<div class=\"table\"><table class=\"alignedsummary\" translate=\"no\">\n";
3276 } else {
3277 if (twoColumn)
3278 out() << "<div class=\"table\"><table class=\"propsummary\" translate=\"no\">\n"
3279 << "<tr><td class=\"topAlign\">";
3280 out() << "<ul>\n";
3281 }
3282
3283 int i = 0;
3284 for (const auto &member : nv) {
3285 // Skip shared nodes that hold functions.
3286 if (member->isSharedCommentNode() && !member->isPropertyGroup())
3287 continue;
3288
3289 if (alignNames) {
3290 out() << "<tr><td class=\"memItemLeft rightAlign topAlign\"> ";
3291 } else {
3292 if (twoColumn && i == (nv.size() + 1) / 2)
3293 out() << "</ul></td><td class=\"topAlign\"><ul>\n";
3294 out() << "<li class=\"fn\" translate=\"no\">";
3295 }
3296
3297 generateSynopsis(member, relative, marker, Section::Summary, alignNames);
3298 if (alignNames)
3299 out() << "</td></tr>\n";
3300 else
3301 out() << "</li>\n";
3302 i++;
3303 }
3304 if (alignNames)
3305 out() << "</table></div>\n";
3306 else {
3307 out() << "</ul>\n";
3308 if (twoColumn)
3309 out() << "</td></tr>\n</table></div>\n";
3310 }
3311 }
3312}
3313
3314void HtmlGenerator::generateSectionList(const Section &section, const Node *relative,
3315 CodeMarker *marker, bool useObsoleteMembers)
3316{
3317 bool alignNames = true;
3318 const NodeVector &members =
3319 (useObsoleteMembers ? section.obsoleteMembers() : section.members());
3320 if (!members.isEmpty()) {
3321 bool hasPrivateSignals = false;
3322 bool isInvokable = false;
3323 bool twoColumn = false;
3324 if (section.style() == Section::AllMembers) {
3325 alignNames = false;
3326 twoColumn = (members.size() >= 16);
3327 } else if (members.first()->isProperty()) {
3328 twoColumn = (members.size() >= 5);
3329 alignNames = false;
3330 }
3331 if (alignNames) {
3332 out() << "<div class=\"table\"><table class=\"alignedsummary\" translate=\"no\">\n";
3333 } else {
3334 if (twoColumn)
3335 out() << "<div class=\"table\"><table class=\"propsummary\" translate=\"no\">\n"
3336 << "<tr><td class=\"topAlign\">";
3337 out() << "<ul>\n";
3338 }
3339
3340 int i = 0;
3341 for (const auto &member : members) {
3342 // Filter out unnamed nodes. This includes regular shared comment
3343 // nodes but not property groups.
3344 if (member->name().isEmpty())
3345 continue;
3346
3347 if (alignNames) {
3348 out() << "<tr><td class=\"memItemLeft topAlign rightAlign\"> ";
3349 } else {
3350 if (twoColumn && i == (members.size() + 1) / 2)
3351 out() << "</ul></td><td class=\"topAlign\"><ul>\n";
3352 out() << "<li class=\"fn\" translate=\"no\">";
3353 }
3354
3355 generateSynopsis(member, relative, marker, section.style(), alignNames);
3356 if (member->isFunction()) {
3357 const auto *fn = static_cast<const FunctionNode *>(member);
3358 if (fn->isPrivateSignal()) {
3359 hasPrivateSignals = true;
3360 if (alignNames)
3361 out() << "</td><td class=\"memItemRight bottomAlign\">[see note below]";
3362 } else if (fn->isInvokable()) {
3363 isInvokable = true;
3364 if (alignNames)
3365 out() << "</td><td class=\"memItemRight bottomAlign\">[see note below]";
3366 }
3367 }
3368 if (alignNames)
3369 out() << "</td></tr>\n";
3370 else
3371 out() << "</li>\n";
3372 i++;
3373 }
3374 if (alignNames)
3375 out() << "</table></div>\n";
3376 else {
3377 out() << "</ul>\n";
3378 if (twoColumn)
3379 out() << "</td></tr>\n</table></div>\n";
3380 }
3381 if (alignNames) {
3382 if (hasPrivateSignals)
3383 generateAddendum(relative, Generator::PrivateSignal, marker);
3384 if (isInvokable)
3385 generateAddendum(relative, Generator::Invokable, marker);
3386 }
3387 }
3388
3389 if (!useObsoleteMembers && section.style() == Section::Summary
3390 && !section.inheritedMembers().isEmpty()) {
3391 out() << "<ul>\n";
3392 generateSectionInheritedList(section, relative);
3393 out() << "</ul>\n";
3394 }
3395}
3396
3397void HtmlGenerator::generateSectionInheritedList(const Section &section, const Node *relative)
3398{
3399 const QList<std::pair<const Aggregate *, int>> &inheritedMembers = section.inheritedMembers();
3400 for (const auto &member : inheritedMembers) {
3401 out() << "<li class=\"fn\" translate=\"no\">";
3402 out() << member.second << ' ';
3403 if (member.second == 1) {
3404 out() << section.singular();
3405 } else {
3406 out() << section.plural();
3407 }
3408 out() << " inherited from <a href=\"" << fileName(member.first) << '#'
3409 << Generator::cleanRef(section.title().toLower()) << "\">"
3410 << protectEnc(member.first->plainFullName(relative)) << "</a></li>\n";
3411 }
3412}
3413
3414void HtmlGenerator::generateSynopsis(const Node *node, const Node *relative, CodeMarker *marker,
3415 Section::Style style, bool alignNames)
3416{
3417 QString marked = marker->markedUpSynopsis(node, relative, style);
3418 marked.replace("@param>", "i>");
3419
3420 if (style == Section::Summary) {
3421 marked.remove("<@name>");
3422 marked.remove("</@name>");
3423 }
3424
3425 if (style == Section::AllMembers) {
3426 static const QRegularExpression extraRegExp("<@extra>.*</@extra>",
3427 QRegularExpression::InvertedGreedinessOption);
3428 marked.remove(extraRegExp);
3429 } else {
3430 marked.replace("<@extra>", "<code class=\"%1 extra\" translate=\"no\">"_L1
3431 .arg(style == Section::Summary ? "summary"_L1 : "details"_L1));
3432 marked.replace("</@extra>", "</code>");
3433 }
3434
3435 if (style != Section::Details) {
3436 marked.remove("<@type>");
3437 marked.remove("</@type>");
3438 }
3439
3440 out() << highlightedCode(marked, relative, alignNames);
3441}
3442
3443QString HtmlGenerator::highlightedCode(const QString &markedCode, const Node *relative,
3444 bool alignNames, Genus genus)
3445{
3446 QString src = markedCode;
3447 QString html;
3448 html.reserve(src.size());
3449 QStringView arg;
3450 QStringView par1;
3451
3452 const QChar charLangle = '<';
3453 const QChar charAt = '@';
3454
3455 static const QString typeTag("type");
3456 static const QString headerTag("headerfile");
3457 static const QString funcTag("func");
3458 static const QString linkTag("link");
3459 static const QString extrefTag("extref");
3460 static const QString conceptTag("concept");
3461
3462 // URL mapping for external references to cppreference.com
3463 static const QHash<QString, QString> extrefUrls = {
3464 {"cpp-explicitly-defaulted"_L1,
3465 "https://en.cppreference.com/w/cpp/language/function#Defaulted_functions"_L1},
3466 {"cpp-deleted-functions"_L1,
3467 "https://en.cppreference.com/w/cpp/language/function#Deleted_functions"_L1},
3468 };
3469
3470 // replace all <@link> tags: "(<@link node=\"([^\"]+)\">).*(</@link>)"
3471 // replace all <@func> tags: "(<@func target=\"([^\"]*)\">)(.*)(</@func>)"
3472 // replace all "(<@(type|headerfile)(?: +[^>]*)?>)(.*)(</@\\2>)" tags
3473 bool done = false;
3474 for (int i = 0, srcSize = src.size(); i < srcSize;) {
3475 if (src.at(i) == charLangle && src.at(i + 1) == charAt) {
3476 if (alignNames && !done) {
3477 html += QLatin1String("</td><td class=\"memItemRight bottomAlign\">");
3478 done = true;
3479 }
3480 i += 2;
3481 if (parseArg(src, linkTag, &i, srcSize, &arg, &par1)) {
3482 html += QLatin1String("<b>");
3483 const Node *n = static_cast<const Node*>(Utilities::nodeForString(par1.toString()));
3484 QString link = linkForNode(n, relative);
3485 addLink(link, arg, &html);
3486 html += QLatin1String("</b>");
3487 } else if (parseArg(src, funcTag, &i, srcSize, &arg, &par1)) {
3488 const FunctionNode *fn = m_qdb->findFunctionNode(par1.toString(), relative, genus);
3489 QString link = linkForNode(fn, relative);
3490 addLink(link, arg, &html);
3491 par1 = QStringView();
3492 } else if (parseArg(src, typeTag, &i, srcSize, &arg, &par1)) {
3493 par1 = QStringView();
3494 const Node *n = m_qdb->findTypeNode(arg.toString(), relative, genus);
3495 html += QLatin1String("<span class=\"type\">");
3496 if (n && (n->isQmlBasicType())) {
3497 if (relative && (relative->genus() == n->genus() || genus == n->genus()))
3498 addLink(linkForNode(n, relative), arg, &html);
3499 else
3500 html += arg;
3501 } else
3502 addLink(linkForNode(n, relative), arg, &html);
3503 html += QLatin1String("</span>");
3504 } else if (parseArg(src, conceptTag, &i, srcSize, &arg, &par1)) {
3505 // The target attribute carries the fully-qualified concept
3506 // name to look up; the body carries the unqualified text the
3507 // reader sees. Resolve by target, render by body.
3508 const QString target = par1.isEmpty() ? arg.toString() : par1.toString();
3509 par1 = QStringView();
3510 const Node *n = m_qdb->findConceptNode(target);
3511 if (n)
3512 addLink(linkForNode(n, relative), arg, &html);
3513 else
3514 html += arg;
3515 } else if (parseArg(src, headerTag, &i, srcSize, &arg, &par1)) {
3516 par1 = QStringView();
3517 if (arg.startsWith(QLatin1Char('&')))
3518 html += arg;
3519 else {
3520 const Node *n = m_qdb->findNodeForInclude(QStringList(arg.toString()));
3521 if (n && n != relative)
3522 addLink(linkForNode(n, relative), arg, &html);
3523 else
3524 html += arg;
3525 }
3526 } else if (parseArg(src, extrefTag, &i, srcSize, &arg, &par1)) {
3527 QString url = extrefUrls.value(par1.toString());
3528 if (!url.isEmpty())
3529 addLink(url, arg, &html);
3530 else
3531 html += arg;
3532 } else {
3533 html += charLangle;
3534 html += charAt;
3535 }
3536 } else {
3537 html += src.at(i++);
3538 }
3539 }
3540
3541 // Replace code marker tags with HTML spans:
3542 // "<@tag>" -> "<span ...>"
3543 // "</@tag>" -> "</span>"
3544 src = html;
3545 html = QString();
3546 html.reserve(src.size());
3547
3548 struct SpanTag {
3549 QLatin1StringView tag;
3550 QLatin1StringView span;
3551 };
3552 static constexpr SpanTag spanTags[] = {
3553 {"comment>"_L1, "<span class=\"comment\">"_L1},
3554 {"preprocessor>"_L1, "<span class=\"preprocessor\">"_L1},
3555 {"string>"_L1, "<span class=\"string\">"_L1},
3556 {"char>"_L1, "<span class=\"char\">"_L1},
3557 {"number>"_L1, "<span class=\"number\">"_L1},
3558 {"op>"_L1, "<span class=\"operator\">"_L1},
3559 {"type>"_L1, "<span class=\"type\">"_L1},
3560 {"name>"_L1, "<span class=\"name\">"_L1},
3561 {"keyword>"_L1, "<span class=\"keyword\">"_L1},
3562 {"template-block>"_L1, "<span class=\"template-block\">"_L1},
3563 };
3564
3565 qsizetype i = 0;
3566 const qsizetype n = src.size();
3567 const QStringView sv(src);
3568 while (i < n) {
3569 if (sv.at(i) == '<'_L1) {
3570 if (i + 1 < n && sv.at(i + 1) == '@'_L1) {
3571 i += 2;
3572 bool handled = false;
3573 for (const auto &st : spanTags) {
3574 if (i + st.tag.size() <= n
3575 && st.tag == sv.sliced(i, st.tag.size())) {
3576 html += st.span;
3577 i += st.tag.size();
3578 handled = true;
3579 break;
3580 }
3581 }
3582 if (!handled) {
3583 // drop 'our' unknown tags (the ones still containing '@')
3584 while (i < n && sv.at(i) != '>'_L1)
3585 ++i;
3586 if (i < n)
3587 ++i;
3588 }
3589 continue;
3590 } else if (i + 2 < n && sv.at(i + 1) == '/'_L1 && sv.at(i + 2) == '@'_L1) {
3591 i += 3;
3592 bool handled = false;
3593 for (const auto &st : spanTags) {
3594 if (i + st.tag.size() <= n
3595 && st.tag == sv.sliced(i, st.tag.size())) {
3596 html += "</span>"_L1;
3597 i += st.tag.size();
3598 handled = true;
3599 break;
3600 }
3601 }
3602 if (!handled) {
3603 // drop 'our' unknown tags (the ones still containing '@')
3604 while (i < n && sv.at(i) != '>'_L1)
3605 ++i;
3606 if (i < n)
3607 ++i;
3608 }
3609 continue;
3610 }
3611 }
3612 html += src.at(i);
3613 ++i;
3614 }
3615 return html;
3616}
3617
3618void HtmlGenerator::generateLink(const Atom *atom)
3619{
3620 Q_ASSERT(m_inLink);
3621
3622 if (m_linkNode && m_linkNode->isFunction()) {
3623 auto match = XmlGenerator::m_funcLeftParen.match(atom->string());
3624 if (match.hasMatch()) {
3625 // C++: move () outside of link
3626 qsizetype leftParenLoc = match.capturedStart(1);
3627 out() << protectEnc(atom->string().left(leftParenLoc));
3628 endLink();
3629 out() << protectEnc(atom->string().mid(leftParenLoc));
3630 return;
3631 }
3632 }
3633 out() << protectEnc(atom->string());
3634}
3635
3636QString HtmlGenerator::protectEnc(const QString &string)
3637{
3638 return protect(string);
3639}
3640
3641QString HtmlGenerator::protect(const QString &string)
3642{
3643 if (string.isEmpty())
3644 return string;
3645
3646#define APPEND(x)
3647 if (html.isEmpty()) {
3648 html = string;
3649 html.truncate(i);
3650 }
3651 html += (x);
3652
3653 QString html;
3654 qsizetype n = string.size();
3655
3656 for (int i = 0; i < n; ++i) {
3657 QChar ch = string.at(i);
3658
3659 if (ch == QLatin1Char('&')) {
3660 APPEND("&amp;");
3661 } else if (ch == QLatin1Char('<')) {
3662 APPEND("&lt;");
3663 } else if (ch == QLatin1Char('>')) {
3664 APPEND("&gt;");
3665 } else if (ch == QChar(8211)) {
3666 APPEND("&ndash;");
3667 } else if (ch == QChar(8212)) {
3668 APPEND("&mdash;");
3669 } else if (ch == QLatin1Char('"')) {
3670 APPEND("&quot;");
3671 } else {
3672 if (!html.isEmpty())
3673 html += ch;
3674 }
3675 }
3676
3677 if (!html.isEmpty())
3678 return html;
3679 return string;
3680
3681#undef APPEND
3682}
3683
3684QString HtmlGenerator::fileBase(const Node *node) const
3685{
3686 QString result = Generator::fileBase(node);
3687 if (!node->isAggregate() && node->isDeprecated())
3688 result += QLatin1String("-obsolete");
3689 return result;
3690}
3691
3692QString HtmlGenerator::fileName(const Node *node)
3693{
3694 if (node->isExternalPage())
3695 return node->name();
3696 return Generator::fileName(node);
3697}
3698
3699void HtmlGenerator::generateFullName(const Node *apparentNode, const Node *relative,
3700 const Node *actualNode)
3701{
3702 if (actualNode == nullptr)
3703 actualNode = apparentNode;
3704 bool link = !linkForNode(actualNode, relative).isEmpty();
3705 if (link) {
3706 out() << "<a href=\"" << linkForNode(actualNode, relative);
3707 if (actualNode->isDeprecated())
3708 out() << "\" class=\"obsolete";
3709 out() << "\">";
3710 }
3711 out() << protectEnc(apparentNode->fullName(relative));
3712 if (link)
3713 out() << "</a>";
3714}
3715
3716/*!
3717 Generates a link to the declaration of the C++ API entity
3718 represented by \a node.
3719*/
3720void HtmlGenerator::generateSourceLink(const Node *node)
3721{
3722 Q_ASSERT(node);
3723 if (node->genus() != Genus::CPP)
3724 return;
3725
3726 const auto srcLink = Config::instance().getSourceLink();
3727 if (!srcLink.enabled)
3728 return;
3729
3730 // With no valid configuration or location, do nothing
3731 const auto &loc{node->declLocation()};
3732 if (loc.isEmpty() || srcLink.baseUrl.isEmpty() || srcLink.rootPath.isEmpty())
3733 return;
3734
3735 QString srcUrl{srcLink.baseUrl};
3736 if (!srcUrl.contains('\1'_L1)) {
3737 if (!srcUrl.endsWith('/'_L1))
3738 srcUrl += '/'_L1;
3739 srcUrl += '\1'_L1;
3740 }
3741
3742 QDir rootDir{srcLink.rootPath};
3743 srcUrl.replace('\1'_L1, rootDir.relativeFilePath(loc.filePath()));
3744 srcUrl.replace('\2'_L1, QString::number(loc.lineNo()));
3745 const auto &description{"View declaration of this %1"_L1.arg(node->nodeTypeString())};
3746 out() << "<a class=\"srclink\" href=\"%1\" title=\"%2\">%3</a>"_L1
3747 .arg(srcUrl, description, srcLink.linkText);
3748}
3749
3750QString HtmlGenerator::memberHeadingRef(const Node *node)
3751{
3752 // Distinct related members can be rendered on the same page even when
3753 // their canonical links lead to different owning pages.
3754 const QString base = refForNode(node);
3755 QString ref = base;
3756 for (int n = 2; m_emittedMemberRefs.contains(ref); ++n)
3757 ref = base + '-'_L1 + QString::number(n);
3758 m_emittedMemberRefs.insert(ref);
3759 return ref;
3760}
3761
3762void HtmlGenerator::generateDetailedMember(const Node *node, const PageNode *relative,
3763 CodeMarker *marker)
3764{
3765 const EnumNode *etn;
3766 generateExtractionMark(node, MemberMark);
3767 if (node->isSharedCommentNode()) {
3768 const auto *scn = reinterpret_cast<const SharedCommentNode *>(node);
3769 const QList<Node *> &collective = scn->collective();
3770 if (collective.size() > 1)
3771 out() << "<div class=\"fngroup\">\n";
3772 QSet<const Node *> emitted;
3773 for (const auto *sharedNode : collective) {
3774 if (emitted.contains(sharedNode))
3775 continue;
3776 emitted.insert(sharedNode);
3777 out() << headingStart.arg(getClassAttr(sharedNode, "fn fngroupitem"_L1),
3778 memberHeadingRef(sharedNode));
3779 generateSynopsis(sharedNode, relative, marker, Section::Details);
3780 generateSourceLink(sharedNode);
3781 out() << headingEnd;
3782 }
3783 if (collective.size() > 1)
3784 out() << "</div>";
3785 out() << '\n';
3786 } else {
3787 if (node->isEnumType(Genus::CPP) && (etn = static_cast<const EnumNode *>(node))->flagsType()) {
3788 out() << headingStart.arg(getClassAttr(node, "flags"_L1), memberHeadingRef(node));
3789 generateSynopsis(etn, relative, marker, Section::Details);
3790 out() << "<br/>";
3791 generateSynopsis(etn->flagsType(), relative, marker, Section::Details);
3792 generateSourceLink(node);
3793 out() << headingEnd;
3794 } else {
3795 out() << headingStart.arg(getClassAttr(node, "fn"_L1), memberHeadingRef(node));
3796 generateSynopsis(node, relative, marker, Section::Details);
3797 generateSourceLink(node);
3798 out() << headingEnd;
3799 }
3800 }
3801
3802 generateStatus(node, marker);
3803 generateBody(node, marker);
3804 if (node->isFunction()) {
3805 const auto *func = static_cast<const FunctionNode *>(node);
3806 if (func->hasOverloads() && (func->isSignal() || func->isSlot()))
3807 generateAddendum(node, OverloadNote, marker, AdmonitionPrefix::Note);
3808 }
3809 generateComparisonCategory(node, marker);
3810 generateThreadSafeness(node, marker);
3811 generateSince(node, marker);
3812 generateNoexceptNote(node, marker);
3813
3814 if (node->isProperty()) {
3815 const auto property = static_cast<const PropertyNode *>(node);
3816 if (property->propertyType() == PropertyNode::PropertyType::StandardProperty ||
3817 property->propertyType() == PropertyNode::PropertyType::BindableProperty) {
3818 Section section("", "", "", "", Section::Accessors);
3819
3820 section.appendMembers(property->getters().toVector());
3821 section.appendMembers(property->setters().toVector());
3822 section.appendMembers(property->resetters().toVector());
3823
3824 if (!section.members().isEmpty()) {
3825 out() << "<p><b>Access functions:</b></p>\n";
3826 generateSectionList(section, node, marker);
3827 }
3828
3829 Section notifiers("", "", "", "", Section::Accessors);
3830 notifiers.appendMembers(property->notifiers().toVector());
3831
3832 if (!notifiers.members().isEmpty()) {
3833 out() << "<p><b>Notifier signal:</b></p>\n";
3834 generateSectionList(notifiers, node, marker);
3835 }
3836 }
3837 } else if (node->isEnumType(Genus::CPP)) {
3838 const auto *enumTypeNode = static_cast<const EnumNode *>(node);
3839 if (enumTypeNode->flagsType()) {
3840 out() << "<p>The " << protectEnc(enumTypeNode->flagsType()->name())
3841 << " type is a typedef for "
3842 << "<a href=\"" << m_qflagsHref << "\">QFlags</a>&lt;"
3843 << protectEnc(enumTypeNode->name()) << "&gt;. It stores an OR combination of "
3844 << protectEnc(enumTypeNode->name()) << " values.</p>\n";
3845 }
3846 }
3847 generateAlsoList(node, marker);
3848 generateExtractionMark(node, EndMark);
3849}
3850
3851/*!
3852 This version of the function is called when outputting the link
3853 to an example file or example image, where the \a link is known
3854 to be correct.
3855 */
3856void HtmlGenerator::beginLink(const QString &link)
3857{
3858 m_link = link;
3859 m_inLink = true;
3860 m_linkNode = nullptr;
3861
3862 if (!m_link.isEmpty())
3863 out() << "<a href=\"" << m_link << "\" translate=\"no\">";
3864}
3865
3866void HtmlGenerator::beginLink(const QString &link, const Node *node, const Node *relative)
3867{
3868 m_link = link;
3869 m_inLink = true;
3870 m_linkNode = node;
3871 if (m_link.isEmpty())
3872 return;
3873
3874 const QString &translate_attr =
3875 (node && isApiGenus(node->genus())) ? " translate=\"no\""_L1 : ""_L1;
3876
3877 if (node == nullptr || (relative != nullptr && node->status() == relative->status()))
3878 out() << "<a href=\"" << m_link << "\"%1>"_L1.arg(translate_attr);
3879 else if (node->isDeprecated())
3880 out() << "<a href=\"" << m_link << "\" class=\"obsolete\"%1>"_L1.arg(translate_attr);
3881 else
3882 out() << "<a href=\"" << m_link << "\"%1>"_L1.arg(translate_attr);
3883}
3884
3885void HtmlGenerator::endLink()
3886{
3887 if (!m_inLink)
3888 return;
3889
3890 m_inLink = false;
3891 m_linkNode = nullptr;
3892
3893 if (!m_link.isEmpty())
3894 out() << "</a>";
3895}
3896
3897/*!
3898 Generates the summary list for the \a members. Only used for
3899 sections of QML element documentation.
3900 */
3901void HtmlGenerator::generateQmlSummary(const NodeVector &members, const Node *relative,
3902 CodeMarker *marker)
3903{
3904 if (!members.isEmpty()) {
3905 out() << "<ul>\n";
3906 for (const auto &member : members) {
3907 out() << "<li class=\"fn\" translate=\"no\">";
3908 generateQmlItem(member, relative, marker, true);
3909 if (member->isPropertyGroup()) {
3910 const auto *scn = static_cast<const SharedCommentNode *>(member);
3911 if (scn->count() > 0) {
3912 out() << "<ul>\n";
3913 const QList<Node *> &sharedNodes = scn->collective();
3914 for (const auto &node : sharedNodes) {
3915 if (node->isQmlProperty()) {
3916 out() << "<li class=\"fn\" translate=\"no\">";
3917 generateQmlItem(node, relative, marker, true);
3918 out() << "</li>\n";
3919 }
3920 }
3921 out() << "</ul>\n";
3922 }
3923 }
3924 out() << "</li>\n";
3925 }
3926 out() << "</ul>\n";
3927 }
3928}
3929
3930/*!
3931 \brief Emits the <h3> header for a property group.
3932*/
3933void HtmlGenerator::emitGroupHeader(const SharedCommentNode *scn)
3934{
3935 out() << headingStart.arg(getClassAttr(scn, "fn qml-member qml-property-group"_L1),
3936 refForNode(scn))
3937 << "<b>" << scn->name() << " group</b>"
3938 << headingEnd;
3939}
3940
3941/*!
3942 Outputs the html detailed documentation for a section
3943 on a QML element reference page.
3944 */
3945void HtmlGenerator::generateDetailedQmlMember(Node *node, const Aggregate *relative,
3946 CodeMarker *marker)
3947{
3948 generateExtractionMark(node, MemberMark);
3949
3950 auto generateQmlProperty = [&](Node *n, bool isGroupItem = false) {
3951 const auto cssClasses = isGroupItem ? "fn qml-member qml-property fngroupitem"_L1 : "fn qml-member qml-property"_L1;
3952 out() << headingStart.arg(getClassAttr(n, cssClasses), refForNode(n));
3953 generateQmlItem(n, relative, marker, false);
3954 generateSourceLink(n);
3955 out() << headingEnd;
3956 };
3957
3958 auto generateQmlMethod = [&](Node *n, bool isGroupItem = false) {
3959 const auto cssClasses = isGroupItem ? "fn qml-member qml-method fngroupitem"_L1 : "fn qml-member qml-method"_L1;
3960 out() << headingStart.arg(getClassAttr(n, cssClasses), refForNode(n));
3961 generateSynopsis(n, relative, marker, Section::Details, false);
3962 generateSourceLink(n);
3963 out() << headingEnd;
3964 };
3965
3966 if (node->isSharedCommentNode()) {
3967 auto *scn = static_cast<const SharedCommentNode *>(node);
3968 const auto shared = scn->collective();
3969
3970 if (scn->isPropertyGroup() && !scn->name().isEmpty())
3971 emitGroupHeader(scn);
3972
3973 const bool isGroup = shared.size() > 1;
3974
3975 if (isGroup)
3976 out() << "<div class=\"fngroup\">\n"_L1;
3977
3978 for (auto *child : std::as_const(shared)) {
3979 if (child->isQmlProperty())
3980 generateQmlProperty(child, isGroup);
3981 else
3982 generateQmlMethod(child, isGroup);
3983 }
3984
3985 if (isGroup)
3986 out() << "</div>"_L1;
3987 out() << '\n';
3988 } else if (node->isQmlProperty()) {
3989 generateQmlProperty(node);
3990 } else { // assume the node is a method/signal handler
3991 generateQmlMethod(node);
3992 }
3993
3994 generateStatus(node, marker);
3995 generateBody(node, marker);
3996 generateThreadSafeness(node, marker);
3997 generateSince(node, marker);
3998 generateAlsoList(node, marker);
3999 generateExtractionMark(node, EndMark);
4000}
4001
4002void HtmlGenerator::generateExtractionMark(const Node *node, ExtractionMarkType markType)
4003{
4004 if (markType != EndMark) {
4005 out() << "<!-- $$$" + node->name();
4006 if (markType == MemberMark) {
4007 if (node->isFunction()) {
4008 const auto *func = static_cast<const FunctionNode *>(node);
4009 if (!func->hasAssociatedProperties()) {
4010 if (func->overloadNumber() == 0)
4011 out() << "[overload1]";
4012 out() << "$$$" + func->name() + func->parameters().rawSignature().remove(' ');
4013 }
4014 } else if (node->isProperty()) {
4015 out() << "-prop";
4016 const auto *prop = static_cast<const PropertyNode *>(node);
4017 const NodeList &list = prop->functions();
4018 for (const auto *propFuncNode : list) {
4019 if (propFuncNode->isFunction()) {
4020 const auto *func = static_cast<const FunctionNode *>(propFuncNode);
4021 out() << "$$$" + func->name()
4022 + func->parameters().rawSignature().remove(' ');
4023 }
4024 }
4025 } else if (node->isEnumType()) {
4026 const auto *enumNode = static_cast<const EnumNode *>(node);
4027 const auto &items = enumNode->items();
4028 for (const auto &item : items)
4029 out() << "$$$" + item.name();
4030 }
4031 } else if (markType == BriefMark) {
4032 out() << "-brief";
4033 } else if (markType == DetailedDescriptionMark) {
4034 out() << "-description";
4035 }
4036 out() << " -->\n";
4037 } else {
4038 out() << "<!-- @@@" + node->name() + " -->\n";
4039 }
4040}
4041
4042QT_END_NAMESPACE
#define ATOM_LIST_BULLET
Definition atom.h:211
#define ATOM_FORMATTING_TELETYPE
Definition atom.h:206
#define ATOM_LIST_LOWERALPHA
Definition atom.h:214
#define ATOM_FORMATTING_UNDERLINE
Definition atom.h:209
#define ATOM_LIST_UPPERALPHA
Definition atom.h:217
#define ATOM_FORMATTING_NOTRANSLATE
Definition atom.h:201
#define ATOM_LIST_TAG
Definition atom.h:212
#define ATOM_LIST_LOWERROMAN
Definition atom.h:215
#define ATOM_FORMATTING_SPAN
Definition atom.h:203
#define ATOM_FORMATTING_SUBSCRIPT
Definition atom.h:204
#define ATOM_FORMATTING_BOLD
Definition atom.h:197
#define ATOM_FORMATTING_TRADEMARK
Definition atom.h:207
#define ATOM_LIST_VALUE
Definition atom.h:213
#define ATOM_FORMATTING_ITALIC
Definition atom.h:199
#define ATOM_LIST_UPPERROMAN
Definition atom.h:218
#define ATOM_FORMATTING_LINK
Definition atom.h:200
#define ATOM_FORMATTING_SUPERSCRIPT
Definition atom.h:205
#define ATOM_FORMATTING_INDEX
Definition atom.h:198
#define ATOM_FORMATTING_UICONTROL
Definition atom.h:208
#define ATOM_FORMATTING_PARAMETER
Definition atom.h:202
The Atom class is the fundamental unit for representing documents internally.
Definition atom.h:19
AtomType type() const
Return the type of this atom.
Definition atom.h:146
AtomType
\value AnnotatedList \value AutoLink \value BaseName \value BriefLeft \value BriefRight \value C \val...
Definition atom.h:21
@ CaptionLeft
Definition atom.h:29
@ ListTagLeft
Definition atom.h:69
@ TableRight
Definition atom.h:99
@ DivRight
Definition atom.h:44
@ GeneratedList
Definition atom.h:54
@ BriefRight
Definition atom.h:27
@ CodeQuoteArgument
Definition atom.h:33
@ WarningLeft
Definition atom.h:112
@ SinceList
Definition atom.h:91
@ TableOfContentsLeft
Definition atom.h:106
@ SidebarLeft
Definition atom.h:89
@ TableOfContentsRight
Definition atom.h:107
@ Keyword
Definition atom.h:61
@ TableHeaderRight
Definition atom.h:101
@ FormatElse
Definition atom.h:49
@ InlineImage
Definition atom.h:60
@ TableRowRight
Definition atom.h:103
@ FootnoteRight
Definition atom.h:48
@ LineBreak
Definition atom.h:64
@ SnippetCommand
Definition atom.h:94
@ TableRowLeft
Definition atom.h:102
@ Nop
Definition atom.h:76
@ WarningRight
Definition atom.h:113
@ LegaleseRight
Definition atom.h:63
@ ListTagRight
Definition atom.h:70
@ CaptionRight
Definition atom.h:30
@ NavLink
Definition atom.h:75
@ ListItemNumber
Definition atom.h:68
@ SinceTagRight
Definition atom.h:93
@ DetailsLeft
Definition atom.h:39
@ CodeBad
Definition atom.h:32
@ RawString
Definition atom.h:84
@ Target
Definition atom.h:108
@ AnnotatedList
Definition atom.h:22
@ SectionRight
Definition atom.h:86
@ SectionHeadingLeft
Definition atom.h:87
@ TableLeft
Definition atom.h:98
@ ListItemRight
Definition atom.h:72
@ DeprecatedLeft
Definition atom.h:37
@ Image
Definition atom.h:56
@ TableItemRight
Definition atom.h:105
@ ListItemLeft
Definition atom.h:71
@ ImportantRight
Definition atom.h:59
@ Code
Definition atom.h:31
@ String
Definition atom.h:97
@ ListLeft
Definition atom.h:67
@ NavAutoLink
Definition atom.h:74
@ CodeQuoteCommand
Definition atom.h:34
@ BriefLeft
Definition atom.h:26
@ ImageText
Definition atom.h:57
@ ExampleFileLink
Definition atom.h:45
@ LegaleseLeft
Definition atom.h:62
@ ListRight
Definition atom.h:73
@ C
Definition atom.h:28
@ ParaRight
Definition atom.h:80
@ Qml
Definition atom.h:81
@ FormattingLeft
Definition atom.h:52
@ FormattingRight
Definition atom.h:53
@ SectionHeadingRight
Definition atom.h:88
@ Link
Definition atom.h:65
@ ImportantLeft
Definition atom.h:58
@ FormatEndif
Definition atom.h:50
@ UnhandledFormat
Definition atom.h:111
@ ExampleImageLink
Definition atom.h:46
@ BR
Definition atom.h:25
@ DetailsRight
Definition atom.h:40
@ FootnoteLeft
Definition atom.h:47
@ AutoLink
Definition atom.h:23
@ SnippetLocation
Definition atom.h:96
@ TableHeaderLeft
Definition atom.h:100
@ ComparesRight
Definition atom.h:36
@ DeprecatedRight
Definition atom.h:38
@ QuotationLeft
Definition atom.h:82
@ SectionLeft
Definition atom.h:85
@ LinkNode
Definition atom.h:66
@ HR
Definition atom.h:55
@ DivLeft
Definition atom.h:43
@ TableItemLeft
Definition atom.h:104
@ NoteRight
Definition atom.h:78
@ QuotationRight
Definition atom.h:83
@ ParaLeft
Definition atom.h:79
@ BaseName
Definition atom.h:24
@ ComparesLeft
Definition atom.h:35
@ FormatIf
Definition atom.h:51
@ SnippetIdentifier
Definition atom.h:95
@ NoteLeft
Definition atom.h:77
@ SidebarRight
Definition atom.h:90
@ DetailsSummaryRight
Definition atom.h:42
@ DetailsSummaryLeft
Definition atom.h:41
const Atom * next() const
Return the next atom in the atom list.
Definition atom.h:143
const Atom * next(AtomType t) const
Return the next Atom in the list if it is of AtomType t.
Definition atom.cpp:302
The ClassNode represents a C++ class.
Definition classnode.h:23
bool isQmlNativeType()
Definition classnode.h:54
virtual Atom::AtomType atomType() const
Definition codemarker.h:24
A class for holding the members of a collection of doc pages.
const NodeList & members() const
bool wasSeen() const override
Returns the seen flag data member of this node if it is a NamespaceNode or a CollectionNode.
NodeMap getMembers(NodeType type) const
bool preparing() const
Definition config.h:201
Definition doc.h:32
const Location & location() const
Returns the starting location of a qdoc comment.
Definition doc.cpp:89
bool hasTableOfContents() const
Definition doc.cpp:292
static void quoteFromFile(const Location &location, Quoter &quoter, ResolvedFile resolved_file, CodeMarker *marker=nullptr)
Definition doc.cpp:468
Text briefText(bool inclusive=false) const
Definition doc.cpp:126
QStringMultiMap * metaTagMap() const
Definition doc.cpp:347
const TypedefNode * flagsType() const
Definition enumnode.h:40
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.
bool generateComparisonCategory(const Node *node, CodeMarker *marker=nullptr)
static void setQmlTypeContext(QmlTypeNode *t)
Definition generator.h:92
void generateStatus(const Node *node, CodeMarker *marker)
void generateThreadSafeness(const Node *node, CodeMarker *marker)
Generates text that explains how threadsafe and/or reentrant node is.
static bool useOutputSubdirs()
Definition generator.h:91
static bool noLinkErrors()
Definition generator.h:87
void generateNoexceptNote(const Node *node, CodeMarker *marker)
void unknownAtom(const Atom *atom)
virtual void terminateGenerator()
static bool matchAhead(const Atom *atom, Atom::AtomType expectedAtomType)
virtual void generateDocs()
Traverses the database recursively to generate all the documentation.
static bool appendTrademark(const Atom *atom)
Returns true if a trademark symbol should be appended to the output as determined by atom.
QTextStream & out()
static bool s_redirectDocumentationToDevNull
Definition generator.h:225
virtual void generateBody(const Node *node, CodeMarker *marker)
Generate the body of the documentation from the qdoc comment found with the entity represented by the...
void generateSince(const Node *node, CodeMarker *marker)
void endSubPage()
Flush the text stream associated with the subpage, and then pop it off the text stream stack and dele...
@ PrivateSignal
Definition generator.h:45
@ OverloadNote
Definition generator.h:49
static bool autolinkErrors()
Definition generator.h:88
bool generateComparisonTable(const Node *node)
Generates a table of comparison categories for node, combining both self-comparison (from \compares) ...
virtual void initializeGenerator()
No-op base implementation.
QString fileExtension() const override
Returns "html" for this subclass of Generator.
void generateProxyPage(Aggregate *aggregate, CodeMarker *marker) override
void generatePageNode(PageNode *pn, CodeMarker *marker) override
Generate the HTML page for an entity that doesn't map to any underlying parsable C++ or QML element.
void generateCppReferencePage(Aggregate *aggregate, CodeMarker *marker) override
Generate a reference page for the C++ class, namespace, or header file documented in node using the c...
void generateDocs() override
If qdoc is in the {-prepare} phase, traverse the primary tree to generate the index file for the curr...
void generateCollectionNode(CollectionNode *cn, CodeMarker *marker) override
Generate the HTML page for a group, module, or QML module.
~HtmlGenerator() override
Destroys the HTML output generator.
HtmlGenerator(FileResolver &file_resolver)
void generateExampleFilePage(const PageNode *en, ResolvedFile resolved_file, CodeMarker *marker) override
Generate an html file with the contents of a C++ or QML source file.
QString fileBase(const Node *node) const override
void generateGenericCollectionPage(CollectionNode *cn, CodeMarker *marker) override
Generate the HTML page for a generic collection.
void generateQmlTypePage(QmlTypeNode *qcn, CodeMarker *marker) override
Generate the HTML page for a QML type.
void initializeGenerator() override
Initializes the HTML output generator's data structures from the configuration (Config) singleton.
QString format() const override
Returns the format identifier for this producer (e.g., "HTML", "DocBook", "template").
void terminateGenerator() override
Gracefully terminates the HTML output generator.
virtual bool generatesHelpProject() const
Returns true if this generator writes a Qt help project (.qhp) file.
qsizetype generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker) override
Generate html from an instance of Atom.
static bool isIncluded(const InclusionPolicy &policy, const NodeContext &context)
The Location class provides a way to mark a location in a file.
Definition location.h:20
bool isEmpty() const
Returns true if there is no file name set yet; returns false otherwise.
Definition location.h:45
The ManifestWriter is responsible for writing manifest files.
void generateManifestFiles()
This function outputs one or more manifest files in XML.
This class represents a C++ namespace.
NamespaceNode * docNode() const
Returns a pointer to the NamespaceNode that represents where the namespace documentation is actually ...
Tree * tree() const override
Returns a pointer to the Tree that contains this NamespaceNode.
bool isDocumentedHere() const
Returns true if this namespace is to be documented in the current module.
A PageNode is a Node that generates a documentation page.
Definition pagenode.h:19
bool noAutoList() const
Returns the value of the no auto-list flag.
Definition pagenode.h:42
This class describes one instance of using the Q_PROPERTY macro.
This class provides exclusive access to the qdoc database, which consists of a forrest of trees and a...
static QDocDatabase * qdocDB()
Creates the singleton.
Status
Specifies the status of the QQmlIncubator.
ClassNode * classNode() const override
If this is a QmlTypeNode, this function returns the pointer to the C++ ClassNode that this QML type r...
Definition qmltypenode.h:27
bool isUncreatable() const
Definition qmltypenode.h:35
static void subclasses(const Node *base, NodeList &subs, bool recurse=false)
Loads the list subs with the nodes of all the subclasses of base.
QString logicalModuleVersion() const override
If the QML type's QML module pointer is set, return the QML module version from the QML module node.
bool isSingleton() const
Definition qmltypenode.h:31
QString logicalModuleName() const override
If the QML type's QML module pointer is set, return the QML module name from the QML module node.
QmlTypeNode * qmlBaseNode() const override
If this Aggregate is a QmlTypeNode, this function returns a pointer to the QmlTypeNode that is its ba...
Definition qmltypenode.h:54
CollectionNode * logicalModule() const override
If this is a QmlTypeNode, a pointer to its QML module is returned, which is a pointer to a Collection...
Definition qmltypenode.h:47
A class for containing the elements of one documentation section.
Definition sections.h:17
const NodeVector & obsoleteMembers() const
Definition sections.h:54
void appendMembers(const NodeVector &nv)
Definition sections.h:55
const Aggregate * aggregate() const
Definition sections.h:56
const ClassNodesList & classNodesList() const
Definition sections.h:53
@ Summary
Definition sections.h:19
@ Details
Definition sections.h:19
@ Accessors
Definition sections.h:19
@ AllMembers
Definition sections.h:19
const NodeVector & members() const
Definition sections.h:46
Style style() const
Definition sections.h:41
bool isEmpty() const
Definition sections.h:35
A class for creating vectors of collections for documentation.
Definition sections.h:80
const Aggregate * aggregate() const
Definition sections.h:161
SectionVector & summarySections()
Definition sections.h:151
SectionVector & sinceSections()
Definition sections.h:154
Sections(const Aggregate *aggregate)
This constructor builds the section vectors based on the type of the aggregate node.
Definition sections.cpp:372
Sections(const NodeMultiMap &nsmap)
This constructor builds the since sections from the since node map, nsmap.
Definition sections.cpp:410
bool hasObsoleteMembers(SectionPtrVector *summary_spv, SectionPtrVector *details_spv) const
Returns true if any sections in this object contain obsolete members.
Definition sections.cpp:967
SectionVector & detailsSections()
Definition sections.h:152
const Section & allMembersSection() const
Definition sections.h:158
bool isPropertyGroup() const override
Returns true if the node is a SharedCommentNode for documenting multiple C++ properties or multiple Q...
Table of contents writer.
Definition tocwriter.h:22
void generateTOC(const QString &fileName, const QString &indexTitle)
Writes the TOC entries for project to fileName, starting from a page with a title matching indexTitle...
Definition tocwriter.cpp:46
This class handles the generation of the QDoc tag files.
void generateTagFile(const QString &fileName, Generator *generator)
Writes a tag file named fileName.
Definition text.h:12
bool isEmpty() const
Definition text.h:30
void clear()
Definition text.cpp:250
Text()
Definition text.cpp:12
Atom * lastAtom()
Definition text.h:22
const QString & camelCaseModuleName() const
Definition tree.h:75
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)
static const QRegularExpression m_funcLeftParen
static NodeType typeFromString(const Atom *atom)
Returns the type of this atom as an enumeration.
#define COMMAND_VERSION
Definition codeparser.h:85
#define COMMAND_INQMLMODULE
Definition codeparser.h:34
#define CONFIG_USEALTTEXTASTITLE
Definition config.h:469
#define CONFIG_CPPCLASSESTITLE
Definition config.h:391
#define CONFIG_HOMETITLE
Definition config.h:411
#define CONFIG_HOMEPAGE
Definition config.h:410
#define CONFIG_URL
Definition config.h:468
#define CONFIG_CODEPREFIX
Definition config.h:388
#define CONFIG_QMLTYPESPAGE
Definition config.h:474
#define CONFIG_ENDHEADER
Definition config.h:397
#define CONFIG_HEADERSCRIPTS
Definition config.h:408
#define CONFIG_DESCRIPTION
Definition config.h:394
#define CONFIG_PROJECT
Definition config.h:444
#define CONFIG_CODEINDENT
Definition config.h:386
#define CONFIG_TRADEMARKSPAGE
Definition config.h:467
#define CONFIG_CPPCLASSESPAGE
Definition config.h:390
#define CONFIG_NATURALLANGUAGE
Definition config.h:433
#define CONFIG_PRODUCTNAME
Definition config.h:443
#define CONFIG_NAVIGATION
Definition config.h:434
#define CONFIG_BUILDVERSION
Definition config.h:385
#define CONFIG_LANDINGPAGE
Definition config.h:423
#define CONFIG_TAGFILE
Definition config.h:463
#define CONFIG_CODESUFFIX
Definition config.h:389
#define CONFIG_LANDINGTITLE
Definition config.h:424
#define CONFIG_HEADERSTYLES
Definition config.h:409
#define CONFIG_QMLTYPESTITLE
Definition config.h:475
NodeType
Definition genustypes.h:165
static QString getClassAttr(const Node *node, const QString &classSet)
Extends the class HTML attribute generated for node.
static void appendTemplateParametersAtoms(Text &out, const TemplateDeclarationStorage &storage)
static const Atom closeCodeTag
#define APPEND(x)
static void addLink(const QString &linkTarget, QStringView nestedStuff, QString *res)
static const auto headingStart
static void appendTemplateParameterAtoms(Text &out, const RelaxedTemplateParameter &param)
static const auto headingEnd
static const Atom openCodeTag
static void appendTemplateDeclAtoms(Text &out, const RelaxedTemplateDeclaration &templateDecl)
#define HTMLGENERATOR_PROLOGUE
#define HTMLGENERATOR_NONAVIGATIONBAR
#define HTMLGENERATOR_TOCDEPTH
#define HTMLGENERATOR_NAVIGATIONSEPARATOR
#define HTMLGENERATOR_POSTPOSTHEADER
#define HTMLGENERATOR_ADDRESS
#define HTMLGENERATOR_FOOTER
#define HTMLGENERATOR_POSTHEADER
Pure string helpers with no dependencies on QDoc driver types.
Definition textutils.h:11
This namespace holds QDoc-internal utility methods.
Definition utilities.h:21
QList< Node * > NodeList
Definition node.h:45
QList< Node * > NodeVector
Definition node.h:47
QMap< QString, Node * > NodeMap
Definition node.h:48
QMap< QString, NodeMap > NodeMapMap
Definition node.h:49
QMap< QString, CollectionNode * > CNMap
Definition node.h:52
QT_BEGIN_NAMESPACE typedef QMultiMap< Text, const Node * > TextToNodeMap
QMultiMap< QString, Node * > NodeMultiMap
Definition generator.h:36
QList< const Section * > SectionPtrVector
Definition sections.h:77
QList< Section > SectionVector
Definition sections.h:76
QList< ClassNodes > ClassNodesList
Definition sections.h:14
@ Deprecated
Definition status.h:12
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.
Definition node.h:100
const Doc & doc() const
Returns a reference to the node's Doc data member.
Definition node.h:239
virtual bool hasClasses() const
Returns true if this is a CollectionNode and its members list contains class nodes.
Definition node.h:191
virtual bool hasNamespaces() const
Returns true if this is a CollectionNode and its members list contains namespace nodes.
Definition node.h:190
bool isEnumType(Genus g) const
Definition node.h:98
bool isGroup() const
Returns true if the node type is Group.
Definition node.h:105
SharedCommentNode * sharedCommentNode()
Definition node.h:252
bool isNamespace() const
Returns true if the node type is Namespace.
Definition node.h:110
bool isQmlBasicType() const
Returns true if the node type is QmlBasicType.
Definition node.h:119
bool isQmlType() const
Returns true if the node type is QmlType or QmlValueType.
Definition node.h:123
bool isSharedCommentNode() const
Returns true if the node type is SharedComment.
Definition node.h:126
virtual bool isInternal() const
Returns true if the node's status is Internal, or if its parent is a class with Internal status.
Definition node.cpp:868
bool isHeader() const
Returns true if the node type is HeaderFile.
Definition node.h:106
Genus genus() const override
Returns this node's Genus.
Definition node.h:85
virtual bool isPageNode() const
Returns true if this node represents something that generates a documentation page.
Definition node.h:150
bool isEnumType() const
Returns true if the node type is Enum.
Definition node.h:94
virtual Status status() const
Returns the node's status value.
Definition node.h:243
bool isConcept() const
Definition node.h:109
virtual bool isTextPageNode() const
Returns true if the node is a PageNode but not an Aggregate.
Definition node.h:155
Aggregate * parent() const
Returns the node's parent pointer, that is, the aggregate under which the node is documented.
Definition node.h:211
virtual bool isDeprecated() const
Returns true if this node's status is Deprecated.
Definition node.h:136
virtual bool isAggregate() const
Returns true if this node is an aggregate, which means it inherits Aggregate and can therefore have c...
Definition node.h:138
static bool nodeNameLessThan(const Node *first, const Node *second)
Returns true if the node n1 is less than node n2.
Definition node.cpp:111
const Location & location() const
If this node's definition location is empty, this function returns this node's declaration location.
Definition node.h:235
bool isProxyNode() const
Returns true if the node type is Proxy.
Definition node.h:115
const std::optional< RelaxedTemplateDeclaration > & templateDecl() const
Definition node.h:247
bool isFunction(Genus g=Genus::DontCare) const
Returns true if this is a FunctionNode and its Genus is set to g.
Definition node.h:101
bool isProperty() const
Returns true if the node type is Property.
Definition node.h:114
const Location & declLocation() const
Returns the Location where this node's declaration was seen.
Definition node.h:233
NodeContext createContext() const
Definition node.cpp:175
bool isModule() const
Returns true if the node type is Module.
Definition node.h:108
bool isSharingComment() const
This function returns true if the node is sharing a comment with other nodes.
Definition node.h:250
bool hasDoc() const
Returns true if this node is documented, or it represents a documented node read from the index ('had...
Definition node.cpp:942
@ NextLink
Definition node.h:73
@ StartLink
Definition node.h:73
@ PreviousLink
Definition node.h:73
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
Definition node.h:145
virtual bool isCollectionNode() const
Returns true if this is an instance of CollectionNode.
Definition node.h:146
static bool nodeSortKeyOrNameLessThan(const Node *n1, const Node *n2)
Returns true if node n1 is less than node n2 when comparing the sort keys, defined with.
Definition node.cpp:161
bool isQmlModule() const
Returns true if the node type is QmlModule.
Definition node.h:120
bool isExample() const
Returns true if the node type is Example.
Definition node.h:99
bool isQmlProperty() const
Returns true if the node type is QmlProperty.
Definition node.h:122
ValuedDeclaration valued_declaration
Represents a file that is reachable by QDoc based on its current configuration.