Skip to content

Commit 9c66762

Browse files
jnsnowMarkus Armbruster
authored andcommitted
docs/qapi-code-gen: add cross-references
Add clickables to many places. Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210720235619.2048797-4-jsnow@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Markus Armbruster <armbru@redhat.com>
1 parent 55927c5 commit 9c66762

File tree

1 file changed

+58
-49
lines changed

1 file changed

+58
-49
lines changed

docs/devel/qapi-code-gen.rst

Lines changed: 58 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ from making a forward reference to a type that is only introduced by
156156
an outer file. The parser may be made stricter in the future to
157157
prevent incomplete include files.
158158

159+
.. _pragma:
159160

160161
Pragma directives
161162
-----------------
@@ -186,6 +187,7 @@ Pragma 'member-name-exceptions' takes a list of types whose member
186187
names may contain uppercase letters, and ``"_"`` instead of ``"-"``.
187188
Default is none.
188189

190+
.. _ENUM-VALUE:
189191

190192
Enumeration types
191193
-----------------
@@ -228,13 +230,15 @@ additional enumeration constant PREFIX__MAX with value N.
228230
Do not use string or an integer type when an enumeration type can do
229231
the job satisfactorily.
230232

231-
The optional 'if' member specifies a conditional. See "Configuring
232-
the schema" below for more on this.
233+
The optional 'if' member specifies a conditional. See `Configuring the
234+
schema`_ below for more on this.
233235

234-
The optional 'features' member specifies features. See "Features"
236+
The optional 'features' member specifies features. See Features_
235237
below for more on this.
236238

237239

240+
.. _TYPE-REF:
241+
238242
Type references and array types
239243
-------------------------------
240244

@@ -269,11 +273,13 @@ Member 'struct' names the struct type.
269273

270274
Each MEMBER of the 'data' object defines a member of the struct type.
271275

276+
.. _MEMBERS:
277+
272278
The MEMBER's STRING name consists of an optional ``*`` prefix and the
273279
struct member name. If ``*`` is present, the member is optional.
274280

275281
The MEMBER's value defines its properties, in particular its type.
276-
The form TYPE-REF is shorthand for :code:`{ 'type': TYPE-REF }`.
282+
The form TYPE-REF_ is shorthand for :code:`{ 'type': TYPE-REF }`.
277283

278284
Example::
279285

@@ -300,10 +306,10 @@ both members like this::
300306
{ "file": "/some/place/my-image",
301307
"backing": "/some/place/my-backing-file" }
302308

303-
The optional 'if' member specifies a conditional. See "Configuring
304-
the schema" below for more on this.
309+
The optional 'if' member specifies a conditional. See `Configuring
310+
the schema`_ below for more on this.
305311

306-
The optional 'features' member specifies features. See "Features"
312+
The optional 'features' member specifies features. See Features_
307313
below for more on this.
308314

309315

@@ -337,7 +343,7 @@ union must have at least one branch.
337343
The BRANCH's STRING name is the branch name.
338344

339345
The BRANCH's value defines the branch's properties, in particular its
340-
type. The form TYPE-REF is shorthand for :code:`{ 'type': TYPE-REF }`.
346+
type. The form TYPE-REF_ is shorthand for :code:`{ 'type': TYPE-REF }`.
341347

342348
A simple union type defines a mapping from automatic discriminator
343349
values to data types like in this example::
@@ -368,12 +374,12 @@ Flat unions permit arbitrary common members that occur in all variants
368374
of the union, not just a discriminator. Their discriminators need not
369375
be named 'type'. They also avoid nesting on the wire.
370376

371-
The 'base' member defines the common members. If it is a MEMBERS
377+
The 'base' member defines the common members. If it is a MEMBERS_
372378
object, it defines common members just like a struct type's 'data'
373379
member defines struct type members. If it is a STRING, it names a
374380
struct type whose members are the common members.
375381

376-
All flat union branches must be of struct type.
382+
All flat union branches must be `Struct types`_.
377383

