2
0

docs.rst 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ==================
  2. QEMU Documentation
  3. ==================
  4. QEMU's documentation is written in reStructuredText format and
  5. built using the Sphinx documentation generator. We generate both
  6. the HTML manual and the manpages from the some documentation sources.
  7. hxtool and .hx files
  8. --------------------
  9. The documentation for QEMU command line options and Human Monitor Protocol
  10. (HMP) commands is written in files with the ``.hx`` suffix. These
  11. are processed in two ways:
  12. * ``scripts/hxtool`` creates C header files from them, which are included
  13. in QEMU to do things like handle the ``--help`` option output
  14. * a Sphinx extension in ``docs/sphinx/hxtool.py`` generates rST output
  15. to be included in the HTML or manpage documentation
  16. The syntax of these ``.hx`` files is simple. It is broadly an
  17. alternation of C code put into the C output and rST format text
  18. put into the documentation. A few special directives are recognised;
  19. these are all-caps and must be at the beginning of the line.
  20. ``HXCOMM`` is the comment marker. The line, including any arbitrary
  21. text after the marker, is discarded and appears neither in the C output
  22. nor the documentation output.
  23. ``SRST`` starts a reStructuredText section. Following lines
  24. are put into the documentation verbatim, and discarded from the C output.
  25. The alternative form ``SRST()`` is used to define a label which can be
  26. referenced from elsewhere in the rST documentation. The label will take
  27. the form ``<DOCNAME-HXFILE-LABEL>``, where ``DOCNAME`` is the name of the
  28. top level rST file, ``HXFILE`` is the filename of the .hx file without
  29. the ``.hx`` extension, and ``LABEL`` is the text provided within the
  30. ``SRST()`` directive. For example,
  31. ``<system/invocation-qemu-options-initrd>``.
  32. ``ERST`` ends the documentation section started with ``SRST``,
  33. and switches back to a C code section.
  34. ``DEFHEADING()`` defines a heading that should appear in both the
  35. ``--help`` output and in the documentation. This directive should
  36. be in the C code block. If there is a string inside the brackets,
  37. this is the heading to use. If this string is empty, it produces
  38. a blank line in the ``--help`` output and is ignored for the rST
  39. output.
  40. ``ARCHHEADING()`` is a variant of ``DEFHEADING()`` which produces
  41. the heading only if the specified guest architecture was compiled
  42. into QEMU. This should be avoided in new documentation.
  43. Within C code sections, you should check the comments at the top
  44. of the file to see what the expected usage is, because this
  45. varies between files. For instance in ``qemu-options.hx`` we use
  46. the ``DEF()`` macro to define each option and specify its ``--help``
  47. text, but in ``hmp-commands.hx`` the C code sections are elements
  48. of an array of structs of type ``HMPCommand`` which define the
  49. name, behaviour and help text for each monitor command.
  50. In the file ``qemu-options.hx``, do not try to explicitly define a
  51. reStructuredText label within a documentation section. This file
  52. is included into two separate Sphinx documents, and some
  53. versions of Sphinx will complain about the duplicate label
  54. that results. Use the ``SRST()`` directive documented above, to
  55. emit an unambiguous label.