diff mbox

[5/5] build-sys: generate QAPI doc based on json

Message ID 1435917064-17827-6-git-send-email-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 3, 2015, 9:51 a.m. UTC
Learn to generate info/html/pdf/man documentation for QEMU and agent QMP
APIs.

This allows to provide missing agent documentation, and should help
getting rid of the duplicate documentation in qmp-commands.hx.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 Makefile | 35 ++++++++++++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 5 deletions(-)

Comments

Eric Blake July 27, 2015, 10:38 p.m. UTC | #1
On 07/03/2015 03:51 AM, Marc-André Lureau wrote:
> Learn to generate info/html/pdf/man documentation for QEMU and agent QMP
> APIs.
> 
> This allows to provide missing agent documentation, and should help

s/allows to provide/provides/

> getting rid of the duplicate documentation in qmp-commands.hx.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  Makefile | 35 ++++++++++++++++++++++++++++++-----
>  1 file changed, 30 insertions(+), 5 deletions(-)
> 
> @@ -354,7 +356,7 @@ distclean: clean
>  	rm -f qemu-doc.vr
>  	rm -f config.log
>  	rm -f linux-headers/asm
> -	rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
> +	rm -f qemu-{tech,qapi,ga-qapi}.{info,aux,cp,dvi,fn,info,.ky,log,pdf,pg,toc,tp,vr}

{} expansion is a bashism; it will probably fail to do what you meant on
systems where /bin/sh is dash.  But you could probably come up with
makefile $() functions to generate the same sort of compact
representation in the Makefile without relying on bashism. (Hmm, $(join)
isn't pairwise, and $(addprefix) only adds a single prefix; I'm not sure
offhand how to get all possible pairwise combinations of two lists...)
diff mbox

Patch

diff --git a/Makefile b/Makefile
index c9be643..c176650 100644
--- a/Makefile
+++ b/Makefile
@@ -89,6 +89,7 @@  HELPERS-$(CONFIG_LINUX) = qemu-bridge-helper$(EXESUF)
 
 ifdef BUILD_DOCS
 DOCS=qemu-doc.html qemu-tech.html qemu.1 qemu-img.1 qemu-nbd.8 qmp-commands.txt
+DOCS+=qemu-qapi.7 qemu-ga-qapi.7
 ifdef CONFIG_LINUX
 DOCS+=kvm_stat.1
 endif
@@ -244,6 +245,7 @@  qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
 gen-out-type = $(subst .,-,$(suffix $@))
 
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
+qapi-py += $(SRC_PATH)/scripts/qapi2texi.py
 
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
@@ -354,7 +356,7 @@  distclean: clean
 	rm -f qemu-doc.vr
 	rm -f config.log
 	rm -f linux-headers/asm
-	rm -f qemu-tech.info qemu-tech.aux qemu-tech.cp qemu-tech.dvi qemu-tech.fn qemu-tech.info qemu-tech.ky qemu-tech.log qemu-tech.pdf qemu-tech.pg qemu-tech.toc qemu-tech.tp qemu-tech.vr
+	rm -f qemu-{tech,qapi,ga-qapi}.{info,aux,cp,dvi,fn,info,.ky,log,pdf,pg,toc,tp,vr}
 	for d in $(TARGET_DIRS); do \
 	rm -rf $$d || exit 1 ; \
         done
@@ -399,6 +401,7 @@  ifneq ($(TOOLS),)
 	$(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
 	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
 	$(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
+	$(INSTALL_DATA) qemu-qapi.7 qemu-ga-qapi.7 "$(DESTDIR)$(mandir)/man7"
 endif
 endif
 ifdef CONFIG_VIRTFS
@@ -514,6 +517,16 @@  qmp-commands.txt: $(SRC_PATH)/qmp-commands.hx
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"  GEN   $@")
 
+qemu-qapi.texi: $(qapi-modules) $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py \
+	"QEMU QAPI Reference Manual" $(VERSION) qemu-qapi \
+	$< > $@,"  GEN   $@")
+
+qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py \
+	"QEMU Guest Agent API Reference Manual" $(VERSION) qemu-ga-qapi \
+	$< > $@,"  GEN   $@")
+
 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi
 	$(call quiet-command, \
 	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu.pod && \
@@ -538,16 +551,28 @@  qemu-nbd.8: qemu-nbd.texi
 	  $(POD2MAN) --section=8 --center=" " --release=" " qemu-nbd.pod > $@, \
 	  "  GEN   $@")
 
+qemu-qapi.7: qemu-qapi.texi
+	$(call quiet-command, \
+	perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-qapi.pod && \
+	$(POD2MAN) --section=7 --center=" " --release=" " qemu-qapi.pod > $@, \
+	"  GEN   $@")
+
+qemu-ga-qapi.7: qemu-ga-qapi.texi
+	$(call quiet-command, \
+	perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< qemu-ga-qapi.pod && \
+	$(POD2MAN) --section=7 --center=" " --release=" " qemu-ga-qapi.pod > $@, \
+	"  GEN   $@")
+
 kvm_stat.1: scripts/kvm/kvm_stat.texi
 	$(call quiet-command, \
 	  perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< kvm_stat.pod && \
 	  $(POD2MAN) --section=1 --center=" " --release=" " kvm_stat.pod > $@, \
 	  "  GEN   $@")
 
-dvi: qemu-doc.dvi qemu-tech.dvi
-html: qemu-doc.html qemu-tech.html
-info: qemu-doc.info qemu-tech.info
-pdf: qemu-doc.pdf qemu-tech.pdf
+dvi: qemu-doc.dvi qemu-tech.dvi qemu-qapi.dvi
+html: qemu-doc.html qemu-tech.html qemu-qapi.html
+info: qemu-doc.info qemu-tech.info qemu-qapi.info
+pdf: qemu-doc.pdf qemu-tech.pdf qemu-qapi.pdf
 
 qemu-doc.dvi qemu-doc.html qemu-doc.info qemu-doc.pdf: \
 	qemu-img.texi qemu-nbd.texi qemu-options.texi \