@@ -385,13 +385,13 @@ Type names in references can be surrounded by brackets, like
385
385
``[typename] ``, to indicate an array of that type. The cross-reference
386
386
will apply only to the type name between the brackets. For example;
387
387
``:qapi:type:`[Qcow2BitmapInfoFlags]` `` renders to:
388
- :qapi:type: `[Qcow2BitmapInfoFlags] `
388
+ :qapi:type: `[QMP: Qcow2BitmapInfoFlags] `
389
389
390
390
To indicate an optional argument/member in a field list, the type name
391
391
can be suffixed with ``? ``. The cross-reference will be transformed to
392
392
"type, Optional" with the link applying only to the type name. For
393
393
example; ``:qapi:type:`BitmapSyncMode?` `` renders to:
394
- :qapi:type: `BitmapSyncMode? `
394
+ :qapi:type: `QMP: BitmapSyncMode? `
395
395
396
396
397
397
Namespaces
@@ -400,17 +400,38 @@ Namespaces
400
400
Mimicking the `Python domain target specification syntax
401
401
<https://www.sphinx-doc.org/en/master/usage/domains/python.html#target-specification> `_,
402
402
QAPI allows you to specify the fully qualified path for a data
403
- type. QAPI enforces globally unique names, so it's unlikely you'll need
404
- this specific feature, but it may be extended in the near future to
405
- allow referencing identically named commands and data types from
406
- different utilities; i.e. QEMU Storage Daemon vs QMP.
403
+ type.
407
404
405
+ * A namespace can be explicitly provided;
406
+ e.g. ``:qapi:type:`QMP:BitmapSyncMode ``
408
407
* A module can be explicitly provided;
409
- ``:qapi:type:`block-core.BitmapSyncMode` `` will render to:
410
- :qapi:type: `block-core.BitmapSyncMode `
408
+ ``:qapi:type:`QMP: block-core.BitmapSyncMode` `` will render to:
409
+ :qapi:type: `QMP: block-core.BitmapSyncMode `
411
410
* If you don't want to display the "fully qualified" name, it can be
412
- prefixed with a tilde; ``:qapi:type:`~block-core.BitmapSyncMode` ``
413
- will render to: :qapi:type: `~block-core.BitmapSyncMode `
411
+ prefixed with a tilde; ``:qapi:type:`~QMP:block-core.BitmapSyncMode` ``
412
+ will render to: :qapi:type: `~QMP:block-core.BitmapSyncMode `
413
+
414
+
415
+ Target resolution
416
+ -----------------
417
+
418
+ Any cross-reference to a QAPI type, whether using the ```any` `` style of
419
+ reference or the more explicit ```:qapi:any:`target` `` syntax, allows
420
+ for the presence or absence of either the namespace or module
421
+ information.
422
+
423
+ When absent, their value will be inferred from context by the presence
424
+ of any ``qapi:namespace `` or ``qapi:module `` directives preceding the
425
+ cross-reference.
426
+
427
+ If no results are found when using the inferred values, other
428
+ namespaces/modules will be searched as a last resort; but any explicitly
429
+ provided values must always match in order to succeed.
430
+
431
+ This allows for efficient cross-referencing with a minimum of syntax in
432
+ the large majority of cases, but additional context or namespace markup
433
+ may be required outside of the QAPI reference documents when linking to
434
+ items that share a name across multiple documented QAPI schema.
414
435
415
436
416
437
Custom link text
@@ -423,7 +444,7 @@ using the ``custom text <target>`` syntax.
423
444
424
445
For example, ``:qapi:cmd:`Merge dirty bitmaps
425
446
<block-dirty-bitmap-merge>` `` will render as: :qapi:cmd: `Merge dirty
426
- bitmaps <block-dirty-bitmap-merge> `
447
+ bitmaps <QMP: block-dirty-bitmap-merge> `
427
448
428
449
429
450
Directives
@@ -464,8 +485,11 @@ removed in a future version.
464
485
QAPI standard options
465
486
---------------------
466
487
467
- All QAPI directives -- *except * for module -- support these common options.
488
+ All QAPI directives -- *except * for namespace and module -- support
489
+ these common options.
468
490
491
+ * ``:namespace: name `` -- This option allows you to override the
492
+ namespace association of a given definition.
469
493
* ``:module: modname `` -- Borrowed from the Python domain, this option allows
470
494
you to override the module association of a given definition.
471
495
* ``:since: x.y `` -- Allows the documenting of "Since" information, which is
@@ -480,6 +504,28 @@ All QAPI directives -- *except* for module -- support these common options.
480
504
production code.
481
505
482
506
507
+ qapi:namespace
508
+ --------------
509
+
510
+ The ``qapi:namespace `` directive marks the start of a QAPI namespace. It
511
+ does not take a content body, nor any options. All subsequent QAPI
512
+ directives are associated with the most recent namespace. This affects
513
+ the definition's "fully qualified name", allowing two different
514
+ namespaces to create an otherwise identically named definition.
515
+
516
+ This directive also influences how reference resolution works for any
517
+ references that do not explicity specify a namespace, so this directive
518
+ can be used to nudge references into preferring targets from within that
519
+ namespace.
520
+
521
+ Example::
522
+
523
+ .. qapi:namespace:: QMP
524
+
525
+
526
+ This directive has no visible effect.
527
+
528
+
483
529
qapi:module
484
530
-----------
485
531
0 commit comments