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
XmlGenerator Class Reference

#include <xmlgenerator.h>

+ Inheritance diagram for XmlGenerator:
+ Collaboration diagram for XmlGenerator:

Public Member Functions

 XmlGenerator (FileResolver &file_resolver)
 
- Public Member Functions inherited from Generator
 Generator (Moc *moc, ClassDef *classDef, const QList< QByteArray > &metaTypes, const QHash< QByteArray, QByteArray > &knownQObjectClasses, const QHash< QByteArray, QByteArray > &knownGadgets, FILE *outfile=nullptr, bool requireCompleteTypes=false)
 
void generateCode ()
 
qsizetype registeredStringsCount ()
 
 Generator (FileResolver &file_resolver)
 Constructs the generator base class.
 
virtual ~Generator ()
 Destroys the generator after removing it from the list of output generators.
 
virtual bool canHandleFormat (const QString &format)
 
virtual QString format ()=0
 
virtual void generateDocs ()
 Traverses the database recursively to generate all the documentation.
 
virtual void initializeGenerator ()
 Updates the generator's m_showInternal from the Config.
 
virtual void initializeFormat ()
 Reads format-specific variables from config, sets output (sub)directories, creates them on the filesystem and copies the template-specific files.
 
virtual void terminateGenerator ()
 
virtual QString typeString (const Node *node)
 
QString fullDocumentLocation (const Node *node)
 Returns the full document location.
 
QString linkForExampleFile (const QString &path, const QString &fileExt=QString())
 Constructs an href link from an example file name, which is a path to the example file.
 
virtual QString fileBase (const Node *node) const
 

Protected Member Functions

QString registerRef (const QString &ref, bool xmlCompliant=false)
 Registers an anchor reference and returns a unique and cleaned copy of the reference (the one that should be used in the output).
 
QString refForNode (const Node *node)
 Generates a clean and unique reference for the given node.
 
QString linkForNode (const Node *node, const Node *relative)
 Construct the link string for the node and return it.
 
QString getLink (const Atom *atom, const Node *relative, const Node **node)
 This function is called for links, i.e.
 
QString getAutoLink (const Atom *atom, const Node *relative, const Node **node, Node::Genus=Node::DontCare)
 This function is called for autolinks, i.e.
 
std::pair< QString, QStringanchorForNode (const Node *node)
 
- Protected Member Functions inherited from Generator
void beginSubPage (const Node *node, const QString &fileName)
 Creates the file named fileName in the output directory.
 
void endSubPage ()
 Flush the text stream associated with the subpage, and then pop it off the text stream stack and delete it.
 
virtual QString fileExtension () const =0
 
virtual void generateExampleFilePage (const Node *, ResolvedFile, CodeMarker *=nullptr)
 
virtual void generateAlsoList (const Node *node, CodeMarker *marker)
 
virtual void generateAlsoList (const Node *node)
 
virtual qsizetype generateAtom (const Atom *, const Node *, CodeMarker *)
 
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 node.
 
virtual void generateCppReferencePage (Aggregate *, CodeMarker *)
 
virtual void generateProxyPage (Aggregate *, CodeMarker *)
 
virtual void generateQmlTypePage (QmlTypeNode *, CodeMarker *)
 
virtual void generatePageNode (PageNode *, CodeMarker *)
 
virtual void generateCollectionNode (CollectionNode *, CodeMarker *)
 
virtual void generateGenericCollectionPage (CollectionNode *, CodeMarker *)
 
virtual void generateDocumentation (Node *node)
 Recursive writing of HTML files from the root node.
 
virtual bool generateText (const Text &text, const Node *relative, CodeMarker *marker)
 Generate the documentation for relative.
 
virtual bool generateText (const Text &text, const Node *relative)
 
virtual int skipAtoms (const Atom *atom, Atom::AtomType type) const
 
void initializeTextOutput ()
 Resets the variables used during text output.
 
QString fileName (const Node *node, const QString &extension=QString()) const
 If the node has a URL, return the URL as the file name.
 
QMap< QString, QString > & formattingLeftMap ()
 
QMap< QString, QString > & formattingRightMap ()
 