378384
In the Client JSON Protocol, a flat union is represented by an object
379385
with the common members (from the base type) and the selected branch's
@@ -425,10 +431,10 @@ is identical on the wire to::
425431
{ 'union': 'Flat', 'base': { 'type': 'Enum' }, 'discriminator': 'type',
426432
'data': { 'one': 'Branch1', 'two': 'Branch2' } }
427433

428-
The optional 'if' member specifies a conditional. See "Configuring
429-
the schema" below for more on this.
434+
The optional 'if' member specifies a conditional. See `Configuring
435+
the schema`_ below for more on this.
430436

431-
The optional 'features' member specifies features. See "Features"
437+
The optional 'features' member specifies features. See Features_
432438
below for more on this.
433439

434440

@@ -481,10 +487,10 @@ following example objects::
481487
"read-only": false,
482488
"filename": "/tmp/mydisk.qcow2" } }
483489

484-
The optional 'if' member specifies a conditional. See "Configuring
485-
the schema" below for more on this.
490+
The optional 'if' member specifies a conditional. See `Configuring
491+
the schema`_ below for more on this.
486492

487-
The optional 'features' member specifies features. See "Features"
493+
The optional 'features' member specifies features. See Features_
488494
below for more on this.
489495

490496

@@ -511,10 +517,10 @@ Syntax::
511517

512518
Member 'command' names the command.
513519

514-
Member 'data' defines the arguments. It defaults to an empty MEMBERS
520+
Member 'data' defines the arguments. It defaults to an empty MEMBERS_
515521
object.
516522

517-
If 'data' is a MEMBERS object, then MEMBERS defines arguments just
523+
If 'data' is a MEMBERS_ object, then MEMBERS defines arguments just
518524
like a struct type's 'data' defines struct type members.
519525

520526
If 'data' is a STRING, then STRING names a complex type whose members
@@ -553,7 +559,7 @@ which would validate this Client JSON Protocol transaction::
553559

554560
The generator emits a prototype for the C function implementing the
555561
command. The function itself needs to be written by hand. See
556-
section "Code generated for commands" for examples.
562+
section `Code generated for commands`_ for examples.
557563

558564
The function returns the return type. When member 'boxed' is absent,
559565
it takes the command arguments as arguments one by one, in QAPI schema
@@ -660,10 +666,10 @@ for a command. We don't currently have a use case for both together and
660666
without a use case, it's not entirely clear what the semantics should
661667
be.
662668

663-
The optional 'if' member specifies a conditional. See "Configuring
664-
the schema" below for more on this.
669+
The optional 'if' member specifies a conditional. See `Configuring
670+
the schema`_ below for more on this.
665671

666-
The optional 'features' member specifies features. See "Features"
672+
The optional 'features' member specifies features. See Features_
667673
below for more on this.
668674

669675

@@ -708,15 +714,17 @@ Resulting in this JSON object::
708714
The generator emits a function to send the event. When member 'boxed'
709715
is absent, it takes event-specific data one by one, in QAPI schema
710716
order. Else it takes them wrapped in the C struct generated for the
711-
complex type. See section "Code generated for events" for examples.
717+
complex type. See section `Code generated for events`_ for examples.
712718

713-
The optional 'if' member specifies a conditional. See "Configuring
714-
the schema" below for more on this.
719+
The optional 'if' member specifies a conditional. See `Configuring
720+
the schema`_ below for more on this.
715721

716-
The optional 'features' member specifies features. See "Features"
722+
The optional 'features' member specifies features. See Features_
717723
below for more on this.
718724

719725

726+
.. _FEATURE:
727+
720728
Features
721729
--------
722730

@@ -735,8 +743,8 @@ For this purpose, a list of features can be specified for a command or
735743
struct type. Each list member can either be ``{ 'name': STRING, '*if':
736744
COND }``, or STRING, which is shorthand for ``{ 'name': STRING }``.
737745

738-
The optional 'if' member specifies a conditional. See "Configuring
739-
the schema" below for more on this.
746+
The optional 'if' member specifies a conditional. See `Configuring
747+
the schema`_ below for more on this.
740748

741749
Example::
742750

@@ -745,7 +753,7 @@ Example::
745753
'features': [ 'allow-negative-numbers' ] }
746754

