summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-06-08 12:50:49 +1000
committerSergey V. Udaltsov <svu@gnome.org>2011-06-08 21:16:44 +0100
commit35dc61af79dba32653ec97bd455b428b9cdb681d (patch)
treecc02548ea9b6ac59b6cfa5d3beb16a4ef56828dd
parenta9fc72984ee796049a49ea7f4a415fab579c5093 (diff)
Use XSL to generate man page from the rules XML
Take evdev.xml and convert it into a man page, install it as xkeyoard-config.7 man page to list all option that xkeyboard-config provides. man.xsl is badly indented because I couldn't figure out how to make xsl ignore whitespaces properly. Adds a requirement on the xorg util-macros. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--configure.in14
-rw-r--r--rules/Makefile.am8
-rw-r--r--xslt/man.xsl106
3 files changed, 128 insertions, 0 deletions
diff --git a/configure.in b/configure.in
index 527e807b..a037abbe 100644
--- a/configure.in
+++ b/configure.in
@@ -3,6 +3,13 @@ AC_CONFIG_SRCDIR(rules/base.xml.in)
AM_INIT_AUTOMAKE([foreign dist-bzip2])
AM_MAINTAINER_MODE
+# Require X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS
+m4_ifndef([XORG_MACROS_VERSION],
+ [m4_fatal([must install xorg-macros 1.8 or later before
+ running autoconf/autogen])])
+XORG_MACROS_VERSION(1.8)
+XORG_MANPAGE_SECTIONS
+
AC_SUBST(VERSION)
AC_PATH_PROG([XKBCOMP], [xkbcomp], [not_found])
@@ -24,6 +31,13 @@ AC_ARG_ENABLE( compat_rules,
enable_compat_rules="$enableval",
enable_compat_rules="yes" )
+AC_PATH_PROG(SED, [sed])
+AC_PATH_PROG(XSLTPROC, [xsltproc])
+AM_CONDITIONAL([HAVE_XSLTPROC], [test "x$XSLTPROC" != "x"])
+if test "x$XSLTPROC" = "x"; then
+ AC_MSG_WARN([xsltproc not found, needed to generate man page.])
+fi
+
# xkeyboard-config does not have build-time dependencies. However, it does
# have run-time dependencies and keyboard layouts may not work without the
# right libX11 or xproto installed.
diff --git a/rules/Makefile.am b/rules/Makefile.am
index f2d73ce8..39351c9c 100644
--- a/rules/Makefile.am
+++ b/rules/Makefile.am
@@ -234,3 +234,11 @@ rulesdir = $(xkb_base)/rules
xmldir = $(rulesdir)
@INTLTOOL_XML_NOMERGE_RULE@
+
+xkeyboard-config.man: evdev.xml
+ $(XSLTPROC) $(top_srcdir)/xslt/man.xsl evdev.xml > $@
+
+xkeyboard-config.7: xkeyboard-config.man
+ $(SED) $(MAN_SUBSTS) < $< > $@
+
+dist_man_MANS = xkeyboard-config.7
diff --git a/xslt/man.xsl b/xslt/man.xsl
new file mode 100644
index 00000000..f0475e04
--- /dev/null
+++ b/xslt/man.xsl
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ >
+<xsl:output method="text" encoding="UTF-8" doctype-system="xkb.dtd"/>
+<xsl:template match="/xkbConfigRegistry"><![CDATA[.\" WARNING: this man page is autogenerated. Do not edit or you will lose all your changes.
+.TH XKEYBOARD-CONFIG __miscmansuffix__ __vendorversion__
+.SH NAME
+xkeyboard-config \- XKB data description files
+.SH DESCRIPTION
+xkeyboard-config provides the description files for the X Keyboard
+Extension (XKB). The configuration options below are usually applied with
+setxkbmap.
+.SH MODELS
+.TS
+l l
+___
+lB l.
+model description ]]>
+<xsl:apply-templates select="modelList"/>
+<![CDATA[
+.TE
+.SH LAYOUTS
+.TS
+l l l
+____
+lB lB l.
+layout variant description ]]>
+<xsl:apply-templates select="layoutList"/>
+<![CDATA[
+.TE
+.SH OPTIONS
+]]>
+<xsl:apply-templates select="optionList"/>
+<![CDATA[
+.SH SEE ALSO
+setxkbmap(__appmansuffix__)
+]]>
+</xsl:template>
+
+<!-- split model/description into a normal table -->
+<xsl:template match="modelList">
+ <xsl:for-each select="model">
+ <xsl:value-of select="configItem/name"/><xsl:text> </xsl:text><xsl:value-of select="configItem/description"/>
+<xsl:text>
+</xsl:text>
+</xsl:for-each>
+</xsl:template>
+
+<!-- split layout/variant/description into a table like this
+
+ layout1 description
+ variant1 description
+ variant2 description
+ layout2 description
+ variant1 description
+-->
+<xsl:template match="layoutList">
+<xsl:for-each select="layout">
+<xsl:value-of select="configItem/name"/><xsl:text> </xsl:text><xsl:value-of select="configItem/description"/>
+<xsl:text>
+</xsl:text>
+<xsl:for-each select="variantList/variant">
+<xsl:text> </xsl:text><xsl:value-of select="configItem/name"/><xsl:text> </xsl:text><xsl:value-of select="configItem/description"/>
+<xsl:text>
+</xsl:text>
+</xsl:for-each>
+<xsl:text>
+</xsl:text>
+</xsl:for-each>
+</xsl:template>
+
+<!-- split option into a table like this
+
+option description:
+ optarg description
+ optarg description
+ optarg description
+
+option2 description:
+ optarg description
+ optarg description
+-->
+<xsl:template match="optionList">
+<xsl:for-each select="group">
+<![CDATA[
+.SS]]> <xsl:value-of select="configItem/description"/>
+<![CDATA[
+.BR
+.TS
+l l
+___
+lB l.
+option description ]]>
+<xsl:for-each select="option">
+<xsl:value-of select="configItem/name"/><xsl:text> </xsl:text><xsl:value-of select="configItem/description"/>
+<xsl:text>
+</xsl:text>
+</xsl:for-each>
+<![CDATA[
+.TE
+
+]]>
+</xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>