From: Hugo Villeneuve Date: Wed, 21 Nov 2012 04:32:27 +0000 (-0500) Subject: Add docbook support for automatic documentation regeneration X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=360861c8d05d6ad6689fd948053b3529d7e3cf20;p=hvgrip.git Add docbook support for automatic documentation regeneration --- diff --git a/configure.ac b/configure.ac index 0e1d0e4..e8496e4 100644 --- a/configure.ac +++ b/configure.ac @@ -131,6 +131,26 @@ fi AC_SUBST(ID3_LIBS) LIBS=$id3_libs_bak + +# Check if we can rebuild documentation +##AX_CHECK_DOCBOOK + +##if test x"$XSLTPROC_WORKS" = xyes; then +## echo " XSLTPROC_WORKS = YES" +##fi + +dnl Check for xsltproc +AC_PATH_PROG([XSLTPROC], [xsltproc]) + +dnl check for DocBook DTD and stylesheets in the local catalog. +JH_CHECK_XML_CATALOG([-//OASIS//DTD DocBook XML V4.3//EN], [DocBook XML DTD V4.3], [docbook_dtd=1], [docbook_dtd=0]) + +JH_CHECK_XML_CATALOG([http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl], [DocBook XSL Stylesheets], [docbook_stylesheet=1], [docbook_stylesheet=0]) + +if test -n "$XSLTPROC" -a x"$docbook_dtd" = x1 -a x"$docbook_stylesheet" = x1; then + AM_CONDITIONAL(have_docbook, test -n "$XSLTPROC" -a x"$docbook_dtd" = x1 -a x"$docbook_stylesheet" = x1) +fi + AC_SUBST(CFLAGS) AC_SUBST(CPPFLAGS) AC_SUBST(LDFLAGS) diff --git a/doc/Makefile.am b/doc/Makefile.am index ca3e3e7..c61b67f 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,11 +1,33 @@ SUBDIRS = images +XSLTPROC=xsltproc +XSLTPROC_FLAGS= +XHTML_STYLESHEET="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl" +#XHTML_STYLESHEET="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl" +XML_CATALOG_FILES=/etc/xml/catalog + @PACKAGE@_helpdir = $(docdir) @PACKAGE@_help_DATA = \ @PACKAGE@.html \ @PACKAGE@.xml +if have_docbook + +@PACKAGE@.html: ${top_srcdir}/doc/@PACKAGE@.xml + XML_CATALOG_FILES=$(XML_CATALOG_FILES) $(XSLTPROC) $(XSLTPROC_FLAGS) -o $@ $(XHTML_STYLESHEET) $< + +##.xml.html: +# XSLTPROC_OPTS=/usr/share/xml/docbook/xsl-stylesheets-/xhtml/docbook.xsl +### $(XSLTPROC) --output $@ --nonet $(docbook_styles)/docbook.xsl $< + +else + +@PACKAGE@.html: + touch $@ + +endif + EXTRA_DIST = \ @PACKAGE@.html \ @PACKAGE@.xml diff --git a/m4/docbook.m4 b/m4/docbook.m4 new file mode 100644 index 0000000..02501fa --- /dev/null +++ b/m4/docbook.m4 @@ -0,0 +1,55 @@ + +# Checks the location of the XML Catalog +# Usage: +# JH_PATH_XML_CATALOG([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# Defines XMLCATALOG and XML_CATALOG_FILE substitutions +AC_DEFUN([JH_PATH_XML_CATALOG], +[ + # check for the presence of the XML catalog + AC_ARG_WITH([xml-catalog], + AC_HELP_STRING([--with-xml-catalog=CATALOG], + [path to xml catalog to use]),, + [with_xml_catalog=/etc/xml/catalog]) + jh_found_xmlcatalog=true + XML_CATALOG_FILE="$with_xml_catalog" + AC_SUBST([XML_CATALOG_FILE]) + AC_MSG_CHECKING([for XML catalog ($XML_CATALOG_FILE)]) + if test -f "$XML_CATALOG_FILE"; then + AC_MSG_RESULT([found]) + else + jh_found_xmlcatalog=false + AC_MSG_RESULT([not found]) + fi + + # check for the xmlcatalog program + AC_PATH_PROG(XMLCATALOG, xmlcatalog, no) + if test "x$XMLCATALOG" = xno; then + jh_found_xmlcatalog=false + fi + + if $jh_found_xmlcatalog; then + ifelse([$1],,[:],[$1]) + else + ifelse([$2],,[AC_MSG_ERROR([could not find XML catalog])],[$2]) + fi +]) + +# Checks if a particular URI appears in the XML catalog +# Usage: +# JH_CHECK_XML_CATALOG(URI, [FRIENDLY-NAME], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +AC_DEFUN([JH_CHECK_XML_CATALOG], +[ + AC_REQUIRE([JH_PATH_XML_CATALOG],[JH_PATH_XML_CATALOG(,[:])])dnl + AC_MSG_CHECKING([for ifelse([$2],,[$1],[$2]) in XML catalog]) + if $jh_found_xmlcatalog && \ + AC_RUN_LOG([$XMLCATALOG --noout "$XML_CATALOG_FILE" "$1" >&2]); then + AC_MSG_RESULT([found]) + ifelse([$3],,,[$3 +])dnl + else + AC_MSG_RESULT([not found]) + ifelse([$4],, + [AC_MSG_ERROR([could not find ifelse([$2],,[$1],[$2]) in XML catalog])], + [$4]) + fi +])