summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon MacMullen <simon@lshift.net>2010-02-26 12:25:34 +0000
committerSimon MacMullen <simon@lshift.net>2010-02-26 12:25:34 +0000
commit08ca738b00e81d85872818fb701225a23f506e76 (patch)
treec88c38abb5d93f1eccb0ba1b8a0bc516799dee2e
parent380bdb02088105b1d2ba45462ea2e316a8539097 (diff)
downloadrabbitmq-server-08ca738b00e81d85872818fb701225a23f506e76.tar.gz
Transform our generated rabbitmqctl HTML page back to our ad-hoc XML format for the website. It looks OK now.
-rw-r--r--Makefile16
-rw-r--r--docs/html-to-website-xml.xsl68
2 files changed, 79 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 6b8d6b42..5fbeefd3 100644
--- a/Makefile
+++ b/Makefile
@@ -207,11 +207,17 @@ distclean: clean
xsltproc docs/usage.xsl $< | sed -e s/\\\"/\\\\\\\"/g | fmt -s >> docs/`basename $< .1.xml`.usage.erl
echo '"), halt(1).' >> docs/`basename $< .1.xml`.usage.erl
-docs/rabbitmqctl.html: docs/rabbitmqctl.1.xml
- xmlto html docs/rabbitmqctl.1.xml
- mv -f index.html docs/rabbitmqctl.html
-
-docs_all: $(MANPAGES) docs/rabbitmqctl.html
+# This evil with grep and sed is due to the remarkable ugliness otherwise
+# experienced trying to get XSLT to work with an input doc where all nodes are
+# in a namespace.
+rabbitmqctl.xml: docs/rabbitmqctl.1.xml
+ xmlto xhtml docs/rabbitmqctl.1.xml
+ cat index.html | grep -v DOCTYPE | sed -e s,xmlns=\"http://www.w3.org/1999/xhtml\",, | xsltproc docs/html-to-website-xml.xsl - | xmllint --format - > rabbitmqctl.xml
+ rm index.html
+ # TODO how should this really be deployed?
+ cp rabbitmqctl.xml ../rabbitmq-website/site/
+
+docs_all: $(MANPAGES) rabbitmqctl.xml
install: SCRIPTS_REL_PATH=$(shell ./calculate-relative $(TARGET_DIR)/sbin $(SBIN_DIR))
install: all docs_all install_dirs
diff --git a/docs/html-to-website-xml.xsl b/docs/html-to-website-xml.xsl
new file mode 100644
index 00000000..d4cee085
--- /dev/null
+++ b/docs/html-to-website-xml.xsl
@@ -0,0 +1,68 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:doc="http://www.rabbitmq.com/namespaces/ad-hoc/doc"
+ version='1.0'>
+
+<xsl:output method="xml" doctype-public="bug in xslt processor requires fake doctype" doctype-system="otherwise css isn't included" />
+
+<xsl:template match="*"/>
+
+<!-- Copy every element through, deliberately losing all attributes -->
+<xsl:template match="node()" mode="copy">
+ <xsl:copy><xsl:apply-templates select="node()" mode="copy"/></xsl:copy>
+</xsl:template>
+
+<!-- Copy the root node, and munge the outer part of the page -->
+<xsl:template match="/html">
+<xsl:processing-instruction name="xml-stylesheet">type="text/xml" href="page.xsl"</xsl:processing-instruction>
+<html xmlns:doc="http://www.rabbitmq.com/namespaces/ad-hoc/doc">
+ <head>
+ <title>rabbitmqctl(1) manual page</title>
+ </head>
+ <body>
+ <doc:div>
+ <p>
+ This is the manual page for the <code>rabbitmqctl</code> command. For
+ more general documentation, please see the
+ <a href="admin-guide.html">administrator's guide</a>.
+ </p>
+
+ <doc:toc class="compact">
+ <doc:heading>Table of Contents</doc:heading>
+ </doc:toc>
+
+ <xsl:apply-templates select="body/div[@class='refentry']" mode="copy"/>
+ </doc:div>
+ </body>
+</html>
+</xsl:template>
+
+<!-- Specific instructions to revert the DocBook HTML to be more like our ad-hoc XML schema -->
+
+<xsl:template match="div[@class='refsect1'] | div[@class='refnamediv'] | div[@class='refsynopsisdiv']" mode="copy">
+ <doc:section name="{@title}">
+ <xsl:apply-templates select="node()" mode="copy"/>
+ </doc:section>
+</xsl:template>
+
+<xsl:template match="div[@class='refsect2']" mode="copy">
+ <doc:subsection name="{@title}">
+ <xsl:apply-templates select="node()" mode="copy"/>
+ </doc:subsection>
+</xsl:template>
+
+<xsl:template match="h2 | h3" mode="copy">
+ <doc:heading>
+ <xsl:apply-templates select="node()" mode="copy"/>
+ </doc:heading>
+</xsl:template>
+
+<xsl:template match="pre[@class='screen']" mode="copy">
+ <pre class="sourcecode">
+ <xsl:apply-templates select="node()" mode="copy"/>
+ </pre>
+</xsl:template>
+
+
+</xsl:stylesheet>
+