Utils: Revamp documentation overview and add some missing docs
[senf.git] / doclib / html-munge.xsl
index 644c546..6bc7038 100644 (file)
@@ -1,21 +1,55 @@
 <?xml version="1.0" encoding="utf-8"?>\r
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">\r
 \r
-  <xsl:output method="html" encoding="html"/>\r
+  <xsl:output \r
+    method="html" \r
+    encoding="html" \r
+    doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"\r
+    doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>\r
+\r
+  <xsl:param name="topdir" select="''"/>\r
   \r
   <xsl:template match="*">\r
     <xsl:copy>\r
-      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>\r
+      <xsl:call-template name="copy-attributes"/>\r
       <xsl:apply-templates/>\r
     </xsl:copy>\r
   </xsl:template>\r
+\r
+  <xsl:template name="copy-attributes">\r
+    <xsl:for-each select="@*">\r
+      <xsl:attribute name="{name(current())}">\r
+        <xsl:choose>\r
+          <xsl:when test="contains(current(),'@TOPDIR@')">\r
+            <xsl:value-of select="substring-before(current(),'@TOPDIR@')"/>\r
+            <xsl:value-of select="$topdir"/>\r
+            <xsl:value-of select="substring-after(current(),'@TOPDIR@')"/>\r
+          </xsl:when>\r
+          <xsl:otherwise>\r
+            <xsl:value-of select="current()"/>\r
+          </xsl:otherwise>\r
+        </xsl:choose>\r
+      </xsl:attribute>\r
+    </xsl:for-each>\r
+  </xsl:template>\r
+\r
+  <!-- Remove the automatically inserted search form (we build our own) -->\r
+  <xsl:template match="li[form]"> \r
+  </xsl:template>\r
+  \r
+  <!-- Replace @TOPDIR@ with  relative top directory path -->\r
+  <xsl:template match="@*[contains(current(),'@TOPDIR@')]">\r
+    <xsl:value-of select="substring-before(current(),'@TOPDIR')"/>\r
+    <xsl:value-of select="$topdir"/>\r
+    <xsl:value-of select="substring-after(current(),'@TOPDIR')"/>\r
+  </xsl:template>\r
   \r
   <!-- Add 'class' attribute to some special paragraphs/lists -->\r
   \r
   <xsl:template name="add-class">\r
     <xsl:param name="class"/>\r
     <xsl:copy>\r
-      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>\r
+      <xsl:call-template name="copy-attributes"/>\r
       <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>\r
       <xsl:apply-templates/>\r
     </xsl:copy>\r
     </xsl:call-template>\r
   </xsl:template>\r
 \r
+  <xsl:template match="dl[dt/b/text()='Implementation note:']">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">implementation</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
   <xsl:template match="table[descendant::td[@class='memItemLeft']]">\r
     <xsl:call-template name="add-class">\r
       <xsl:with-param name="class">members</xsl:with-param>\r
     </xsl:call-template>\r
   </xsl:template>\r
 \r
+  <xsl:template match="a[@href=string(current())]" priority="1">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">literal</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="a[contains(@href,'http://')]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">ext</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="a[not(@href)]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">anchor</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="div[@class='memdoc']/p[1]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">memtitle</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="p[starts-with(text(),'Definition at line ')]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">sourceline</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'References ')]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">references</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Referenced by ')]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">referencedby</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Reimplemented from ')]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">reimplementedfrom</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Reimplemented in ')]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">reimplementedin</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="div[@class='memdoc']/p[starts-with(text(),'Implemented in ')]">\r
+    <xsl:call-template name="add-class">\r
+      <xsl:with-param name="class">implementedin</xsl:with-param>\r
+    </xsl:call-template>\r
+  </xsl:template>\r
+\r
+  <!-- Remove external items from the namespace index -->\r
+  <xsl:template match="div[@id='content2']/table[contains(preceding-sibling::h1/text(),'Namespace Reference')]/tr[td[@class='memItemRight']/a[1][@class='elRef'][@doxygen]]">\r
+  </xsl:template>\r
+  \r
+  <!-- Remove [external] references from the modules page -->\r
+  <xsl:template match="div[@id='content2']/ul/li[a/@class='elRef'][a/@doxygen][code/text()='[external]'][not(ul)]">\r
+  </xsl:template>\r
+  \r
 </xsl:stylesheet>\r