~ubuntu-branches/ubuntu/wily/qtbase-opensource-src/wily

« back to all changes in this revision

Viewing changes to src/tools/qdoc/doc/qdoc-guide/qtwritingstyle-qml.qdoc

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2013-02-05 12:46:17 UTC
  • Revision ID: package-import@ubuntu.com-20130205124617-c8jouts182j002fx
Tags: upstream-5.0.1+dfsg
ImportĀ upstreamĀ versionĀ 5.0.1+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/legal
 
5
**
 
6
** This file is part of the documentation of the Qt Toolkit.
 
7
**
 
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.
 
16
**
 
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.
 
24
** $QT_END_LICENSE$
 
25
**
 
26
****************************************************************************/
 
27
 
 
28
/*!
 
29
\page qtwritingstyle-qml.html
 
30
\title QML Documentation Style
 
31
\brief Style guidelines for QML documentation
 
32
 
 
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}:
 
38
 
 
39
\list
 
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}
 
50
\endlist
 
51
 
 
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.
 
58
 
 
59
\section1 QML Types
 
60
 
 
61
The \l{qmltype-command}{\\qmltype} command is for QML type documentation.
 
62
 
 
63
\snippet examples/qml.qdoc qmltype
 
64
 
 
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
 
67
is not needed.
 
68
 
 
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.
 
72
 
 
73
\code
 
74
\qmltype ColorAnimation
 
75
\brief Animates changes in color values
 
76
\endcode
 
77
 
 
78
Here are some alternate verbs for the brief statement:
 
79
\list
 
80
\li "Provides..."
 
81
\li "Specifies..."
 
82
\li "Describes..."
 
83
\endlist
 
84
 
 
85
The \e{detailed description} follows the brief and may contain images, snippet,
 
86
and link to other documentation.
 
87
 
 
88
\section1 Properties
 
89
 
 
90
The property description focuses on what the property \e does and may use the
 
91
following style:
 
92
 
 
93
Property documentation usually starts with "This property..." but for certain
 
94
properties, these are the common expressions:
 
95
\list
 
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.
 
102
\endlist
 
103
 
 
104
\section1 Signals and Handlers Documentation
 
105
 
 
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.
 
110
 
 
111
\snippet examples/qml.qdoc signals
 
112
 
 
113
These are the possible documentation styles for signals:
 
114
\list
 
115
\li "This signal is triggered when..."
 
116
\li "Triggered when..."
 
117
\li "Emitted when..."
 
118
\endlist
 
119
 
 
120
\section1 Methods and JavaScript Functions
 
121
 
 
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.
 
126
 
 
127
The function documentation starts with a verb, indicating the operation the
 
128
function performs.
 
129
 
 
130
\snippet examples/qml.qdoc function
 
131
 
 
132
Some common verbs for function documentation:
 
133
\list
 
134
\li "Copies..." - for constructors
 
135
\li "Destroys..." - for destructors
 
136
\li "Returns..." - for accessor functions
 
137
\endlist
 
138
 
 
139
The function documentation must document:
 
140
\list
 
141
\li the return type
 
142
\li the parameters
 
143
\li the actions of the functions
 
144
\endlist
 
145
 
 
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.
 
149
 
 
150
\section1 Enumerations
 
151
 
 
152
QML enumerations are documented as QML properties with the
 
153
\l{qmlproperty-command}{\\qmlproperty} command. The type of the property
 
154
is \c enumeration.
 
155
 
 
156
\snippet examples/qml.qdoc enums
 
157
 
 
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.
 
162
 
 
163
*/
 
164