Skip to contentSkip to conversation

docs/sphinx: change default `role` to "any"

PATCH Superseded John Snow 3 participants 6 messages Sep 23, 2021

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

John Snow

author
#0 lore raw

v2 cover docs/sphinx: change default `role` to "any"

Rebased to not let the work done in removing erroneous references prior to 6.1 regress.

John Snow (2):
docs: remove non-reference uses of single backticks docs/sphinx: change default role to "any"

 docs/conf.py                           |  5 +++++
 docs/devel/fuzzing.rst                 |  9 +++++----
 docs/devel/migration.rst               | 10 +++++-----
 docs/devel/tcg-plugins.rst             |  2 +-
 docs/interop/live-block-operations.rst |  2 +-
 docs/system/guest-loader.rst           |  2 +-
 qapi/block-core.json                   |  4 ++--
 include/qemu/module.h                  |  6 +++---
 qemu-options.hx                        |  4 ++--
 9 files changed, 25 insertions(+), 19 deletions(-)
Signature · 1 line
2.31.1
author
#1 lore raw

PATCH v2 1/2 docs: remove non-reference uses of single backticks

The single backtick markup in ReST is the "default role". Currently, Sphinx's default role is called "content". Sphinx suggests you can use the "Any" role instead to turn any single-backtick enclosed item into a cross-reference.

This is useful for things like autodoc for Python docstrings, where it's often nicer to reference other types with foo instead of the more laborious :py:meth:foo. It's also useful in multi-domain cases to easily reference definitions from other Sphinx domains, such as referencing C code definitions from outside of kerneldoc comments.

Before we do that, though, we'll need to turn all existing usages of the "content" role to inline verbatim markup wherever it does not correctly resolve into a cross-refernece by using double backticks instead.

---
 docs/devel/fuzzing.rst                 |  9 +++++----
 docs/devel/migration.rst               | 10 +++++-----
 docs/devel/tcg-plugins.rst             |  2 +-
 docs/interop/live-block-operations.rst |  2 +-
 docs/system/guest-loader.rst           |  2 +-
 qapi/block-core.json                   |  4 ++--
 include/qemu/module.h                  |  6 +++---
 qemu-options.hx                        |  4 ++--
 8 files changed, 20 insertions(+), 19 deletions(-)
docs/devel/fuzzing.rst +5 -4
index 2749bb9bed3..d5fe9314c65 100644
@@ -182,10 +182,11 @@ The output should contain a complete list of matched MemoryRegions.
 
 OSS-Fuzz
 --------