747755
The feature strings are exposed to clients in introspection, as
748-
explained in section "Client JSON Protocol introspection".
756+
explained in section `Client JSON Protocol introspection`_.
749757

750758
Intended use is to have each feature string signal that this build of
751759
QEMU shows a certain behaviour.
@@ -764,7 +772,7 @@ Naming rules and reserved names
764772
All names must begin with a letter, and contain only ASCII letters,
765773
digits, hyphen, and underscore. There are two exceptions: enum values
766774
may start with a digit, and names that are downstream extensions (see
767-
section Downstream extensions) start with underscore.
775+
section `Downstream extensions`_) start with underscore.
768776

769777
Names beginning with ``q_`` are reserved for the generator, which uses
770778
them for munging QMP names that resemble C keywords or other
@@ -794,8 +802,9 @@ Any name (command, event, type, member, or enum value) beginning with
794802
``x-`` is marked experimental, and may be withdrawn or changed
795803
incompatibly in a future release.
796804

797-
Pragmas ``command-name-exceptions`` and ``member-name-exceptions`` let you
798-
violate naming rules. Use for new code is strongly discouraged.
805+
Pragmas ``command-name-exceptions`` and ``member-name-exceptions`` let
806+
you violate naming rules. Use for new code is strongly discouraged. See
807+
`Pragma directives`_ for details.
799808

800809

801810
Downstream extensions
@@ -851,7 +860,7 @@ member 'bar' ::
851860
A union's discriminator may not be conditional.
852861

853862
Likewise, individual enumeration values be conditional. This requires
854-
the longhand form of ENUM-VALUE.
863+
the longhand form of ENUM-VALUE_.
855864

856865
Example: an enum type with unconditional value 'foo' and conditional
857866
value 'bar' ::
@@ -861,7 +870,7 @@ value 'bar' ::
861870
{ 'name' : 'bar', 'if': 'defined(IFCOND)' } ] }
862871

863872
Likewise, features can be conditional. This requires the longhand
864-
form of FEATURE.
873+
form of FEATURE_.
865874

866875
Example: a struct with conditional feature 'allow-negative-numbers' ::
867876

@@ -893,7 +902,7 @@ If the documentation comment starts like ::
893902
it documents the definition of SYMBOL, else it's free-form
894903
documentation.
895904

896-
See below for more on definition documentation.
905+
See below for more on `Definition documentation`_.
897906

898907
Free-form documentation may be used to provide additional text and
899908
structuring content.
@@ -984,7 +993,7 @@ Definition documentation
984993
Definition documentation, if present, must immediately precede the
985994
definition it documents.
986995

987-
When documentation is required (see pragma 'doc-required'), every
996+
When documentation is required (see pragma_ 'doc-required'), every
988997
definition must have documentation.
989998

990999
Definition documentation starts with a line naming the definition,
@@ -1181,7 +1190,7 @@ the wire then.
11811190
Each command or event defined with 'data' as MEMBERS object in the
11821191
QAPI schema implicitly defines an object type.
11831192

1184-
Example: the SchemaInfo for EVENT_C from section Events ::
1193+
Example: the SchemaInfo for EVENT_C from section Events_ ::
11851194

11861195
{ "name": "EVENT_C", "meta-type": "event",
11871196
"arg-type": "q_obj-EVENT_C-arg" }
@@ -1205,7 +1214,7 @@ extensions. The "members" array is in no particular order; clients
12051214
must search the entire object when learning whether a particular
12061215
member is supported.
12071216

1208-
Example: the SchemaInfo for MyType from section Struct types ::
1217+
Example: the SchemaInfo for MyType from section `Struct types`_ ::
12091218

