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
9
QDoc 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
11
in the \c .cpp file while QML types defined in QML are in the \c .qml
12
file. The C++ classes must also be documented
13
documented 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
29
For QML types defined in \c .qml files, QDoc will parse the QML and determine
30
the properties, signals, and the type within the QML definition. The QDoc
31
block then needs to be immediately above the declaration. For QML types
32
implemented in C++, QDoc will output warnings if the C++ class documentation
33
does 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
38
The \l{qmltype-command}{\\qmltype} command is for QML type documentation.
39
40
\snippet examples/qml.qdoc.sample qmltype
41
42
The \l{nativetype-command}{\\nativetype} command accepts the C++ class which
43
implements the QML type as the argument. For types implemented in QML, this
44
is not needed.
45
46
The \e{brief description} provides a summary for the QML type. The brief does
47
not need to be a complete sentence and may start with a verb. QDoc will append
48
the 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
55
Here are some alternate verbs for the brief statement:
56
\list
57
\li "Provides..."
58
\li "Specifies..."
59
\li "Describes..."
60
\endlist
61
62
The \e{detailed description} follows the brief and may contain images, snippet,
63
and link to other documentation.
64
65
\section1 Properties
66
67
The property description focuses on what the property \e does and may use the
68
following style:
69
70
Property documentation usually starts with "This property..." but for certain
71
properties, 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
77
are marked \c{read-only}.
78
\li "Sets the..." - for properties that configure a type.
79
\endlist
80
81
\section1 Signals and Handlers Documentation
82
83
QML signals are documented either in the QML file or in the C++ implementation
84
with the \l{qmlsignal-command}{\\qmlsignal} command. Signal documentation
85
must include the condition for emitting the signal, mention the corresponding
86
signal handler, and document whether the signal accepts a parameter.
87
88
\snippet examples/qml.qdoc.sample signals
89
90
These 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
99
Typically, function documentation immediately precedes the implementation of the
100
function in the \c .cpp file. The \l{topic-commands}{topic command} for
101
functions is \l{fn-command}{\\fn}. For functions in QML, the
102
documentation must reside immediately above the function declaration.
103
104
The function documentation starts with a verb, indicating the operation the
105
function performs.
106
107
\snippet examples/qml.qdoc.sample function
108
109
Some 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
116
The 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
123
The \l{a-command}{\\a} command marks the parameter in the documentation.
124
The return type documentation should link to the type documentation or be
125
marked with the \l{c-command}{\\c} command in the case of boolean values.
126
127
\section1 Enumerations
128
129
QML enumerations are documented as QML properties with the
130
\l{qmlenum-command}{\\qmlenum} command. Use the \l{value-command}{\\value} command to document
131
the enum values. Add the type name as a prefix to each value, separated by
132
a period (.), as QDoc does not do this automatically.
133
134
\snippet examples/qml.qdoc.sample enums
135
136
The QDoc comment lists the values of the enumeration.
137
138
If the enumeration is implemented in C++, consider using the
139
\l{qmlenumeratorsfrom-command}{\\qmlenumeratorsfrom} command.
140
If this isn't possible, the documentation may also directly link to the
141
corresponding C++ enumeration. However, the QDoc comment should then advise that
142
the enumeration is a C++ enumeration.
143
*/
qttools
src
qdoc
qdoc
doc
qdoc-guide
qtwritingstyle-qml.qdoc
Generated on
for Qt by
1.16.1