Skip to contentSkip to conversation

improve checking for documentation tools and formatting

PATCH Superseded Matt Wilson 2 participants 9 messages Aug 30, 2012 – Sep 4, 2012

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 improve checking for documentation tools and formatting

This version makes running ./configure a prerequisite for building documentation. If a tool is not detected by ./configure and is not specified by the user, the make variable will be empty. So I've switched to using make conditionals instead of which(1).

Matt

#1 lore raw

PATCH v2 1/1 tools: check for documentation generation tools at configure time

It is sometimes hard to discover all the optional tools that should be on a system to build all available Xen documentation. By checking for documentation generation tools at ./configure time and displaying a warning, Xen packagers will more easily learn about new optional build dependencies, like markdown, when they are introduced.

Changes since v1:
* require that ./configure be run before building docs
* remove Docs.mk and make Tools.mk the canonical locaiton where docs tools are defined (via ./configure)
* fold in checking for markdown_py

README +4 -3
diff -r d7e4efa17fb0 -r 512b4e0c49f3 README
@@ -28,8 +28,9 @@
 your system. For full documentation, see the Xen User Manual. If this
 is a pre-built release then you can find the manual at:
  dist/install/usr/share/doc/xen/pdf/user.pdf
-If you have a source release, then 'make -C docs' will build the
-manual at docs/pdf/user.pdf.
+If you have a source release and the required documentation generation
+tools, then './configure; make -C docs' will build the manual at
+docs/pdf/user.pdf.
 
 Quick-Start Guide
 =================
@@ -59,7 +60,6 @@
     * GNU gettext
     * 16-bit x86 assembler, loader and compiler (dev86 rpm or bin86 & bcc debs)
     * ACPI ASL compiler (iasl)
-    * markdown
 
 In addition to the above there are a number of optional build
 prerequisites. Omitting these will cause the related features to be
@@ -67,6 +67,7 @@
     * Development install of Ocaml (e.g. ocaml-nox and
       ocaml-findlib). Required to build ocaml components which
       includes the alternative ocaml xenstored.
+    * markdown
 
 Second, you need to acquire a suitable kernel for use in domain 0. If
 possible you should use a kernel provided by your OS distributor. If
config/Tools.mk.in +12 -0
diff -r d7e4efa17fb0 -r 512b4e0c49f3 config/Tools.mk.in
@@ -22,6 +22,18 @@
 LD86                := @LD86@
 BCC                 := @BCC@
 IASL                := @IASL@
+PS2PDF              := @PS2PDF@
+DVIPS               := @DVIPS@
+LATEX               := @LATEX@
+FIG2DEV             := @FIG2DEV@
+LATEX2HTML          := @LATEX2HTML@
+DOXYGEN             := @DOXYGEN@
+POD2MAN             := @POD2MAN@
+POD2HTML            := @POD2HTML@
+POD2TEXT            := @POD2TEXT@
+DOT                 := @DOT@
+NEATO               := @NEATO@
+MARKDOWN            := @MARKDOWN@
 
 # Extra folder for libs/includes
 PREPEND_INCLUDES    := @PREPEND_INCLUDES@
docs/Docs.mk deleted +0 -12
diff -r d7e4efa17fb0 -r 512b4e0c49f3 docs/Docs.mk
@@ -1,12 +0,0 @@
-PS2PDF		:= ps2pdf
-DVIPS		:= dvips
-LATEX		:= latex
-FIG2DEV		:= fig2dev
-LATEX2HTML	:= latex2html
-DOXYGEN		:= doxygen
-POD2MAN		:= pod2man
-POD2HTML	:= pod2html
-POD2TEXT	:= pod2text
-DOT		:= dot
-NEATO		:= neato
-MARKDOWN	:= markdown
docs/Makefile +48 -20

124 lines not on this page · raw message

docs/xen-api/Makefile +6 -1
diff -r d7e4efa17fb0 -r 512b4e0c49f3 docs/xen-api/Makefile
@@ -2,7 +2,7 @@
 
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/Config.mk
-include $(XEN_ROOT)/docs/Docs.mk
+-include $(XEN_ROOT)/config/Tools.mk
 
 
 TEX := $(wildcard *.tex)
@@ -42,3 +42,8 @@
 .PHONY: clean
 clean:
 	rm -f *.pdf *.ps *.dvi *.aux *.log *.out $(EPSDOT)
+
+ifeq (,$(findstring clean,$(MAKECMDGOALS)))
+$(XEN_ROOT)/config/Tools.mk:
+	$(error You have to run ./configure before building docs)
+endif
tools/configure.ac +13 -0
diff -r d7e4efa17fb0 -r 512b4e0c49f3 tools/configure.ac
@@ -34,6 +34,7 @@
 m4_include([m4/curses.m4])
 m4_include([m4/pthread.m4])
 m4_include([m4/ptyfuncs.m4])
+m4_include([m4/docs_tool.m4])
 
 # Enable/disable options
 AX_ARG_DEFAULT_DISABLE([githttp], [Download GIT repositories via HTTP])
@@ -80,6 +81,18 @@
 AC_PATH_PROG([BISON], [bison])
 AC_PATH_PROG([FLEX], [flex])
 AX_PATH_PROG_OR_FAIL([PERL], [perl])
+AX_DOCS_TOOL_PROG([PS2PDF], [ps2pdf])
+AX_DOCS_TOOL_PROG([DVIPS], [dvips])
+AX_DOCS_TOOL_PROG([LATEX], [latex])
+AX_DOCS_TOOL_PROG([FIG2DEV], [fig2dev])
+AX_DOCS_TOOL_PROG([LATEX2HTML], [latex2html])
+AX_DOCS_TOOL_PROG([DOXYGEN], [doxygen])
+AX_DOCS_TOOL_PROG([POD2MAN], [pod2man])
+AX_DOCS_TOOL_PROG([POD2HTML], [pod2html])
+AX_DOCS_TOOL_PROG([POD2TEXT], [pod2text])
+AX_DOCS_TOOL_PROG([DOT], [dot])
+AX_DOCS_TOOL_PROG([NEATO], [neato])
+AX_DOCS_TOOL_PROGS([MARKDOWN], [markdown markdown_py])
 AS_IF([test "x$xapi" = "xy"], [
     AX_PATH_PROG_OR_FAIL([CURL], [curl-config])
     AX_PATH_PROG_OR_FAIL([XML], [xml2-config])
tools/m4/docs_tool.m4 new file +17 -0
diff -r d7e4efa17fb0 -r 512b4e0c49f3 tools/m4/docs_tool.m4
@@ -0,0 +1,17 @@
+AC_DEFUN([AX_DOCS_TOOL_PROG], [
+dnl
+    AC_ARG_VAR([$1], [Path to $2 tool])
+    AC_PATH_PROG([$1], [$2])
+    AS_IF([! test -x "$ac_cv_path_$1"], [
+        AC_MSG_WARN([$2 is not available so some documentation won't be built])
+    ])
+])
+
+AC_DEFUN([AX_DOCS_TOOL_PROGS], [
+dnl
+    AC_ARG_VAR([$1], [Path to $2 tool])
+    AC_PATH_PROGS([$1], [$2])
+    AS_IF([! test -x "$ac_cv_path_$1"], [
+        AC_MSG_WARN([$2 is not available so some documentation won't be built])
+    ])
+])
#6 lore raw

PATCH v2 1/1 docs: use elinks to format markdown-generated html to text

In reply to Matt Wilson

Markdown, while easy to read and write, isn't the most consumable format for users reading documentation on a terminal. This patch uses lynx to format markdown produced HTML into text files.

Changes since v3:
* check for html to text dump tool in ./configure
* switch to using elinks
* allow command line flags to dump tool to be specified

config/Tools.mk.in +2 -0
diff -r 512b4e0c49f3 -r 651347cccff7 config/Tools.mk.in
@@ -34,6 +34,8 @@
 DOT                 := @DOT@
 NEATO               := @NEATO@
 MARKDOWN            := @MARKDOWN@
+HTMLDUMP            := @HTMLDUMP@
+HTMLDUMPFLAGS       := @HTMLDUMPFLAGS@
 
 # Extra folder for libs/includes
 PREPEND_INCLUDES    := @PREPEND_INCLUDES@
docs/Makefile +13 -2
diff -r 512b4e0c49f3 -r 651347cccff7 docs/Makefile
@@ -146,9 +146,20 @@
 	$(call move-if-changed,[email protected],$@)
 
 txt/%.txt: %.markdown
-	$(INSTALL_DIR) $(@D)
-	cp $< [email protected]
+	@$(INSTALL_DIR) $(@D)
+ifdef MARKDOWN
+ifdef HTMLDUMP
+	@echo "Running markdown to generate $*.txt ... "; \
+	$(MARKDOWN) $< | $(HTMLDUMP) $(HTMLDUMPFLAGS) > [email protected]
 	$(call move-if-changed,[email protected],$@)
+else
+	@echo "html dump tool (like elinks) not installed; just copying $<." \;
+	cp $< $@;
+endif
+else
+	@echo "markdown not installed; just copying $<." \;
+	cp $< $@;
+endif
 
 txt/man/%.1.txt: man/%.pod.1 Makefile
 	$(INSTALL_DIR) $(@D)
tools/configure.ac +10 -0
diff -r 512b4e0c49f3 -r 651347cccff7 tools/configure.ac
@@ -93,6 +93,16 @@
 AX_DOCS_TOOL_PROG([DOT], [dot])
 AX_DOCS_TOOL_PROG([NEATO], [neato])
 AX_DOCS_TOOL_PROGS([MARKDOWN], [markdown markdown_py])
+AC_ARG_VAR([HTMLDUMP],
+           [Path to html-to-text generation tool (default: elinks)])
+AC_PATH_PROG([HTMLDUMP], [elinks])
+AS_IF([! test -x "$ac_cv_path_HTMLDUMP"], [
+    AC_MSG_WARN([$ac_cv_path_HTMLDUMP is not available so text documentation will be unformatted markdown])
+])
+AC_SUBST([HTMLDUMPFLAGS], ["-dump"])
+AC_ARG_VAR([HTMLDUMPFLAGS], [Flags passed to html to text translation tool])
+
+
 AS_IF([test "x$xapi" = "xy"], [
     AX_PATH_PROG_OR_FAIL([CURL], [curl-config])
     AX_PATH_PROG_OR_FAIL([XML], [xml2-config])
#2 lore raw

Re: [PATCH 1 of 2 v2] tools: check for documentation generation tools at configure time

In reply to Matt Wilson
Quoted 18 lines · Matt Wilson

It is sometimes hard to discover all the optional tools that should be on a system to build all available Xen documentation. By checking for documentation generation tools at ./configure time and displaying a warning, Xen packagers will more easily learn about new optional build dependencies, like markdown, when they are introduced.

Changes since v1:
* require that ./configure be run before building docs
* remove Docs.mk and make Tools.mk the canonical locaiton where docs tools are defined (via ./configure)
* fold in checking for markdown_py

diff -r d7e4efa17fb0 -r 512b4e0c49f3 README

README line 33

Quoted 8 lines
README +3 -2
@@ -28,8 +28,9 @@
 your system. For full documentation, see the Xen User Manual. If this
 is a pre-built release then you can find the manual at:
  dist/install/usr/share/doc/xen/pdf/user.pdf
-If you have a source release, then 'make -C docs' will build the
-manual at docs/pdf/user.pdf.
+If you have a source release and the required documentation generation
+tools, then './configure; make -C docs' will build the manual at
+docs/pdf/user.pdf.

This document was removed in 24563:4271634e4c86, looks like we missed this reference. Could you nuke it as you go please?

Quoted 6 lines

diff -r d7e4efa17fb0 -r 512b4e0c49f3 tools/m4/docs_tool.m4

tools/m4/docs_tool.m4 new file +2 -0
@@ -0,0 +1,17 @@
+AC_DEFUN([AX_DOCS_TOOL_PROG], [
+dnl

tools/m4/docs_tool.m4 line 12

Quoted 10 lines
tools/m4/docs_tool.m4 new file +10 -0
+    AC_ARG_VAR([$1], [Path to $2 tool])
+    AC_PATH_PROG([$1], [$2])
+    AS_IF([! test -x "$ac_cv_path_$1"], [
+        AC_MSG_WARN([$2 is not available so some documentation won't be built])
+    ])
+])
+
+AC_DEFUN([AX_DOCS_TOOL_PROGS], [
+dnl
+    AC_ARG_VAR([$1], [Path to $2 tool])

Does this do something sensible when $2 is a space separated list?

Do we need both PROG and PROGS variants? PROG is just a special case of PROGS, isn't it? Although seeing that AC apparently has both variants I guess there's a reason for that.

Quoted 5 lines
tools/m4/docs_tool.m4 new file +5 -0
+    AC_PATH_PROGS([$1], [$2])
+    AS_IF([! test -x "$ac_cv_path_$1"], [
+        AC_MSG_WARN([$2 is not available so some documentation won't be built])
+    ])
+])
#7 lore raw

Re: [PATCH 2 of 2 v2] docs: use elinks to format markdown-generated html to text

In reply to Matt Wilson
Quoted 3 lines · Matt Wilson

Markdown, while easy to read and write, isn't the most consumable format for users reading documentation on a terminal. This patch uses lynx to format markdown produced HTML into text files.

s/lynx/elinks/ in the comment.

config/Tools.mk.in line 38

Quoted 9 lines

diff -r 512b4e0c49f3 -r 651347cccff7 config/Tools.mk.in

config/Tools.mk.in +2 -0
@@ -34,6 +34,8 @@
 DOT                 := @DOT@
 NEATO               := @NEATO@
 MARKDOWN            := @MARKDOWN@
+HTMLDUMP            := @HTMLDUMP@
+HTMLDUMPFLAGS       := @HTMLDUMPFLAGS@

Does HTMLDUMP="elinks -dump" not work?

Ian.

#3 lore raw

Re: [PATCH 1 of 2 v2] tools: check for documentation generation tools at configure time

In reply to Ian Campbell
Quoted 5 lines · Ian Campbell

tools/m4/docs_tool.m4 line 12

Quoted 3 lines
tools/m4/docs_tool.m4 new file +3 -0
+AC_DEFUN([AX_DOCS_TOOL_PROGS], [
+dnl
+    AC_ARG_VAR([$1], [Path to $2 tool])

Does this do something sensible when $2 is a space separated list?

Not especially:

$ ./configure --help| grep mark
   MARKDOWN    Path to markdown markdown_py tool

Ian.

#5 lore raw

Re: [PATCH 1 of 2 v2] tools: check for documentation generation tools at configure time

In reply to Matt Wilson
Quoted 5 lines · Matt Wilson

It is sometimes hard to discover all the optional tools that should be on a system to build all available Xen documentation. By checking for documentation generation tools at ./configure time and displaying a warning, Xen packagers will more easily learn about new optional build dependencies, like markdown, when they are introduced.

Having remembered to rerun autogen.sh I can confirm that I get the same set of docs as I did before on my regular build machine. I get no warnings about missing tools so I suppose I'm building all the docs.

(note to self, when this patch goes in check that the cronjob running
http://xenbits.xen.org/docs/unstable/ still works. reminders appreciated...)

Ian.

#8 lore raw

Re: [PATCH 2 of 2 v2] docs: use elinks to format markdown-generated html to text

In reply to Ian Campbell
Quoted 7 lines · Ian Campbell
Quoted 3 lines · Matt Wilson

Markdown, while easy to read and write, isn't the most consumable format for users reading documentation on a terminal. This patch uses lynx to format markdown produced HTML into text files.

s/lynx/elinks/ in the comment.

Quoted 11 lines

config/Tools.mk.in line 38

Quoted 9 lines

diff -r 512b4e0c49f3 -r 651347cccff7 config/Tools.mk.in

config/Tools.mk.in +2 -0
@@ -34,6 +34,8 @@
 DOT                 := @DOT@
 NEATO               := @NEATO@
 MARKDOWN            := @MARKDOWN@
+HTMLDUMP            := @HTMLDUMP@
+HTMLDUMPFLAGS       := @HTMLDUMPFLAGS@

Does HTMLDUMP="elinks -dump" not work?

I don't think so. AC_PATH_PROG() will just want the program name. This follows the CC / CFLAGS model.

Matt

#4 lore raw

Re: [PATCH 1 of 2 v2] tools: check for documentation generation tools at configure time

In reply to Ian Campbell
Quoted 10 lines · Ian Campbell
Quoted 5 lines · Ian Campbell

tools/m4/docs_tool.m4 line 12

Quoted 3 lines
tools/m4/docs_tool.m4 new file +3 -0
+AC_DEFUN([AX_DOCS_TOOL_PROGS], [
+dnl
+    AC_ARG_VAR([$1], [Path to $2 tool])

Does this do something sensible when $2 is a space separated list?

Not especially:

$ ./configure --help| grep mark
   MARKDOWN    Path to markdown markdown_py tool

I'll fix that up.

Matt