12101219
{ "name": "MyType", "meta-type": "object",
12111220
"members": [
@@ -1216,7 +1225,7 @@ Example: the SchemaInfo for MyType from section Struct types ::
12161225
"features" exposes the command's feature strings as a JSON array of
12171226
strings.
12181227

1219-
Example: the SchemaInfo for TestType from section Features::
1228+
Example: the SchemaInfo for TestType from section Features_::
12201229

12211230
{ "name": "TestType", "meta-type": "object",
12221231
"members": [
@@ -1232,7 +1241,7 @@ that provides the variant members for this type tag value). The
12321241
list cases in the same order as the corresponding "tag" enum type.
12331242

12341243
Example: the SchemaInfo for flat union BlockdevOptions from section
1235-
Union types ::
1244+
`Union types`_ ::
12361245

12371246
{ "name": "BlockdevOptions", "meta-type": "object",
12381247
"members": [
@@ -1247,13 +1256,13 @@ Note that base types are "flattened": its members are included in the
12471256
"members" array.
12481257

12491258
A simple union implicitly defines an enumeration type for its implicit
1250-
discriminator (called "type" on the wire, see section Union types).
1259+
discriminator (called "type" on the wire, see section `Union types`_).
12511260

12521261
A simple union implicitly defines an object type for each of its
12531262
variants.
12541263

12551264
Example: the SchemaInfo for simple union BlockdevOptionsSimple from section
1256-
Union types ::
1265+
`Union types`_ ::
12571266

12581267
{ "name": "BlockdevOptionsSimple", "meta-type": "object",
12591268
"members": [
@@ -1273,7 +1282,7 @@ a JSON object with member "type", which names a type. Values of the
12731282
alternate type conform to exactly one of its member types. There is
12741283
no guarantee on the order in which "members" will be listed.
12751284

1276-
Example: the SchemaInfo for BlockdevRef from section Alternate types ::
1285+
Example: the SchemaInfo for BlockdevRef from section `Alternate types`_ ::
12771286

12781287
{ "name": "BlockdevRef", "meta-type": "alternate",
12791288
"members": [
@@ -1297,13 +1306,13 @@ variant member "values". The values are listed in no particular
12971306
order; clients must search the entire enum when learning whether a
12981307
particular value is supported.
12991308

1300-
Example: the SchemaInfo for MyEnum from section Enumeration types ::
1309+
Example: the SchemaInfo for MyEnum from section `Enumeration types`_ ::
13011310

13021311
{ "name": "MyEnum", "meta-type": "enum",
13031312
"values": [ "value1", "value2", "value3" ] }
13041313

13051314
The SchemaInfo for a built-in type has the same name as the type in
1306-
the QAPI schema (see section Built-in Types), with one exception
1315+
the QAPI schema (see section `Built-in Types`_), with one exception
13071316
detailed below. It has variant member "json-type" that shows how
13081317
values of this type are encoded on the wire.
13091318

@@ -1505,7 +1514,7 @@ Example::
15051514

15061515
[Uninteresting stuff omitted...]
15071516

1508-
For a modular QAPI schema (see section Include directives), code for
1517+
For a modular QAPI schema (see section `Include directives`_), code for
15091518
each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
15101519

15111520
SUBDIR/$(prefix)qapi-types-SUBMODULE.h
@@ -1643,7 +1652,7 @@ Example::
16431652

16441653
[Uninteresting stuff omitted...]
16451654

1646-
For a modular QAPI schema (see section Include directives), code for
1655+
For a modular QAPI schema (see section `Include directives`_), code for
16471656
each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
16481657

16491658
SUBDIR/$(prefix)qapi-visit-SUBMODULE.h
@@ -1773,7 +1782,7 @@ Example::
17731782
}
17741783
[Uninteresting stuff omitted...]
17751784

1776-
For a modular QAPI schema (see section Include directives), code for
1785+
For a modular QAPI schema (see section `Include directives`_), code for
17771786
each sub-module SUBDIR/SUBMODULE.json is actually generated into::
17781787

17791788
SUBDIR/$(prefix)qapi-commands-SUBMODULE.h
@@ -1862,7 +1871,7 @@ Example::
18621871

18631872
[Uninteresting stuff omitted...]
18641873

1865-
For a modular QAPI schema (see section Include directives), code for
1874+
For a modular QAPI schema (see section `Include directives`_), code for
18661875
each sub-module SUBDIR/SUBMODULE.json is actually generated into ::
18671876

18681877
SUBDIR/$(prefix)qapi-events-SUBMODULE.h

0 commit comments

Comments
 (0)