1
/****************************************************************************
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the documentation of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:FDL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Free Documentation License Usage
18
** Alternatively, this file may be used under the terms of the GNU Free
19
** Documentation License version 1.3 as published by the Free Software
20
** Foundation and appearing in the file included in the packaging of
21
** this file. Please review the following information to ensure
22
** the GNU Free Documentation License version 1.3 requirements
23
** will be met: http://www.gnu.org/copyleft/fdl.html.
26
****************************************************************************/
29
\page qtwritingstyle-qml.html
30
\title QML Documentation Style
31
\brief Style guidelines for QML documentation
33
QDoc can process QML types defined as C++ classes and QML types defined in
34
\c .qml files. For C++ classes documented as QML types, the QDoc comments are
35
in the \c .cpp file while QML types defined in QML are in the \c .qml
36
file. The C++ classes must also be documented
37
documented with the QML \l{topic-commands}{topic commands}:
40
\li \l{qmlattachedproperty-command}{\\qmlattachedproperty}
41
\li \l{qmlattachedsignal-command}{\\qmlattachedsignal}
42
\li \l{qmlbasictype-command}{\\qmlbasictype}
43
\li \l{qmltype-command}{\\qmltype}
44
\li \l{qmlmethod-command}{\\qmlmethod}
45
\li \l{qmlproperty-command}{\\qmlproperty}
46
\li \l{qmlsignal-command}{\\qmlsignal}
47
\li \l{qmlmodule-command}{\\qmlmodule}
48
\li \l{inqmlmodule-command}{\\inqmlmodule}
49
\li \l{instantiates-command}{\\instantiates}
52
For QML types defined in \c .qml files, QDoc will parse the QML and determine
53
the properties, signals, and the type within the QML definition. The QDoc
54
block then needs to be immediately above the declaration. For QML types
55
implemented in C++, QDoc will output warnings if the C++ class documentation
56
does not exist. The class documentation may be marked as
57
\l{internal-command}{internal} if it is not a public API.
61
The \l{qmltype-command}{\\qmltype} command is for QML type documentation.
63
\snippet examples/qml.qdoc qmltype
65
The \l{instantiates-command}{\\instantiates} accepts the C++ class which
66
implements the QML type as the argument. For types implemented in QML, this
69
The \e{brief description} provides a summary for the QML type. The brief does
70
not need to be a complete sentence and may start with a verb. QDoc will append
71
the brief description onto the QML type in tables and generated lists.
74
\qmltype ColorAnimation
75
\brief Animates changes in color values
78
Here are some alternate verbs for the brief statement:
85
The \e{detailed description} follows the brief and may contain images, snippet,
86
and link to other documentation.
90
The property description focuses on what the property \e does and may use the
93
Property documentation usually starts with "This property..." but for certain
94
properties, these are the common expressions:
96
\li "This property holds..."
97
\li "This property describes..."
98
\li "This property represents..."
99
\li "Returns \c true when... and \c false when..." - for properties that
100
are marked \c{read-only}.
101
\li "Sets the..." - for properties that configure a type.
104
\section1 Signals and Handlers Documentation
106
QML signals are documented either in the QML file or in the C++ implementation
107
with the \l{qmlsignal-command}{\\qmlsignal} command. Signal documentation
108
must include the condition for emitting the signal, mention the corresponding
109
signal handler, and document whether the signal accepts a parameter.
111
\snippet examples/qml.qdoc signals
113
These are the possible documentation styles for signals:
115
\li "This signal is triggered when..."
116
\li "Triggered when..."
117
\li "Emitted when..."
120
\section1 Methods and JavaScript Functions
122
Typically, function documentation immediately precedes the implementation of the
123
function in the \c .cpp file. The \l{topic-commands}{topic command} for
124
functions is \l{fn-command}{\\fn}. For functions in QML or JavaScript, the
125
documentation must reside immediately above the function declaration.
127
The function documentation starts with a verb, indicating the operation the
130
\snippet examples/qml.qdoc function
132
Some common verbs for function documentation:
134
\li "Copies..." - for constructors
135
\li "Destroys..." - for destructors
136
\li "Returns..." - for accessor functions
139
The function documentation must document:
143
\li the actions of the functions
146
The \l{a-command}{\\a} command marks the parameter in the documentation.
147
The return type documentation should link to the type documentation or be
148
marked with the \l{c-command}{\\c} command in the case of boolean values.
150
\section1 Enumerations
152
QML enumerations are documented as QML properties with the
153
\l{qmlproperty-command}{\\qmlproperty} command. The type of the property
156
\snippet examples/qml.qdoc enums
158
The QDoc comment lists the values of the enumeration. If the enumeration is
159
implemented in C++, the documentation may link to the corresponding C++
160
enumeration. However, the QDoc comment should advise that the enumeration
161
is a C++ enumeration.