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