-QEMU is continuously fuzzed on `OSS-Fuzz` __(https://github.com/google/oss-fuzz).
-By default, the OSS-Fuzz build will try to fuzz every fuzz-target. Since the
-generic-fuzz target requires additional information provided in environment
-variables, we pre-define some generic-fuzz configs in
+QEMU is continuously fuzzed on ``OSS-Fuzz``
+__(https://github.com/google/oss-fuzz).  By default, the OSS-Fuzz build
+will try to fuzz every fuzz-target. Since the generic-fuzz target
+requires additional information provided in environment variables, we
+pre-define some generic-fuzz configs in
 ``tests/qtest/fuzz/generic_fuzz_configs.h``. Each config must specify:
 
 - ``.name``: To identify the fuzzer config
docs/devel/migration.rst +5 -5
index 24012534827..6b1230f2d7f 100644
@@ -403,8 +403,8 @@ version_id.  And the function ``load_state_old()`` (if present) is able to
 load state from minimum_version_id_old to minimum_version_id.  This
 function is deprecated and will be removed when no more users are left.
 
-There are *_V* forms of many ``VMSTATE_`` macros to load fields for version dependent fields,
-e.g.
+There are *_V* forms of many ``VMSTATE_`` macros to load fields for
+version dependent fields, e.g.
 
 .. code:: c
 
@@ -819,9 +819,9 @@ Postcopy now works with hugetlbfs backed memory:
 Postcopy with shared memory
 ---------------------------
 
-Postcopy migration with shared memory needs explicit support from the other
-processes that share memory and from QEMU. There are restrictions on the type of
-memory that userfault can support shared.
+Postcopy migration with shared memory needs explicit support from the
+other processes that share memory and from QEMU. There are restrictions
+on the type of memory that userfault can support shared.
 
 The Linux kernel userfault support works on ``/dev/shm`` memory and on ``hugetlbfs``
 (although the kernel doesn't provide an equivalent to ``madvise(MADV_DONTNEED)``
docs/devel/tcg-plugins.rst +1 -1
index dac5101a3c9..8bffff187f8 100644
@@ -212,7 +212,7 @@ The hotpages plugin can be configured using the following arguments:
 
 This is an instruction classifier so can be used to count different
 types of instructions. It has a number of options to refine which get
-counted. You can give a value to the `count` argument for a class of
+counted. You can give a value to the ``count`` argument for a class of
 instructions to break it down fully, so for example to see all the system
 registers accesses::
 
docs/interop/live-block-operations.rst +1 -1
index 9e3635b2338..814c29bbe1d 100644
@@ -640,7 +640,7 @@ at this point:
         (QEMU) block-job-complete device=job0
 
 In either of the above cases, if you once again run the
-`query-block-jobs` command, there should not be any active block
+``query-block-jobs`` command, there should not be any active block
 operation.
 
 Comparing 'commit' and 'mirror': In both then cases, the overlay images
docs/system/guest-loader.rst +1 -1
index 4320d1183f7..9ef9776bf07 100644
@@ -51,4 +51,4 @@ The full syntax of the guest-loader is::
 
 ``bootargs=<args>``
   This is an optional field for kernel blobs which will pass command
-  like via the `/chosen/module@<addr>/bootargs` node.
+  like via the ``/chosen/module@<addr>/bootargs`` node.
qapi/block-core.json +2 -2
index c8ce1d9d5d8..0c64470edb2 100644
@@ -446,11 +446,11 @@
 # @granularity: granularity of the dirty bitmap in bytes (since 1.4)
 #
 # @recording: true if the bitmap is recording new writes from the guest.
-#             Replaces `active` and `disabled` statuses. (since 4.0)
+#             Replaces ``active`` and ``disabled`` statuses. (since 4.0)
 #
 # @busy: true if the bitmap is in-use by some operation (NBD or jobs)
 #        and cannot be modified via QMP or used by another operation.
-#        Replaces `locked` and `frozen` statuses. (since 4.0)
+#        Replaces ``locked`` and ``frozen`` statuses. (since 4.0)
 #
 # @persistent: true if the bitmap was stored on disk, is scheduled to be stored
 #              on disk, or both. (since 4.0)
include/qemu/module.h +3 -3
index 3deac0078b9..5fcc323b2a7 100644
@@ -77,14 +77,14 @@ void module_allow_arch(const char *arch);
 /**
  * DOC: module info annotation macros
  *
- * `scripts/modinfo-collect.py` will collect module info,
+ * ``scripts/modinfo-collect.py`` will collect module info,
  * using the preprocessor and -DQEMU_MODINFO.
  *
- * `scripts/modinfo-generate.py` will create a module meta-data database
+ * ``scripts/modinfo-generate.py`` will create a module meta-data database
  * from the collected information so qemu knows about module
  * dependencies and QOM objects implemented by modules.
  *
- * See `*.modinfo` and `modinfo.c` in the build directory to check the
+ * See ``*.modinfo`` and ``modinfo.c`` in the build directory to check the
  * script results.
  */
 #ifdef QEMU_MODINFO
qemu-options.hx +2 -2
index 8f603cc7e65..757ac6f2037 100644
@@ -1881,8 +1881,8 @@ SRST
         Valid parameters are:
 
         ``grab-mod=<mods>`` : Used to select the modifier keys for toggling
-        the mouse grabbing in conjunction with the "g" key. `<mods>` can be
-        either `lshift-lctrl-lalt` or `rctrl`.
+        the mouse grabbing in conjunction with the "g" key. ``<mods>`` can be
+        either ``lshift-lctrl-lalt`` or ``rctrl``.
 
         ``alt_grab=on|off`` : Use Control+Alt+Shift-g to toggle mouse grabbing.
         This parameter is deprecated - use ``grab-mod`` instead.
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH v2 1/2] docs: remove non-reference uses of single backticks

Quoted 23 lines · John Snow

The single backtick markup in ReST is the "default role". Currently, Sphinx's default role is called "content". Sphinx suggests you can use the "Any" role instead to turn any single-backtick enclosed item into a cross-reference.

This is useful for things like autodoc for Python docstrings, where it's often nicer to reference other types with foo instead of the more laborious :py:meth:foo. It's also useful in multi-domain cases to easily reference definitions from other Sphinx domains, such as referencing C code definitions from outside of kerneldoc comments.

Before we do that, though, we'll need to turn all existing usages of the "content" role to inline verbatim markup wherever it does not correctly resolve into a cross-refernece by using double backticks instead.

docs/devel/fuzzing.rst +0 -0
index 2749bb9bed3..d5fe9314c65 100644

docs/devel/fuzzing.rst The output should contain a complete list of matched MemoryRegions. · line 186

Quoted 9 lines
docs/devel/fuzzing.rst +2 -4
@@ -182,10 +182,11 @@ The output should contain a complete list of matched MemoryRegions.
 
 OSS-Fuzz
 --------
-QEMU is continuously fuzzed on `OSS-Fuzz` __(https://github.com/google/oss-fuzz).
-By default, the OSS-Fuzz build will try to fuzz every fuzz-target. Since the
-generic-fuzz target requires additional information provided in environment
-variables, we pre-define some generic-fuzz configs in
+QEMU is continuously fuzzed on ``OSS-Fuzz``
+__(https://github.com/google/oss-fuzz).  By default, the OSS-Fuzz build

This is supposed to be a link and I don't think it's intended to be fixed-width font formatting, so I don't think this is the correct syntax fix.

Quoted 11 lines
docs/devel/fuzzing.rst +3 -0
+will try to fuzz every fuzz-target. Since the generic-fuzz target
+requires additional information provided in environment variables, we
+pre-define some generic-fuzz configs in
 ``tests/qtest/fuzz/generic_fuzz_configs.h``. Each config must specify:
 
 - ``.name``: To identify the fuzzer config
docs/devel/migration.rst +0 -0
index 24012534827..6b1230f2d7f 100644

docs/devel/migration.rst version_id. And the function ``load_state_old()`` (if present) is able to · line 407

Quoted 7 lines
docs/devel/migration.rst +2 -2
@@ -403,8 +403,8 @@ version_id.  And the function ``load_state_old()`` (if present) is able to
 load state from minimum_version_id_old to minimum_version_id.  This
 function is deprecated and will be removed when no more users are left.
 
-There are *_V* forms of many ``VMSTATE_`` macros to load fields for version dependent fields,
-e.g.
+There are *_V* forms of many ``VMSTATE_`` macros to load fields for
+version dependent fields, e.g.

This doesn't seem to be changing a ... ?

docs/devel/migration.rst Postcopy now works with hugetlbfs backed memory: · line 825

Quoted 13 lines
docs/devel/migration.rst +3 -3
 .. code:: c
 
@@ -819,9 +819,9 @@ Postcopy now works with hugetlbfs backed memory:
 Postcopy with shared memory
 ---------------------------
 
-Postcopy migration with shared memory needs explicit support from the other
-processes that share memory and from QEMU. There are restrictions on the type of
-memory that userfault can support shared.
+Postcopy migration with shared memory needs explicit support from the
+other processes that share memory and from QEMU. There are restrictions
+on the type of memory that userfault can support shared.
 

This part doesn't seem to be changing any ... use ?

The rest looks OK.

thanks
-- PMM

Reviewed-by on v2 1/2
#3 lore raw

Re: [PATCH v2 1/2] docs: remove non-reference uses of single backticks

In reply to John Snow
Quoted 11 lines · John Snow

The single backtick markup in ReST is the "default role". Currently, Sphinx's default role is called "content". Sphinx suggests you can use the "Any" role instead to turn any single-backtick enclosed item into a cross-reference.

This is useful for things like autodoc for Python docstrings, where it's often nicer to reference other types with foo instead of the more laborious :py:meth:foo. It's also useful in multi-domain cases to easily reference definitions from other Sphinx domains, such as referencing C code definitions from outside of kerneldoc comments.

Quoted 5 lines

Before we do that, though, we'll need to turn all existing usages of the "content" role to inline verbatim markup wherever it does not correctly resolve into a cross-refernece by using double backticks instead.

Clear demonstration of the usefulness of patch 2/2 (these occurrences of foo wouldn't have been added if the default role was "any" because "any" errors out on invalid references).

However, it looks like there are unrelated changes:

[...]

docs/devel/migration.rst version_id. And the function ``load_state_old()`` (if present) is able to · line 407

Quoted 12 lines
docs/devel/migration.rst +2 -2
index 24012534827..6b1230f2d7f 100644
@@ -403,8 +403,8 @@ version_id.  And the function ``load_state_old()`` (if present) is able to
 load state from minimum_version_id_old to minimum_version_id.  This
 function is deprecated and will be removed when no more users are left.
 
-There are *_V* forms of many ``VMSTATE_`` macros to load fields for version dependent fields,
-e.g.
+There are *_V* forms of many ``VMSTATE_`` macros to load fields for
+version dependent fields, e.g.

Unrelated? Line wrapping change only.

docs/devel/migration.rst Postcopy now works with hugetlbfs backed memory: · line 824

Quoted 13 lines
docs/devel/migration.rst +3 -3
 .. code:: c
 
@@ -819,9 +819,9 @@ Postcopy now works with hugetlbfs backed memory:
 Postcopy with shared memory
 ---------------------------
 
-Postcopy migration with shared memory needs explicit support from the other
-processes that share memory and from QEMU. There are restrictions on the type of
-memory that userfault can support shared.
+Postcopy migration with shared memory needs explicit support from the
+other processes that share memory and from QEMU. There are restrictions
+on the type of memory that userfault can support shared.

Unrelated? Line wrapping change only.

Signature · 1 line
Eduardo
author
#4 lore raw

Re: [PATCH v2 1/2] docs: remove non-reference uses of single backticks

Quoted 60 lines · Eduardo Habkost
Quoted 11 lines · John Snow

The single backtick markup in ReST is the "default role". Currently, Sphinx's default role is called "content". Sphinx suggests you can use the "Any" role instead to turn any single-backtick enclosed item into a cross-reference.

This is useful for things like autodoc for Python docstrings, where it's often nicer to reference other types with foo instead of the more laborious :py:meth:foo. It's also useful in multi-domain cases to easily reference definitions from other Sphinx domains, such as referencing C code definitions from outside of kerneldoc comments.

Quoted 5 lines

Before we do that, though, we'll need to turn all existing usages of the "content" role to inline verbatim markup wherever it does not correctly resolve into a cross-refernece by using double backticks instead.

Clear demonstration of the usefulness of patch 2/2 (these occurrences of foo wouldn't have been added if the default role was "any" because "any" errors out on invalid references).

However, it looks like there are unrelated changes:

[...]

docs/devel/migration.rst version_id. And the function ``load_state_old()``

Quoted 5 lines
docs/devel/migration.rst +0 -0
index 24012534827..6b1230f2d7f 100644
@@ -403,8 +403,8 @@ version_id.  And the function ``load_state_old()``

(if present) is able to

docs/devel/migration.rst version_id. And the function ``load_state_old()`` (if present) is able to

Quoted 4 lines
docs/devel/migration.rst +0 -1
 load state from minimum_version_id_old to minimum_version_id.  This
 function is deprecated and will be removed when no more users are left.
 
-There are *_V* forms of many ``VMSTATE_`` macros to load fields for

version dependent fields,

docs/devel/migration.rst version_id. And the function ``load_state_old()`` (if present) is able to · line 407

Quoted 3 lines
docs/devel/migration.rst +2 -1
-e.g.
+There are *_V* forms of many ``VMSTATE_`` macros to load fields for
+version dependent fields, e.g.

Unrelated? Line wrapping change only.

docs/devel/migration.rst Postcopy now works with hugetlbfs backed memory: · line 822

Quoted 8 lines
docs/devel/migration.rst +0 -1
 .. code:: c
 
@@ -819,9 +819,9 @@ Postcopy now works with hugetlbfs backed memory:
 Postcopy with shared memory
 ---------------------------
 
-Postcopy migration with shared memory needs explicit support from the

other

docs/devel/migration.rst Postcopy now works with hugetlbfs backed memory: · line 823

Quoted 1 line
docs/devel/migration.rst +0 -1
-processes that share memory and from QEMU. There are restrictions on

the type of

docs/devel/migration.rst Postcopy now works with hugetlbfs backed memory: · line 824

Quoted 4 lines
docs/devel/migration.rst +3 -1
-memory that userfault can support shared.
+Postcopy migration with shared memory needs explicit support from the
+other processes that share memory and from QEMU. There are restrictions
+on the type of memory that userfault can support shared.

Unrelated? Line wrapping change only.

Quoted 7 lines

wrapping changes are dropped

--
Eduardo

Apologies for that -- it's bad rebase confetti. Something got merged automatically and it resulted in weird junk. Sorry for the noise.

--js

author
#5 lore raw

PATCH v2 2/2 docs/sphinx: change default role to "any"

In reply to John Snow

This interprets single-backtick syntax in all of our Sphinx docs as a cross-reference to *something*, including Python symbols.

From here on out, new uses of backticks will cause a build failure if the target cannot be referenced.

---
 docs/conf.py | 5 +++++
 1 file changed, 5 insertions(+)
docs/conf.py +5 -0
index ff6e92c6e2e..4d9f56601fc 100644
@@ -85,6 +85,11 @@
 # The master toctree document.
 master_doc = 'index'
 
+# Interpret `single-backticks` to be a cross-reference to any kind of
+# referenceable object. Unresolvable or ambiguous references will emit a
+# warning at build time.
+default_role = 'any'
+
 # General information about the project.
 project = u'QEMU'
 copyright = u'2021, The QEMU Project Developers'
Signature · 1 line
2.31.1