const AtomgenerateAtomList (const Atom *atom, const Node *relative, CodeMarker *marker, bool generate, int &numGeneratedAtoms)
 
void generateEnumValuesForQmlProperty (const Node *node, CodeMarker *marker)
 
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 'url.examples config' variable is not defined.
 
void generateLinkToExample (const ExampleNode *en, CodeMarker *marker, const QString &exampleUrl)
 Generates an external link to the project folder for example node.
 
virtual void generateFileList (const ExampleNode *en, CodeMarker *marker, bool images)
 This function is called when the documentation for an example is being formatted.
 
void generateSince (const Node *node, CodeMarker *marker)
 
void generateNoexceptNote (const Node *node, CodeMarker *marker)
 
void generateStatus (const Node *node, CodeMarker *marker)
 
virtual void generateAddendum (const Node *node, Addendum type, CodeMarker *marker, bool generateNote)
 Generates an addendum note of type type for node, using marker as the code marker.
 
virtual void generateAddendum (const Node *node, Addendum type, CodeMarker *marker)
 
void generateThreadSafeness (const Node *node, CodeMarker *marker)
 Generates text that explains how threadsafe and/or reentrant node is.
 
bool generateComparisonCategory (const Node *node, CodeMarker *marker=nullptr)
 
bool generateComparisonList (const Node *node)
 Generates a list of types that compare to node with the comparison category that applies for the relationship, followed by (an optional) descriptive text.
 
void generateOverloadedSignal (const Node *node, CodeMarker *marker)
 If the node is an overloaded signal, add a node with an example on how to connect to it.
 
QString indent (int level, const QString &markedCode)
 
QTextStreamout ()
 
QString outFileName ()
 
bool parseArg (const QString &src, const QString &tag, int *pos, int n, QStringView *contents, QStringView *par1=nullptr)
 
void unknownAtom (const Atom *atom)
 
int appendSortedQmlNames (Text &text, const Node *base, const NodeList &subs)
 
void appendFullName (Text &text, const Node *apparentNode, const Node *relative, const Node *actualNode=nullptr)
 
void appendFullName (Text &text, const Node *apparentNode, const QString &fullName, const Node *actualNode)
 
int appendSortedNames (Text &text, const ClassNode *classe, const QList< RelatedClass > &classes)
 
void appendSignature (Text &text, const Node *node)
 Append the signature for the function named in node to text, so that is a link to the documentation for that function.
 
void signatureList (const NodeList &nodes, const Node *relative, CodeMarker *marker)
 Generate a bullet list of function signatures.
 
void addImageToCopy (const ExampleNode *en, const ResolvedFile &resolved_file)
 

Static Protected Member Functions

static bool hasBrief (const Node *node)
 Do not display.
 
static bool isThreeColumnEnumValueTable (const Atom *atom)
 Determines whether the list atom should be shown with three columns (constant-value-description).
 
static bool isOneColumnValueTable (const Atom *atom)
 Determines whether the list atom should be shown with just one column (value).
 
static int hOffset (const Node *node)
 Header offset depending on the type of the node.
 
static void rewritePropertyBrief (const Atom *atom, const Node *relative)
 Rewrites the brief of this node depending on its first word.
 
static Node::NodeType typeFromString (const Atom *atom)
 Returns the type of this atom as an enumeration.
 
static void setImageFileName (const Node *relative, const QString &fileName)
 For images shown in examples, set the image file to the one it will have once the documentation is generated.
 
static std::pair< QString, int > getAtomListValue (const Atom *atom)
 Handles the differences in lists between list tags and since tags, and returns the content of the list entry atom (first member of the pair).
 
static std::pair< QString, QStringgetTableWidthAttr (const Atom *atom)
 Parses the table attributes from the given atom.
 
static QString targetType (const Node *node)
 Returns a string describing the node type.
 
- Static Protected Member Functions inherited from Generator
static QFileopenSubPageFile (const PageNode *node, const QString &fileName)
 Creates the file named fileName in the output directory and returns a QFile pointing to this file.
 
static bool matchAhead (const Atom *atom, Atom::AtomType expectedAtomType)
 
