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{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
28For QML types defined in \c .qml files, QDoc will parse the QML and determine
29the properties, signals, and the type within the QML definition. The QDoc
30block then needs to be immediately above the declaration. For QML types
31implemented in C++, QDoc will output warnings if the C++ class documentation
32does 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
37The \l{qmltype-command}{\\qmltype} command is for QML type documentation.
38
39\snippet examples/qml.qdoc.sample qmltype
40
41The \l{nativetype-command}{\\nativetype} command accepts the C++ class which
42implements the QML type as the argument. For types implemented in QML, this
43is not needed.
44
45The \e{brief description} provides a summary for the QML type. The brief does
46not need to be a complete sentence and may start with a verb. QDoc will append
47the 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
54Here are some alternate verbs for the brief statement:
55\list
56\li "Provides..."
57\li "Specifies..."
58\li "Describes..."
59\endlist
60
61The \e{detailed description} follows the brief and may contain images, snippet,
62and link to other documentation.
63
64\section1 Properties
65
66The property description focuses on what the property \e does and may use the
67following style:
68
69Property documentation usually starts with "This property..." but for certain
70properties, 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
76are marked \c{read-only}.
77\li "Sets the..." - for properties that configure a type.
78\endlist
79
80\section1 Signals and Handlers Documentation
81
82QML signals are documented either in the QML file or in the C++ implementation
83with the \l{qmlsignal-command}{\\qmlsignal} command. Signal documentation
84must include the condition for emitting the signal, mention the corresponding
85signal handler, and document whether the signal accepts a parameter.
86
87\snippet examples/qml.qdoc.sample signals
88
89These 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
98Typically, function documentation immediately precedes the implementation of the
99function in the \c .cpp file. The \l{topic-commands}{topic command} for
100functions is \l{fn-command}{\\fn}. For functions in QML, the
101documentation must reside immediately above the function declaration.
102
103The function documentation starts with a verb, indicating the operation the
104function performs.
105
106\snippet examples/qml.qdoc.sample function
107
108Some 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
115The 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
122The \l{a-command}{\\a} command marks the parameter in the documentation.
123The return type documentation should link to the type documentation or be
124marked with the \l{c-command}{\\c} command in the case of boolean values.
125
126\section1 Enumerations
127
128QML enumerations are documented as QML properties with the
129\l{qmlproperty-command}{\\qmlproperty} command. The type of the property
130is \c enumeration. 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. If the enumeration is
137implemented in C++, the documentation may link to the corresponding C++
138enumeration. However, the QDoc comment should advise that the enumeration
139is a C++ enumeration.
140
141*/