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
qtwritingstyle-qml.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5\page qtwritingstyle-qml.html
6\title QML Documentation Style
7\brief Style guidelines for QML documentation
8
9QDoc can process QML types defined as C++ classes and QML types defined in
10\c .qml files. For C++ classes documented as QML types, the QDoc comments are
11in the \c .cpp file while QML types defined in QML are in the \c .qml
12file. The C++ classes must also be documented
13documented with the QML \l{topic-commands}{topic commands}:
14
15\list
16\li \l{qmlattachedmethod-command}{\\qmlattachedmethod}
17\li \l{qmlattachedproperty-command}{\\qmlattachedproperty}
18\li \l{qmlattachedsignal-command}{\\qmlattachedsignal}
19\li \l{qmlvaluetype-command}{\\qmlvaluetype}
20\li \l{qmltype-command}{\\qmltype}
21\li \l{qmlmethod-command}{\\qmlmethod}
22\li \l{qmlproperty-command}{\\qmlproperty}
23\li \l{qmlsignal-command}{\\qmlsignal}
24\li \l{qmlmodule-command}{\\qmlmodule}
25\li \l{inqmlmodule-command}{\\inqmlmodule}
26\li \l{nativetype-command}{\\nativetype}
27\endlist
28
29For QML types defined in \c .qml files, QDoc will parse the QML and determine
30the properties, signals, and the type within the QML definition. The QDoc
31block then needs to be immediately above the declaration. For QML types
32implemented in C++, QDoc will output warnings if the C++ class documentation
33does not exist. The class documentation may be marked as
34\l{internal-command}{internal} if it is not a public API.
35
36\section1 QML Types
37
38The \l{qmltype-command}{\\qmltype} command is for QML type documentation.
39
40\snippet examples/qml.qdoc.sample qmltype
41
42The \l{nativetype-command}{\\nativetype} command accepts the C++ class which
43implements the QML type as the argument. For types implemented in QML, this
44is not needed.
45
46The \e{brief description} provides a summary for the QML type. The brief does
47not need to be a complete sentence and may start with a verb. QDoc will append
48the brief description onto the QML type in tables and generated lists.
49
50\code
51\qmltype ColorAnimation
52\brief Animates changes in color values
53\endcode
54
55Here are some alternate verbs for the brief statement:
56\list
57\li "Provides..."
58\li "Specifies..."
59\li "Describes..."
60\endlist
61
62The \e{detailed description} follows the brief and may contain images, snippet,
63and link to other documentation.
64
65\section1 Properties
66
67The property description focuses on what the property \e does and may use the
68following style:
69
70Property documentation usually starts with "This property..." but for certain
71properties, these are the common expressions:
72\list
73\li "This property holds..."
74\li "This property describes..."
75\li "This property represents..."
76\li "Returns \c true when... and \c false when..." - for properties that
77are marked \c{read-only}.
78\li "Sets the..." - for properties that configure a type.
79\endlist
80
81\section1 Signals and Handlers Documentation
82
83QML signals are documented either in the QML file or in the C++ implementation
84with the \l{qmlsignal-command}{\\qmlsignal} command. Signal documentation
85must include the condition for emitting the signal, mention the corresponding
86signal handler, and document whether the signal accepts a parameter.
87
88\snippet examples/qml.qdoc.sample signals
89
90These are the possible documentation styles for signals:
91\list
92\li "This signal is triggered when..."
93\li "Triggered when..."
94\li "Emitted when..."
95\endlist
96
97\section1 Methods and QML Functions
98
99Typically, function documentation immediately precedes the implementation of the
100function in the \c .cpp file. The \l{topic-commands}{topic command} for
101functions is \l{fn-command}{\\fn}. For functions in QML, the
102documentation must reside immediately above the function declaration.
103
104The function documentation starts with a verb, indicating the operation the
105function performs.
106
107\snippet examples/qml.qdoc.sample function
108
109Some common verbs for function documentation:
110\list
111\li "Copies..." - for constructors
112\li "Destroys..." - for destructors
113\li "Returns..." - for accessor functions
114\endlist
115
116The function documentation must document:
117\list
118\li the return type
119\li the parameters
120\li the actions of the functions
121\endlist
122
123The \l{a-command}{\\a} command marks the parameter in the documentation.
124The return type documentation should link to the type documentation or be
125marked with the \l{c-command}{\\c} command in the case of boolean values.
126
127\section1 Enumerations
128
129QML enumerations are documented as QML properties with the
130\l{qmlenum-command}{\\qmlenum} command. Use the \l{value-command}{\\value} command to document
131the enum values. Add the type name as a prefix to each value, separated by
132a period (.), as QDoc does not do this automatically.
133
134\snippet examples/qml.qdoc.sample enums
135
136The QDoc comment lists the values of the enumeration.
137
138If the enumeration is implemented in C++, consider using the
139\l{qmlenumeratorsfrom-command}{\\qmlenumeratorsfrom} command.
140If this isn't possible, the documentation may also directly link to the
141corresponding C++ enumeration. However, the QDoc comment should then advise that
142the enumeration is a C++ enumeration.
143*/