static QString outputPrefix (const Node *node)
 
static QString outputSuffix (const Node *node)
 
static void supplementAlsoList (const Node *node, QList< Text > &alsoList)
 
static QString trimmedTrailing (const QString &string, const QString &prefix, const QString &suffix)
 Trims trailing whitespace off the string and returns the trimmed string.
 
static QString formatSince (const Node *node)
 
static QString getOverloadedSignalCode (const Node *node)
 Returns the string containing an example code of the input node, if it is an overloaded signal.
 
static bool hasExceptions (const Node *node, NodeList &reentrant, NodeList &threadsafe, NodeList &nonreentrant)
 
static bool comparePaths (const QString &a, const QString &b)
 
static bool appendTrademark (const Atom *atom)
 Returns true if a trademark symbol should be appended to the output as determined by atom.
 
static std::optional< std::pair< QString, QString > > cmakeRequisite (const CollectionNode *cn)
 Generate the CMake requisite for the node cn, i.e.
 
static Qt::SortOrder sortOrder (const QString &str)
 

Protected Attributes

QHash< QString, QStringrefMap
 
const Nodem_linkNode { nullptr }
 
- Protected Attributes inherited from Generator
QString naturalLanguage
 
QString tagFile_
 
QStack< QTextStream * > outStreamStack
 
FileResolverfile_resolver
 
QDocDatabasem_qdb { nullptr }
 
bool m_inLink { false }
 
bool m_inContents { false }
 
bool m_inSectionHeading { false }
 
bool m_inTableHeader { false }
 
bool m_threeColumnEnumValueTable { true }
 
bool m_showInternal { false }
 
bool m_quoting { false }
 
int m_numTableRows { 0 }
 
QString m_link {}
 
QString m_sectionNumber {}
 

Static Protected Attributes

static const QRegularExpression m_funcLeftParen
 

Additional Inherited Members

- Public Types inherited from Generator
enum  ListType { Generic , Obsolete }
 
enum  Addendum {
  Invokable , PrivateSignal , QmlSignalHandler , AssociatedProperties ,
  BindableProperty
}
 
- Static Public Member Functions inherited from Generator
static QString exampleFileTitle (const ExampleNode *relative, const QString &fileName)
 Helper function to construct a title for a file or image page included in an example.
 
static GeneratorcurrentGenerator ()
 
static GeneratorgeneratorForFormat (const QString &format)
 
static void initialize ()
 
static const QStringoutputDir ()
 
static const QStringoutputSubdir ()
 
static void terminate ()
 
static const QStringListoutputFileNames ()
 
static bool noLinkErrors ()
 
static bool autolinkErrors ()
 
static QString defaultModuleName ()
 
static void resetUseOutputSubdirs ()
 
static bool useOutputSubdirs ()
 
static void setQmlTypeContext (QmlTypeNode *t)
 
static QmlTypeNodeqmlTypeContext ()
 
static QString cleanRef (const QString &ref, bool xmlCompliant=false)
 Clean the given ref to be used as an HTML anchor or an xml:id.
 
static QString plainCode (const QString &markedCode)
 

Detailed Description

Definition at line 17 of file xmlgenerator.h.

Constructor & Destructor Documentation

◆ XmlGenerator()

XmlGenerator::XmlGenerator ( FileResolver & file_resolver)
explicit

Definition at line 19 of file xmlgenerator.cpp.

References Generator::Generator().

Referenced by DocBookGenerator::DocBookGenerator(), and HtmlGenerator::HtmlGenerator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ anchorForNode()

std::pair< QString, QString > XmlGenerator::anchorForNode ( const Node * node)
protected

Definition at line 438 of file xmlgenerator.cpp.

References Node< _Tp >::isTextPageNode().

+ Here is the call graph for this function:

◆ getAtomListValue()

std::pair< QString, int > XmlGenerator::getAtomListValue ( const Atom * atom)
staticprotected

Handles the differences in lists between list tags and since tags, and returns the content of the list entry atom (first member of the pair).

It also returns the number of items to skip ahead (second member of the pair).

Definition at line 150 of file xmlgenerator.cpp.

