Skip to contentSkip to conversation

Syncing documentation vs. -help vs. qemu_options table

RFC PATCH New Blue Swirl 1 participant 1 message Mar 10, 2009 Kbuild

lore
Share & tools
lore

Blue Swirl

author
#0 lore raw

RFC PATCH 1/1 Syncing documentation vs. -help vs. qemu_options table

Hi,

It would be nice if the documentation about command line switches, -help text and qemu_options table would be kept more easily in sync.

In true Qemu tradition, this solution uses an include file that is parsed once for getting the enums, another time for getopt tables and third time for help message. Documentation for options is generated from the same file with CPP.

The advantage is that all stuff is in a single location, so developers are less likely to forget to update docs when adding new switches.

I made a reference implementation using the -parallel switch as a an example.

The new system could be introduced gradually, starting from this patch and then converting the options.

Comments?

Makefile +7 -4
Index: qemu/Makefile
===================================================================
@@ -283,13 +283,16 @@
 
 # documentation
 %.html: %.texi
-	texi2html -monolithic -number $<
+	texi2html -I=. -monolithic -number $<
 
 %.info: %.texi
-	makeinfo $< -o $@
+	makeinfo -I . $< -o $@
 
 %.dvi: %.texi
-	texi2dvi $<
+	texi2dvi -I . $<
+
+qemu-options.texi: options.c
+	cpp $< | egrep -v '^#.*' > $@
 
 qemu.1: qemu-doc.texi
 	perl -Ww -- $(SRC_PATH)/texi2pod.pl $< qemu.pod
@@ -309,7 +312,7 @@
 
 html: qemu-doc.html qemu-tech.html
 
-qemu-doc.dvi qemu-doc.html qemu-doc.info: qemu-img.texi qemu-nbd.texi
+qemu-doc.dvi qemu-doc.html qemu-doc.info: qemu-img.texi qemu-nbd.texi qemu-options.texi
 
 VERSION ?= $(shell cat VERSION)
 FILE = qemu-$(VERSION)
options.c new file +19 -0
Index: qemu/options.c
===================================================================
@@ -0,0 +1,19 @@
+#ifndef DEF
+#define DEF(option, opt_arg, opt_enum, opt_help)
+#define GEN_DOCS
+#endif
+
+DEF("parallel", HAS_ARG, QEMU_OPTION_parallel,                          \
+    "-parallel dev   redirect the parallel port to char device 'dev'\n")
+#ifdef GEN_DOCS
+@item -parallel @var{dev}
+Redirect the virtual parallel port to host device @var{dev} (same
+devices as the serial port). On Linux hosts, @file{/dev/parportN} can
+be used to use hardware devices connected on the corresponding host
+parallel port.
+
+This option can be used several times to simulate up to 3 parallel
+ports.
+
+Use @code{-parallel none} to disable all parallel ports.
+#endif
qemu-doc.texi +1 -10
Index: qemu/qemu-doc.texi
===================================================================
@@ -1073,16 +1073,7 @@
 
 @end table
 
-@item -parallel @var{dev}
-Redirect the virtual parallel port to host device @var{dev} (same
-devices as the serial port). On Linux hosts, @file{/dev/parportN} can
-be used to use hardware devices connected on the corresponding host
-parallel port.
-
-This option can be used several times to simulate up to 3 parallel
-ports.
-
-Use @code{-parallel none} to disable all parallel ports.
+@include qemu-options.texi
 
 @item -monitor @var{dev}
 Redirect the monitor to host device @var{dev} (same devices as the
vl.c +12 -3
Index: qemu/vl.c
===================================================================
@@ -4057,7 +4057,10 @@
            "\n"
            "Debug/Expert options:\n"
            "-serial dev     redirect the serial port to char device 'dev'\n"
-           "-parallel dev   redirect the parallel port to char device 'dev'\n"
+#define DEF(option, opt_arg, opt_enum, opt_help)        \
+           opt_help
+#include "options.c"
+#undef DEF
            "-monitor dev    redirect the monitor to char device 'dev'\n"
            "-pidfile file   write PID to 'file'\n"
            "-S              freeze CPU at startup (use 'c' to start execution)\n"
@@ -4197,7 +4200,10 @@
 
     /* Debug/Expert options: */
     QEMU_OPTION_serial,
-    QEMU_OPTION_parallel,
+#define DEF(option, opt_arg, opt_enum, opt_help)        \
+    opt_enum,
+#include "options.c"
+#undef DEF
     QEMU_OPTION_monitor,
     QEMU_OPTION_pidfile,
     QEMU_OPTION_S,
@@ -4319,7 +4325,10 @@
 
     /* Debug/Expert options: */
     { "serial", HAS_ARG, QEMU_OPTION_serial },
-    { "parallel", HAS_ARG, QEMU_OPTION_parallel },
+#define DEF(option, opt_arg, opt_enum, opt_help)        \
+    { option, opt_arg, opt_enum },
+#include "options.c"
+#undef DEF
     { "monitor", HAS_ARG, QEMU_OPTION_monitor },
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
     { "S", 0, QEMU_OPTION_S },