comparison doxy2devhelp.xsl @ 20912:f34539eb7a61

Add some xsl magic to generate a .devhelp index from doxygen's XML output, allowing the documentation to be viewed in Devhelp. It's not perfect --- there are some broken links and the transformation is a bit fragile --- but works well enough to be useful.
author Will Thompson <will.thompson@collabora.co.uk>
date Sat, 13 Oct 2007 15:44:43 +0000
parents
children
comparison
equal deleted inserted replaced
20910:54d232b52607 20912:f34539eb7a61
1 <xsl:stylesheet
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:fo="http://www.w3.org/1999/XSL/Format"
4 version="1.0">
5
6 <!-- Based on http://bur.st/~eleusis/devhelp/doxy2devhelp.xsl
7 (http://bur.st/~eleusis/devhelp/README)
8 which is based on http://bugzilla.gnome.org/show_bug.cgi?id=122450
9 -->
10
11 <xsl:output method="xml" version="1.0" indent="yes"/>
12
13 <xsl:param name="reference_prefix"></xsl:param>
14
15 <xsl:template match="/">
16 <book title="Pidgin Documentation"
17 name="pidgin"
18 link="{$reference_prefix}main.html">
19 <chapters>
20 <sub name="Modules" link="{$reference_prefix}modules.html">
21 <xsl:apply-templates select="doxygenindex/compound[@kind='group']">
22 <xsl:sort select="."/>
23 </xsl:apply-templates>
24 </sub>
25 <!-- annotated.html has the short descriptions beside each struct. is
26 that more useful than being grouped alphabetically?
27 -->
28 <sub name="Structs" link="{$reference_prefix}classes.html">
29 <xsl:apply-templates select="doxygenindex/compound[@kind='struct']">
30 <xsl:sort select="."/>
31 </xsl:apply-templates>
32 </sub>
33 <!-- This is redundant given Modules -->
34 <!--
35 <sub name="Directories" link="{$reference_prefix}dirs.html">
36 <xsl:apply-templates select="doxygenindex/compound[@kind='dir']">
37 <xsl:sort select="."/>
38 </xsl:apply-templates>
39 </sub>
40 -->
41 <!-- FIXME: Some files show up here but are broken links; mostly
42 files that are under pages...
43 -->
44 <sub name="Files" link="{$reference_prefix}files.html">
45 <xsl:apply-templates select="doxygenindex/compound[@kind='file']">
46 <xsl:sort select="."/>
47 </xsl:apply-templates>
48 </sub>
49 <sub name="Signals, HOWTOs, Other" link="{$reference_prefix}pages.html">
50 <xsl:apply-templates select="doxygenindex/compound[@kind='page']">
51 <xsl:sort select="."/>
52 </xsl:apply-templates>
53 </sub>
54 </chapters>
55
56 <functions>
57 <!-- @todo: maybe select only the real functions, ie those with kind=="function"? -->
58 <xsl:apply-templates select="doxygenindex/compound/member" mode="as-function"/>
59 </functions>
60 </book>
61 </xsl:template>
62
63 <xsl:template match="compound">
64 <xsl:param name="name"><xsl:value-of select="name"/></xsl:param>
65 <xsl:param name="link"><xsl:value-of select="@refid"/>.html</xsl:param>
66 <sub name="{$name}" link="{$reference_prefix}{$link}">
67 <xsl:apply-templates select="member" mode="as-sub">
68 <xsl:sort select="."/>
69 </xsl:apply-templates>
70 </sub>
71 </xsl:template>
72
73 <xsl:template match="member" mode="as-function">
74 <!--
75 <function name="atk_set_value" link="atk-atkvalue.html#ATK-SET-VALUE"/>
76 -->
77 <xsl:param name="name"><xsl:value-of select="name"/></xsl:param>
78 <!-- Link is refid attribute of parent element + "#" + diff between refid of parent and own refid -->
79 <xsl:param name="refid_parent"><xsl:value-of select="parent::node()/@refid"/></xsl:param>
80 <xsl:param name="own_refid"><xsl:value-of select="@refid"/></xsl:param>
81 <xsl:param name="offset"><xsl:value-of select="string-length($refid_parent) + 3"/></xsl:param>
82 <xsl:param name="ref_diff"><xsl:value-of select="substring($own_refid, $offset, 33)"/></xsl:param>
83 <xsl:param name="link"><xsl:value-of select="$refid_parent"/>.html#<xsl:value-of select="$ref_diff"/></xsl:param>
84 <function name="{$name}" link="{$reference_prefix}{$link}"/>
85 </xsl:template>
86
87 <xsl:template match="member" mode="as-sub">
88 <xsl:param name="name"><xsl:value-of select="name"/></xsl:param>
89 <!-- Link is refid attribute of parent element + "#" + diff between refid of parent and own refid -->
90 <xsl:param name="refid_parent"><xsl:value-of select="parent::node()/@refid"/></xsl:param>
91 <xsl:param name="own_refid"><xsl:value-of select="@refid"/></xsl:param>
92 <xsl:param name="offset"><xsl:value-of select="string-length($refid_parent) + 3"/></xsl:param>
93 <xsl:param name="ref_diff"><xsl:value-of select="substring($own_refid, $offset, 33)"/></xsl:param>
94 <xsl:param name="link"><xsl:value-of select="$refid_parent"/>.html#<xsl:value-of select="$ref_diff"/></xsl:param>
95 <sub name="{$name}" link="{$reference_prefix}{$link}"/>
96 </xsl:template>
97
98 </xsl:stylesheet>