References Atom::next(), Atom::SinceTagLeft, Atom::String, and Atom::type().

+ Here is the call graph for this function:

◆ getAutoLink()

QString XmlGenerator::getAutoLink ( const Atom * atom,
const Node * relative,
const Node ** node,
Node::Genus genus = Node::DontCare )
protected

This function is called for autolinks, i.e.

for words that are not marked with the qdoc link command that qdoc has reason to believe should be links.

It returns the string for a link found by using the data in the atom to search the database. It also sets node to point to the target node for that link. relative points to the node holding the qdoc comment where the link command was found.

Definition at line 414 of file xmlgenerator.cpp.

References Generator::m_qdb.

◆ getLink()

QString XmlGenerator::getLink ( const Atom * atom,
const Node * relative,
const Node ** node )
protected

This function is called for links, i.e.

for words that are marked with the qdoc link command. For autolinks that are not marked with the qdoc link command, the getAutoLink() function is called

It returns the string for a link found by using the data in the atom to search the database. It also sets node to point to the target node for that link. relative points to the node holding the qdoc comment where the link command was found.

Definition at line 383 of file xmlgenerator.cpp.

◆ getTableWidthAttr()

std::pair< QString, QString > XmlGenerator::getTableWidthAttr ( const Atom * atom)
staticprotected

Parses the table attributes from the given atom.

This method returns a pair containing the width (%) and the attribute for this table (either "generic" or "borderless").

Definition at line 183 of file xmlgenerator.cpp.

◆ hasBrief()

bool XmlGenerator::hasBrief ( const Node * node)
staticprotected

Do not display.

for QML types, document and collection nodes

Definition at line 24 of file xmlgenerator.cpp.

References Node< _Tp >::isCollectionNode(), Node< _Tp >::isPageNode(), and Node< _Tp >::isQmlType().

Referenced by DocBookGenerator::generateAtom(), and HtmlGenerator::generateAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hOffset()

int XmlGenerator::hOffset ( const Node * node)
staticprotected

Header offset depending on the type of the node.

Definition at line 67 of file xmlgenerator.cpp.

References Node< _Tp >::Class, Node< _Tp >::Enum, Node< _Tp >::Function, Node< _Tp >::Group, Node< _Tp >::Module, Node< _Tp >::Namespace, Node< _Tp >::nodeType(), Node< _Tp >::Page, Node< _Tp >::Property, Node< _Tp >::QmlModule, Node< _Tp >::QmlType, Node< _Tp >::QmlValueType, Node< _Tp >::Struct, Node< _Tp >::TypeAlias, Node< _Tp >::Typedef, and Node< _Tp >::Union.

Referenced by DocBookGenerator::generateAtom(), and HtmlGenerator::generateAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isOneColumnValueTable()

bool XmlGenerator::isOneColumnValueTable ( const Atom * atom)
staticprotected

Determines whether the list atom should be shown with just one column (value).

Definition at line 46 of file xmlgenerator.cpp.

References Atom::ListItemLeft, Atom::ListItemRight, Atom::ListLeft, Atom::ListTagRight, Generator::matchAhead(), Atom::next(), and Atom::type().

Referenced by DocBookGenerator::generateAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isThreeColumnEnumValueTable()

bool XmlGenerator::isThreeColumnEnumValueTable ( const Atom * atom)
staticprotected

Determines whether the list atom should be shown with three columns (constant-value-description).

Definition at line 33 of file xmlgenerator.cpp.

References Atom::ListItemLeft, Atom::ListItemRight, Atom::ListRight, Generator::matchAhead(), Atom::next(), and Atom::type().

Referenced by DocBookGenerator::generateAtom(), and HtmlGenerator::generateAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ linkForNode()

QString XmlGenerator::linkForNode ( const Node * node,
const Node * relative )
protected

Construct the link string for the node and return it.

The relative node is used to decide whether the link we are generating is in the same file as the target. Note the relative node can be 0, which pretty much guarantees that the link and the target aren't in the same file.

Definition at line 323 of file xmlgenerator.cpp.

