20#include <QtCore/qxmlstream.h>
24using namespace Qt::StringLiterals;
32 m_indexWriteState = {};
56
57
58
59
62 if (m_supplement && currentWriter)
70 QXmlStreamWriter writer(&data);
71 writer.setAutoFormatting(
true);
72 beginSubPage(aggregate, Generator::fileName(aggregate,
"webxml"));
73 writer.writeStartDocument();
74 writer.writeStartElement(
"WebXML");
75 writer.writeStartElement(
"document");
79 writer.writeEndElement();
80 writer.writeEndElement();
81 writer.writeEndDocument();
90 currentWriter.emplace(&data);
91 currentWriter->setAutoFormatting(
true);
92 beginSubPage(pn, Generator::fileName(pn,
"webxml"));
93 currentWriter->writeStartDocument();
94 currentWriter->writeStartElement(
"WebXML");
95 currentWriter->writeStartElement(
"document");
99 currentWriter->writeEndElement();
100 currentWriter->writeEndElement();
101 currentWriter->writeEndDocument();
112 QXmlStreamWriter writer(&data);
113 writer.setAutoFormatting(
true);
114 beginSubPage(en, linkForExampleFile(resolved_file.get_query(),
"webxml"));
115 writer.writeStartDocument();
116 writer.writeStartElement(
"WebXML");
117 writer.writeStartElement(
"document");
118 writer.writeStartElement(
"page");
119 writer.writeAttribute(
"name", resolved_file.get_query());
120 writer.writeAttribute(
"href", linkForExampleFile(resolved_file.get_query()));
121 const QString title = exampleFileTitle(
static_cast<
const ExampleNode *>(en), resolved_file.get_query());
122 writer.writeAttribute(
"title", title);
123 writer.writeAttribute(
"fulltitle", title);
124 writer.writeAttribute(
"subtitle", resolved_file.get_query());
125 writer.writeStartElement(
"description");
128 writer.writeAttribute(
"path", resolved_file.get_path());
129 writer.writeAttribute(
"line",
"0");
130 writer.writeAttribute(
"column",
"0");
135 QString code = quoter.quoteTo(en
->location(), QString(), QString());
136 writer.writeTextElement(
"code", trimmedTrailing(code, QString(), QString()));
138 writer.writeEndElement();
139 writer.writeEndElement();
140 writer.writeEndElement();
141 writer.writeEndElement();
142 writer.writeEndDocument();
151 const Config &config = Config::instance();
153 context.documentLocation = [
this](
const Node *target) {
154 return fullDocumentLocation(target);
160 if (qdocIndexFiles) {
161 qdocIndexFiles->generateIndexSections(writer, node, context, m_indexWriteState,
this);
167 std::ignore = qdocIndexFiles->generateIndexSection(writer, node, context,
168 m_indexWriteState,
this);
182 writer.writeStartElement(
"description");
184 writer.writeAttribute(
"path", effectiveDoc
.location().filePath());
185 writer.writeAttribute(
"line", QString::number(effectiveDoc.location().lineNo()));
186 writer.writeAttribute(
"column", QString::number(effectiveDoc.location().columnNo()));
190 generateRelations(writer, node);
193 writer.writeStartElement(
"generatedlist");
194 writer.writeAttribute(
"contents",
"classesbymodule");
195 auto *cnn =
static_cast<CollectionNode *>(node);
197 if (cnn->hasNamespaces()) {
198 writer.writeStartElement(
"section");
199 writer.writeStartElement(
"heading");
200 writer.writeAttribute(
"level",
"1");
201 writer.writeCharacters(
"Namespaces");
202 writer.writeEndElement();
204 generateAnnotatedList(writer, node, namespaces);
205 writer.writeEndElement();
207 if (cnn->hasClasses()) {
208 writer.writeStartElement(
"section");
209 writer.writeStartElement(
"heading");
210 writer.writeAttribute(
"level",
"1");
211 writer.writeCharacters(
"Classes");
212 writer.writeEndElement();
214 generateAnnotatedList(writer, node, classes);
215 writer.writeEndElement();
217 writer.writeEndElement();
220 m_inLink = m_inSectionHeading = m_hasQuotingInformation =
false;
223 writer.writeStartElement(
"deprecated"_L1);
227 writer.writeEndElement();
234 QList<Text> alsoList = effectiveDoc.alsoList();
235 supplementAlsoList(node, alsoList);
237 if (!alsoList.isEmpty()) {
238 writer.writeStartElement(
"see-also");
239 for (
const auto &item : alsoList) {
240 const auto *atom = item.firstAtom();
242 atom = addAtomElements(writer, atom, node, marker_);
244 writer.writeEndElement();
250 m_supplement =
false;
252 auto *cn =
static_cast<CollectionNode *>(node);
253 if (!cn->noAutoList())
254 generateAnnotatedList(writer, node, cn->members());
257 writer.writeEndElement();
267 const InclusionPolicy policy = Config::instance().createInclusionPolicy();
278 m_qdb->mergeCollections(
static_cast<CollectionNode *>(node));
287 auto *aggregate =
static_cast<Aggregate *>(node);
288 for (
auto c : aggregate->childNodes()) {
289 if ((c->isAggregate() || c->isTextPageNode() || c->isCollectionNode())
291 generateDocumentation(c);
299 bool keepQuoting =
false;
306 const CollectionNode *cn = m_qdb->getCollectionNode(atom->string(), NodeType::Group);
308 generateAnnotatedList(writer, relative, cn
->members());
311 const Node *node{
nullptr};
314 if (!m_inLink && !m_inSectionHeading) {
315 link = getAutoLink(atom, relative, &node, Genus::API);
323 startLink(writer, atom, node, link);
325 writer.writeCharacters(atom->string());
328 writer.writeEndElement();
344 writer.writeStartElement(
"brief");
347 writer.writeCharacters(
"This property");
350 writer.writeCharacters(
"This variable");
363 str[0] = str[0].toLower();
364 if (str.endsWith(
'.'))
367 const QList<QStringView> words = QStringView{str}.split(
' ');
368 if (!words.isEmpty()) {
369 QStringView first(words.at(0));
370 if (!(first == u"contains" || first == u"specifies" || first == u"describes"
371 || first == u"defines" || first == u"holds" || first == u"determines"))
372 writer.writeCharacters(
" holds ");
374 writer.writeCharacters(
" ");
381 writer.writeCharacters(
".");
383 writer.writeEndElement();
387 writer.writeStartElement(
"teletype");
389 writer.writeAttribute(
"type",
"normal");
391 writer.writeAttribute(
"type",
"highlighted");
393 writer.writeCharacters(plainCode(atom->string()));
394 writer.writeEndElement();
398 if (!m_hasQuotingInformation)
399 writer.writeTextElement(
400 "code", trimmedTrailing(plainCode(atom->string()), QString(), QString()));
406 writer.writeTextElement(
"badcode",
407 trimmedTrailing(plainCode(atom->string()), QString(), QString()));
412 if (quoteCommand ==
"dots") {
413 writer.writeAttribute(
"indent", atom->string());
414 writer.writeCharacters(
"...");
416 writer.writeCharacters(atom->string());
418 writer.writeEndElement();
425 quoteCommand = atom->string();
426 writer.writeStartElement(quoteCommand);
438 QString link = linkForExampleFile(atom->string());
440 startLink(writer, atom, relative, link);
446 QString link = atom->string();
448 startLink(writer, atom,
nullptr,
"images/used-in-examples/" + link);
453 writer.writeStartElement(
"footnote");
457 writer.writeEndElement();
461 writer.writeEndElement();
464 writer.writeStartElement(
"raw");
465 writer.writeAttribute(
"format", atom->string());
469 writer.writeStartElement(
"bold");
471 writer.writeStartElement(
"italic");
473 writer.writeStartElement(
"underline");
475 writer.writeStartElement(
"subscript");
477 writer.writeStartElement(
"superscript");
479 writer.writeStartElement(
"teletype");
481 writer.writeStartElement(
"argument");
483 writer.writeStartElement(
"index");
488 writer.writeEndElement();
490 writer.writeEndElement();
492 writer.writeEndElement();
494 writer.writeEndElement();
496 writer.writeEndElement();
498 writer.writeEndElement();
500 writer.writeEndElement();
502 writer.writeEndElement();
504 writer.writeCharacters(QChar(0x2122));
507 writer.writeEndElement();
513 writer.writeStartElement(
"generatedlist");
514 writer.writeAttribute(
"contents", atom->string());
515 writer.writeEndElement();
526 auto maybe_resolved_file{file_resolver.resolve(atom->string())};
527 if (!maybe_resolved_file) {
529 relative
->location().warning(QStringLiteral(
"Missing image: %1").arg(atom->string()));
532 QString file_name{QFileInfo{file.get_path()}.fileName()};
536 "%1/%2"_L1.arg(outputDir(), imagesOutputDir()));
538 writer.writeStartElement(atom->typeString().toLower());
539 const auto &imgPath =
"%1/%2"_L1.arg(imagesOutputDir(), file_name);
541 writer.writeAttribute(
"href", imgPath);
542 writer.writeEndElement();
544 setImageFileName(relative, imgPath);
552 writer.writeStartElement(
"para");
553 writer.writeTextElement(
"bold",
"Important:");
554 writer.writeCharacters(
" ");
558 writer.writeStartElement(
"legalese");
562 writer.writeEndElement();
568 const Node *node =
nullptr;
569 QString link = getLink(atom, relative, &node);
571 startLink(writer, atom, node, link);
576 writer.writeStartElement(
"list");
579 writer.writeAttribute(
"type",
"bullet");
581 writer.writeAttribute(
"type",
"definition");
584 writer.writeAttribute(
"type",
"enum");
586 writer.writeAttribute(
"type",
"definition");
588 writer.writeAttribute(
"type",
"ordered");
590 writer.writeAttribute(
"start",
"A");
592 writer.writeAttribute(
"start",
"a");
594 writer.writeAttribute(
"start",
"I");
596 writer.writeAttribute(
"start",
"i");
598 writer.writeAttribute(
"start", atom
->next()->string());
600 writer.writeAttribute(
"start",
"1");
607 writer.writeStartElement(
"definition");
609 writer.writeTextElement(
610 "term", plainCode(marker->markedUpEnumValue(atom
->next()->string(), relative)));
614 writer.writeEndElement();
618 writer.writeStartElement(
"item");
622 writer.writeEndElement();
626 writer.writeEndElement();
630 writer.writeStartElement(
"para");
631 writer.writeTextElement(
"bold",
"Note:");
632 writer.writeCharacters(
" ");
639 writer.writeEndElement();
647 writer.writeStartElement(
"para");
652 writer.writeEndElement();
656 writer.writeStartElement(
"quote");
660 writer.writeEndElement();
664 writer.writeCharacters(atom->string());
668 writer.writeStartElement(
"section");
669 writer.writeAttribute(
"id",
674 writer.writeEndElement();
678 writer.writeStartElement(
"heading");
679 int unit = atom->string().toInt();
680 writer.writeAttribute(
"level", QString::number(unit));
681 m_inSectionHeading =
true;
685 writer.writeEndElement();
686 m_inSectionHeading =
false;
695 writer.writeStartElement(atom->string());
701 writer.writeAttribute(
"identifier", atom->string());
702 writer.writeEndElement();
709 const QString &location = atom->string();
710 writer.writeAttribute(
"location", location);
711 auto maybe_resolved_file{file_resolver.resolve(location)};
713 if (maybe_resolved_file)
714 writer.writeAttribute(
"path", (*maybe_resolved_file).get_path());
717 QString details =
std::transform_reduce(
718 file_resolver.get_search_directories().cbegin(),
719 file_resolver.get_search_directories().cend(),
720 u"Searched directories:"_s,
722 [](
const DirectoryPath &directory_path) -> QString {
return u' ' + directory_path.value(); }
725 relative
->location().warning(u"Cannot find file to quote from: %1"_s.arg(location), details);
731 writer.writeCharacters(atom->string());
734 writer.writeStartElement(
"table");
735 if (atom->string().contains(
"%"))
736 writer.writeAttribute(
"width", atom->string());
740 writer.writeEndElement();
744 writer.writeStartElement(
"header");
748 writer.writeEndElement();
752 writer.writeStartElement(
"row");
756 writer.writeEndElement();
760 writer.writeStartElement(
"item");
761 QStringList spans = atom->string().split(
",");
762 if (spans.size() == 2) {
763 if (spans.at(0) !=
"1")
764 writer.writeAttribute(
"colspan", spans.at(0).trimmed());
765 if (spans.at(1) !=
"1")
766 writer.writeAttribute(
"rowspan", spans.at(1).trimmed());
770 writer.writeEndElement();
775 if (
const auto *endtoc = atom->find(Atom::TableOfContentsRight))
780 writer.writeStartElement(
"target");
781 writer.writeAttribute(
"name", TextUtils::asAsciiPrintable(atom->string()));
782 writer.writeEndElement();
786 writer.writeStartElement(
"para");
787 writer.writeTextElement(
"bold",
"Warning:");
788 writer.writeCharacters(
" ");
793 writer.writeCharacters(atom->typeString());
799 m_hasQuotingInformation = keepQuoting;
806 QString fullName = link;
808 fullName = node->fullName();
809 if (!fullName.isEmpty() && !link.isEmpty()) {
810 writer.writeStartElement(
"link");
811 if (atom && !atom->string().isEmpty())
812 writer.writeAttribute(
"raw", atom->string());
814 writer.writeAttribute(
"raw", fullName);
815 writer.writeAttribute(
"href", link);
816 writer.writeAttribute(
"type", targetType(node));
820 writer.writeAttribute(
"enum", fullName);
823 const auto *en =
static_cast<
const ExampleNode *>(node);
824 const QString fileTitle = atom ? exampleFileTitle(en, atom->string()) : QString();
825 if (!fileTitle.isEmpty()) {
826 writer.writeAttribute(
"page", fileTitle);
832 writer.writeAttribute(
"page", fullName);
835 const auto *propertyNode =
static_cast<
const PropertyNode *>(node);
836 if (!propertyNode->getters().empty())
837 writer.writeAttribute(
"getter", propertyNode->getters().at(0)->fullName());
850 writer.writeEndElement();
857 if (node && !node->links().empty()) {
858 std::pair<QString, QString> anchorPair;
859 const Node *linkNode;
861 for (
auto it = node->links().cbegin(); it != node->links().cend(); ++it) {
863 linkNode = m_qdb->findNodeForTarget(it.value().first, node);
868 if (linkNode == node)
869 anchorPair = it.value();
871 anchorPair = anchorForNode(linkNode);
873 writer.writeStartElement(
"relation");
874 writer.writeAttribute(
"href", anchorPair.first);
875 writer.writeAttribute(
"type", targetType(linkNode));
879 writer.writeAttribute(
"meta",
"start");
882 writer.writeAttribute(
"meta",
"next");
885 writer.writeAttribute(
"meta",
"previous");
888 writer.writeAttribute(
"meta",
"contents");
891 writer.writeAttribute(
"meta",
"");
893 writer.writeAttribute(
"description", anchorPair.second);
894 writer.writeEndElement();
902 generateAnnotatedList(writer, relative, nodeMap.values());
908 writer.writeStartElement(
"table");
909 writer.writeAttribute(
"width",
"100%");
911 for (
const auto *node : nodeList) {
912 writer.writeStartElement(
"row");
913 writer.writeStartElement(
"item");
914 writer.writeStartElement(
"para");
915 const QString link = linkForNode(node, relative);
916 startLink(writer, node->doc().body().firstAtom(), node, link);
918 writer.writeEndElement();
919 writer.writeEndElement();
921 writer.writeStartElement(
"item");
922 writer.writeStartElement(
"para");
923 writer.writeCharacters(node->doc().briefText().toString());
924 writer.writeEndElement();
925 writer.writeEndElement();
926 writer.writeEndElement();
928 writer.writeEndElement();
933 return Generator::fileBase(node);
#define ATOM_FORMATTING_TELETYPE
#define ATOM_LIST_LOWERALPHA
#define ATOM_FORMATTING_UNDERLINE
#define ATOM_LIST_UPPERALPHA
#define ATOM_FORMATTING_NOTRANSLATE
#define ATOM_LIST_LOWERROMAN
#define ATOM_FORMATTING_SUBSCRIPT
#define ATOM_FORMATTING_BOLD
#define ATOM_FORMATTING_TRADEMARK
#define ATOM_FORMATTING_ITALIC
#define ATOM_LIST_UPPERROMAN
#define ATOM_FORMATTING_SUPERSCRIPT
#define ATOM_FORMATTING_INDEX
#define ATOM_FORMATTING_PARAMETER
The Atom class is the fundamental unit for representing documents internally.
AtomType type() const
Return the type of this atom.
const Atom * next() const
Return the next atom in the atom list.
A class for holding the members of a collection of doc pages.
const NodeList & members() const
The Config class contains the configuration variables for controlling how qdoc produces documentation...
InclusionPolicy createInclusionPolicy() const
const Location & location() const
Returns the starting location of a qdoc comment.
static void quoteFromFile(const Location &location, Quoter "er, ResolvedFile resolved_file, CodeMarker *marker=nullptr)
const Text & body() const
Text deprecationText() const
Encapsulate the logic that QDoc uses to find files whose path is provided by the user and that are re...
static bool appendTrademark(const Atom *atom)
Returns true if a trademark symbol should be appended to the output as determined by atom.
void endSubPage()
Flush the text stream associated with the subpage, and then pop it off the text stream stack and dele...
void generateRequiredLinks(const Node *node, CodeMarker *marker)
Generates either a link to the project folder for example node, or a list of links files/images if 'u...
HtmlGenerator(FileResolver &file_resolver)
void initializeGenerator() override
Initializes the HTML output generator's data structures from the configuration (Config) singleton.
void terminateGenerator() override
Gracefully terminates the HTML output generator.
static bool isIncluded(const InclusionPolicy &policy, const NodeContext &context)
A PageNode is a Node that generates a documentation page.
This class imports QDoc index files and serializes index sections for module indexes and WebXML outpu...
static Text sectionHeading(const Atom *sectionBegin)
const Atom * firstAtom() const
QString fileBase(const Node *node) const override
QString format() const override
Returns the format identifier for this producer (e.g., "HTML", "DocBook", "template").
virtual const Atom * addAtomElements(QXmlStreamWriter &writer, const Atom *atom, const Node *relative, CodeMarker *marker)
void terminateGenerator() override
Gracefully terminates the HTML output generator.
void generateDocumentation(Node *node) override
Recursive writing of HTML files from the root node.
void append(QXmlStreamWriter &writer, Node *node) override
virtual void generateIndexSections(QXmlStreamWriter &writer, Node *node)
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.
WebXMLGenerator(FileResolver &file_resolver)
QString fileExtension() const override
Returns "html" for this subclass of Generator.
void initializeGenerator() override
Initializes the HTML output generator's data structures from the configuration (Config) singleton.
void generateExampleFilePage(const PageNode *en, ResolvedFile file, CodeMarker *marker=nullptr) override
Generate an html file with the contents of a C++ or QML source file.
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...
qsizetype generateAtom(const Atom *atom, const Node *relative, CodeMarker *marker) override
Most of the output is generated by QDocIndexFiles and the append() callback.
#define CONFIG_LOCATIONINFO
Combined button and popup list for selecting options.
QMap< QString, Node * > NodeMap
ExampleEntries exampleEntries
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.
const Doc & doc() const
Returns a reference to the node's Doc data member.
bool isGroup() const
Returns true if the node type is Group.
SharedCommentNode * sharedCommentNode()
bool isNamespace() const
Returns true if the node type is Namespace.
bool isHeader() const
Returns true if the node type is HeaderFile.
NodeType nodeType() const override
Returns this node's type.
bool isEnumType() const
Returns true if the node type is Enum.
virtual bool isTextPageNode() const
Returns true if the node is a PageNode but not an Aggregate.
Aggregate * parent() const
Returns the node's parent pointer, that is, the aggregate under which the node is documented.
bool isVariable() const
Returns true if the node type is Variable.
virtual bool isDeprecated() const
Returns true if this node's status is Deprecated.
virtual bool isAggregate() const
Returns true if this node is an aggregate, which means it inherits Aggregate and can therefore have c...
const Location & location() const
If this node's definition location is empty, this function returns this node's declaration location.
virtual bool wasSeen() const
Returns the seen flag data member of this node if it is a NamespaceNode or a CollectionNode.
bool isProperty() const
Returns true if the node type is Property.
NodeContext createContext() const
bool isModule() const
Returns true if the node type is Module.
bool isSharingComment() const
This function returns true if the node is sharing a comment with other nodes.
virtual bool isClassNode() const
Returns true if this is an instance of ClassNode.
virtual bool isCollectionNode() const
Returns true if this is an instance of CollectionNode.
bool isExample() const
Returns true if the node type is Example.
bool isIndexNode() const
Returns true if this node was created from something in an index file.
Represents a file that is reachable by QDoc based on its current configuration.
static CodeMarker * marker_