Utils/Daemon: Documentation
[senf.git] / doclib / html-munge.xsl
1 <?xml version="1.0" encoding="utf-8"?>\r
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">\r
3 \r
4   <xsl:output \r
5     method="html" \r
6     encoding="html" \r
7     doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"\r
8     doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>\r
9 \r
10   <xsl:param name="topdir" select="''"/>\r
11   \r
12   <xsl:template match="*">\r
13     <xsl:copy>\r
14       <xsl:call-template name="copy-attributes"/>\r
15       <xsl:apply-templates/>\r
16     </xsl:copy>\r
17   </xsl:template>\r
18 \r
19   <xsl:template name="copy-attributes">\r
20     <xsl:for-each select="@*">\r
21       <xsl:attribute name="{name(current())}">\r
22         <xsl:choose>\r
23           <xsl:when test="contains(current(),'@TOPDIR@')">\r
24             <xsl:value-of select="substring-before(current(),'@TOPDIR@')"/>\r
25             <xsl:value-of select="$topdir"/>\r
26             <xsl:value-of select="substring-after(current(),'@TOPDIR@')"/>\r
27           </xsl:when>\r
28           <xsl:otherwise>\r
29             <xsl:value-of select="current()"/>\r
30           </xsl:otherwise>\r
31         </xsl:choose>\r
32       </xsl:attribute>\r
33     </xsl:for-each>\r
34   </xsl:template>\r
35 \r
36   <!-- Remove the automatically inserted search form (we build our own) -->\r
37   <xsl:template match="li[form]"> \r
38   </xsl:template>\r
39   \r
40   <!-- Replace @TOPDIR@ with  relative top directory path -->\r
41   <xsl:template match="@*[contains(current(),'@TOPDIR@')]">\r
42     <xsl:value-of select="substring-before(current(),'@TOPDIR')"/>\r
43     <xsl:value-of select="$topdir"/>\r
44     <xsl:value-of select="substring-after(current(),'@TOPDIR')"/>\r
45   </xsl:template>\r
46   \r
47   <!-- Add 'class' attribute to some special paragraphs/lists -->\r
48   \r
49   <xsl:template name="add-class">\r
50     <xsl:param name="class"/>\r
51     <xsl:copy>\r
52       <xsl:call-template name="copy-attributes"/>\r
53       <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>\r
54       <xsl:apply-templates/>\r
55     </xsl:copy>\r
56   </xsl:template>\r
57 \r
58   <xsl:template match="dl[dt/b/a/text()='Bug:']">\r
59     <xsl:call-template name="add-class">\r
60       <xsl:with-param name="class">xref-bug</xsl:with-param>\r
61     </xsl:call-template>\r
62   </xsl:template>\r
63 \r
64   <xsl:template match="dl[dt/b/a/text()='Fix:']">\r
65     <xsl:call-template name="add-class">\r
66       <xsl:with-param name="class">xref-fix</xsl:with-param>\r
67     </xsl:call-template>\r
68   </xsl:template>\r
69 \r
70   <xsl:template match="dl[dt/b/a/text()='Todo:']">\r
71     <xsl:call-template name="add-class">\r
72       <xsl:with-param name="class">xref-todo</xsl:with-param>\r
73     </xsl:call-template>\r
74   </xsl:template>\r
75 \r
76   <xsl:template match="dl[dt/b/a/text()='Idea:']">\r
77     <xsl:call-template name="add-class">\r
78       <xsl:with-param name="class">xref-idea</xsl:with-param>\r
79     </xsl:call-template>\r
80   </xsl:template>\r
81 \r
82   <xsl:template match="dl[dt/b/text()='Parameters:']">\r
83     <xsl:call-template name="add-class">\r
84       <xsl:with-param name="class">parameters</xsl:with-param>\r
85     </xsl:call-template>\r
86   </xsl:template>\r
87 \r
88   <xsl:template match="dl[dt/b/text()='Implementation note:']">\r
89     <xsl:call-template name="add-class">\r
90       <xsl:with-param name="class">implementation</xsl:with-param>\r
91     </xsl:call-template>\r
92   </xsl:template>\r
93 \r
94   <xsl:template match="table[descendant::td[@class='memItemLeft']]">\r
95     <xsl:call-template name="add-class">\r
96       <xsl:with-param name="class">members</xsl:with-param>\r
97     </xsl:call-template>\r
98   </xsl:template>\r
99 \r
100   <xsl:template match="a[@href=string(current())]" priority="1">\r
101     <xsl:call-template name="add-class">\r
102       <xsl:with-param name="class">literal</xsl:with-param>\r
103     </xsl:call-template>\r
104   </xsl:template>\r
105 \r
106   <xsl:template match="a[contains(@href,'http://')]">\r
107     <xsl:call-template name="add-class">\r
108       <xsl:with-param name="class">ext</xsl:with-param>\r
109     </xsl:call-template>\r
110   </xsl:template>\r
111 \r
112   <xsl:template match="a[not(@href)]">\r
113     <xsl:call-template name="add-class">\r
114       <xsl:with-param name="class">anchor</xsl:with-param>\r
115     </xsl:call-template>\r
116   </xsl:template>\r
117 \r
118   <xsl:template match="div[@class='memdoc']/p[1]">\r
119     <xsl:call-template name="add-class">\r
120       <xsl:with-param name="class">memtitle</xsl:with-param>\r
121     </xsl:call-template>\r
122   </xsl:template>\r
123 \r
124   <xsl:template match="p[starts-with(text(),'Definition at line ')]">\r
125     <xsl:call-template name="add-class">\r
126       <xsl:with-param name="class">sourceline</xsl:with-param>\r
127     </xsl:call-template>\r
128   </xsl:template>\r
129 \r
130   <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'References ')]">\r
131     <xsl:call-template name="add-class">\r
132       <xsl:with-param name="class">references</xsl:with-param>\r
133     </xsl:call-template>\r
134   </xsl:template>\r
135 \r
136   <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Referenced by ')]">\r
137     <xsl:call-template name="add-class">\r
138       <xsl:with-param name="class">referencedby</xsl:with-param>\r
139     </xsl:call-template>\r
140   </xsl:template>\r
141 \r
142   <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Reimplemented from ')]">\r
143     <xsl:call-template name="add-class">\r
144       <xsl:with-param name="class">reimplementedfrom</xsl:with-param>\r
145     </xsl:call-template>\r
146   </xsl:template>\r
147 \r
148   <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Reimplemented in ')]">\r
149     <xsl:call-template name="add-class">\r
150       <xsl:with-param name="class">reimplementedin</xsl:with-param>\r
151     </xsl:call-template>\r
152   </xsl:template>\r
153 \r
154   <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Implemented in ')]">\r
155     <xsl:call-template name="add-class">\r
156       <xsl:with-param name="class">implementedin</xsl:with-param>\r
157     </xsl:call-template>\r
158   </xsl:template>\r
159 \r
160   <!-- Remove external items from the namespace index -->\r
161   <xsl:template match="div[@id='content2']/table[contains(preceding-sibling::h1/text(),'Namespace Reference')]/tr[td[@class='memItemRight']/a[1][@class='elRef'][@doxygen]]">\r
162   </xsl:template>\r
163   \r
164   <!-- Remove [external] references from the modules page -->\r
165   <xsl:template match="div[@id='content2']/ul/li[a/@class='elRef'][a/@doxygen][code/text()='[external]'][not(ul)]">\r
166   </xsl:template>\r
167   \r
168 </xsl:stylesheet>\r