References Node< _Tp >::doc(), QmlTypeNode::inherits(), Node< _Tp >::isAbstract(), Node< _Tp >::isInternal(), Node< _Tp >::isPageNode(), Node< _Tp >::isPrivate(), Node< _Tp >::isPropertyGroup(), Node< _Tp >::isQmlType(), Doc::location(), Generator::noLinkErrors(), Node< _Tp >::parent(), and Generator::qmlTypeContext().

+ Here is the call graph for this function:

◆ refForNode()

QString XmlGenerator::refForNode ( const Node * node)
protected

Generates a clean and unique reference for the given node.

This reference may depend on the type of the node (typedef, QML signal, etc.)

Definition at line 253 of file xmlgenerator.cpp.

References Node< _Tp >::doc(), Node< _Tp >::Enum, Node< _Tp >::Function, Node< _Tp >::isAttached(), Node< _Tp >::isPropertyGroup(), FunctionNode::metaness(), Node< _Tp >::nodeType(), FunctionNode::primaryAssociatedProperty(), Node< _Tp >::Property, FunctionNode::QmlMethod, Node< _Tp >::QmlProperty, FunctionNode::QmlSignal, FunctionNode::QmlSignalHandler, Node< _Tp >::SharedComment, Node< _Tp >::TypeAlias, Node< _Tp >::Typedef, and Node< _Tp >::Variable.

+ Here is the call graph for this function:

◆ registerRef()

QString XmlGenerator::registerRef ( const QString & ref,
bool xmlCompliant = false )
protected

Registers an anchor reference and returns a unique and cleaned copy of the reference (the one that should be used in the output).

To ensure unicity throughout the document, this method uses the refMap cache.

Definition at line 229 of file xmlgenerator.cpp.

◆ rewritePropertyBrief()

void XmlGenerator::rewritePropertyBrief ( const Atom * atom,
const Node * relative )
staticprotected

Rewrites the brief of this node depending on its first word.

Only for properties and variables (does nothing otherwise).

Definition at line 96 of file xmlgenerator.cpp.

References Atom::next(), Node< _Tp >::nodeType(), Node< _Tp >::Property, Atom::String, Atom::type(), and Node< _Tp >::Variable.

Referenced by DocBookGenerator::generateAtom(), and HtmlGenerator::generateAtom().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setImageFileName()

void XmlGenerator::setImageFileName ( const Node * relative,
const QString & fileName )
staticprotected

For images shown in examples, set the image file to the one it will have once the documentation is generated.

Definition at line 134 of file xmlgenerator.cpp.

References Node< _Tp >::isExample().

+ Here is the call graph for this function:

◆ targetType()

QString XmlGenerator::targetType ( const Node * node)
staticprotected

Returns a string describing the node type.

Definition at line 452 of file xmlgenerator.cpp.

References Node< _Tp >::Class, Node< _Tp >::Enum, Node< _Tp >::Example, Node< _Tp >::Function, Node< _Tp >::Module, Node< _Tp >::Namespace, Node< _Tp >::nodeType(), Node< _Tp >::Page, Node< _Tp >::Property, Node< _Tp >::Struct, Node< _Tp >::TypeAlias, Node< _Tp >::Typedef, Node< _Tp >::Union, and Node< _Tp >::Variable.

+ Here is the call graph for this function:

◆ typeFromString()

Node::NodeType XmlGenerator::typeFromString ( const Atom * atom)
staticprotected

Returns the type of this atom as an enumeration.

Definition at line 119 of file xmlgenerator.cpp.

References Node< _Tp >::Group, Node< _Tp >::Module, and Node< _Tp >::QmlModule.

Referenced by DocBookGenerator::generateAtom(), and HtmlGenerator::generateAtom().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_funcLeftParen

QT_BEGIN_NAMESPACE const QRegularExpression XmlGenerator::m_funcLeftParen
staticprotected

Definition at line 48 of file xmlgenerator.h.

◆ m_linkNode

const Node* XmlGenerator::m_linkNode { nullptr }
protected

Definition at line 49 of file xmlgenerator.h.

◆ refMap

QHash<QString, QString> XmlGenerator::refMap
protected

Definition at line 23 of file xmlgenerator.h.


The documentation for this class was generated from the following files: