xref: /qemu/tests/qapi-schema/doc-good.json (revision d051d0e1)
1# -*- Mode: Python -*-
2# vim: filetype=python
3#
4# Positive QAPI doc comment tests
5
6{ 'pragma': { 'doc-required': true } }
7
8##
9# = Section
10#
11# == Subsection
12#
13# *with emphasis*
14# @var {in braces}
15#
16# * List item one
17# * Two, multiple
18#   lines
19#
20# * Three
21#   Still in list
22#
23# Not in list
24#
25# - Second list
26#   Note: still in list
27#
28# Note: not in list
29#
30# 1. Third list
31#    is numbered
32#
33# 2. another item
34#
35# Returns: the King
36# Since: the first age
37# Notes:
38#
39# 1. Lorem ipsum dolor sit amet
40#
41# 2. Ut enim ad minim veniam
42#
43# Duis aute irure dolor
44#
45# Example:
46#
47# -> in
48# <- out
49# Examples:
50# - *verbatim*
51# - {braces}
52##
53
54##
55# @Enum:
56# @one: The _one_ {and only}
57#
58# Features:
59# @enum-feat: Also _one_ {and only}
60#
61# @two is undocumented
62##
63{ 'enum': 'Enum', 'data':
64  [ { 'name': 'one', 'if': 'IFONE' }, 'two' ],
65  'features': [ 'enum-feat' ],
66  'if': 'IFCOND' }
67
68##
69# @Base:
70# @base1:
71# the first member
72##
73{ 'struct': 'Base', 'data': { 'base1': 'Enum' },
74  'if': { 'all': ['IFALL1', 'IFALL2'] } }
75
76##
77# @Variant1:
78# A paragraph
79#
80# Another paragraph (but no @var: line)
81#
82# Features:
83# @variant1-feat: a feature
84# @member-feat: a member feature
85##
86{ 'struct': 'Variant1',
87  'features': [ 'variant1-feat' ],
88  'data': { 'var1': { 'type': 'str',
89                      'features': [ 'member-feat' ],
90                      'if': 'IFSTR' } } }
91
92##
93# @Variant2:
94##
95{ 'struct': 'Variant2', 'data': {} }
96
97##
98# @Object:
99# Features:
100# @union-feat1: a feature
101##
102{ 'union': 'Object',
103  'features': [ 'union-feat1' ],
104  'base': 'Base',
105  'discriminator': 'base1',
106  'data': { 'one': 'Variant1',
107            'two': { 'type': 'Variant2',
108                     'if': { 'any': ['IFONE', 'IFTWO'] } } } }
109
110##
111# @SugaredUnion:
112# Features:
113# @union-feat2: a feature
114##
115{ 'union': 'SugaredUnion',
116  'features': [ 'union-feat2' ],
117  'data': { 'one': 'Variant1', 'two': { 'type': 'Variant2', 'if': 'IFTWO' } } }
118
119##
120# @Alternate:
121# @i: an integer
122#     @b is undocumented
123#
124# Features:
125# @alt-feat: a feature
126##
127{ 'alternate': 'Alternate',
128  'features': [ 'alt-feat' ],
129  'data': { 'i': 'int', 'b': 'bool' },
130  'if': { 'not': { 'any': [ 'IFONE', 'IFTWO' ] } } }
131
132##
133# == Another subsection
134##
135
136##
137# @cmd:
138# @arg1: the first argument
139#
140# @arg2: the second
141#        argument
142#
143# Features:
144# @cmd-feat1: a feature
145# @cmd-feat2: another feature
146# Note: @arg3 is undocumented
147# Returns: @Object
148# TODO: frobnicate
149# Notes:
150#
151# - Lorem ipsum dolor sit amet
152# - Ut enim ad minim veniam
153#
154# Duis aute irure dolor
155# Example:
156#
157# -> in
158# <- out
159# Examples:
160# - *verbatim*
161# - {braces}
162# Since: 2.10
163##
164{ 'command': 'cmd',
165  'data': { 'arg1': 'int', '*arg2': 'str', 'arg3': 'bool' },
166  'returns': 'Object',
167  'features': [ 'cmd-feat1', 'cmd-feat2' ] }
168
169##
170# @cmd-boxed:
171# If you're bored enough to read this, go see a video of boxed cats
172# Features:
173# @cmd-feat1: a feature
174# @cmd-feat2: another feature
175# Example:
176#
177# -> in
178#
179# <- out
180##
181{ 'command': 'cmd-boxed', 'boxed': true,
182  'data': 'Object',
183  'features': [ 'cmd-feat1', 'cmd-feat2' ] }
184
185##
186# @EVT_BOXED:
187# Features:
188# @feat3: a feature
189##
190{ 'event': 'EVT_BOXED',  'boxed': true,
191  'features': [ 'feat3' ],
192  'data': 'Object' }
193