``SRST`` starts a reStructuredText section. Following lines
are put into the documentation verbatim, and discarded from the C output.
+The alternative form ``SRST()`` is used to define a label which can
+be referenced from elsewhere in the rST documentation, when used from
+a ``.hx`` file with the ``emitrefs`` option set in its Sphinx hxtool-doc
+directive.
``ERST`` ends the documentation section started with ``SRST``,
and switches back to a C code section.
serror(file, lnum, "Invalid ARCHHEADING line")
return match.group(1)
+def parse_srst(file, lnum, line):
+ """Handle an SRST directive"""
+ # The input should be either "SRST", or "SRST(label)".
+ match = re.match(r'SRST(\((.*?)\))?', line)
+ if match is None:
+ serror(file, lnum, "Invalid SRST line")
+ return match.group(2)
+
class HxtoolDocDirective(Directive):
"""Extract rST fragments from the specified .hx file"""
required_argument = 1
optional_arguments = 1
option_spec = {
- 'hxfile': directives.unchanged_required
+ 'hxfile': directives.unchanged_required,
+ 'emitrefs': directives.flag
}
has_content = False
def run(self):
env = self.state.document.settings.env
hxfile = env.config.hxtool_srctree + '/' + self.arguments[0]
+ emitrefs = "emitrefs" in self.options
# Tell sphinx of the dependency
env.note_dependency(os.path.abspath(hxfile))
serror(hxfile, lnum, 'expected ERST, found SRST')
else:
state = HxState.RST
+ label = parse_srst(hxfile, lnum, line)
+ if emitrefs and label:
+ basename = os.path.splitext(os.path.basename(hxfile))[0]
+ rstlist.append("", hxfile, lnum - 1)
+ refline = ".. _" + basename + "-" + label + ":"
+ rstlist.append(refline, hxfile, lnum - 1)
elif directive == 'ERST':
if state == HxState.CTEXT:
serror(hxfile, lnum, 'expected SRST, found ERST')
(" ``--`` ") on the Xen command line, and does not provide the guest kernel
with an actual initramfs, which would need to listed as a second multiboot
module. For more complicated alternatives, see the command line
-documentation for the ``-initrd`` option.
+:ref:`documentation <qemu-options-initrd>` for the ``-initrd`` option.
Host OS requirements
--------------------