From 33998aa1a72ec2c31f4ad80acd72edb118407870 Mon Sep 17 00:00:00 2001
From: g0dil <g0dil@wiback.org>
Date: Thu, 25 Jan 2007 16:12:14 +0000
Subject: [PATCH] Add XSLT postprocessing of HTML files to fix browser problems

---
 SConstruct                    |  1 +
 Socket/ClientSocketHandle.ct  |  4 ++-
 Socket/ClientSocketHandle.cti |  4 ++-
 Socket/ClientSocketHandle.hh  |  6 +++-
 Socket/SocketPolicy.ct        |  4 ++-
 Socket/SocketPolicy.hh        |  2 +-
 Socket/SocketPolicy.ih        |  4 +++
 doclib/html-munge.xsl         | 54 +++++++++++++++++++++++++++++++++++
 doclib/senf.css               | 27 +++++++++---------
 senfscons/SENFSCons.py        | 17 +++++++++--
 10 files changed, 102 insertions(+), 21 deletions(-)
 create mode 100644 doclib/html-munge.xsl

diff --git a/SConstruct b/SConstruct
index 2bd5c4533..79462692f 100644
--- a/SConstruct
+++ b/SConstruct
@@ -14,6 +14,7 @@ env.Append(
    CPPPATH = [ '#' ],
    LIBS = [ 'iberty' ],
    DOXY_XREF_TYPES = [ 'bug', 'fixme', 'todo', 'idea' ],
+   DOXY_HTML_XSL = '#/doclib/html-munge.xsl',
 )
 
 import datetime
diff --git a/Socket/ClientSocketHandle.ct b/Socket/ClientSocketHandle.ct
index 0c6b61b86..3f5112fc1 100644
--- a/Socket/ClientSocketHandle.ct
+++ b/Socket/ClientSocketHandle.ct
@@ -20,7 +20,9 @@
 // Free Software Foundation, Inc.,
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-// Definition of non-inline template functions
+/** \file
+    \brief senf::ClientSocketHandle non-inline template implementation
+ */
 
 //#include "ClientSocketHandle.ih"
 
diff --git a/Socket/ClientSocketHandle.cti b/Socket/ClientSocketHandle.cti
index c6a934868..669aa38ff 100644
--- a/Socket/ClientSocketHandle.cti
+++ b/Socket/ClientSocketHandle.cti
@@ -20,7 +20,9 @@
 // Free Software Foundation, Inc.,
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-// Definition of inline template functions
+/** \file
+    \brief senf::ClientSocketHandle inline template implementation
+ */
 
 //#include "ClientSocketHandle.ih"
 
diff --git a/Socket/ClientSocketHandle.hh b/Socket/ClientSocketHandle.hh
index a1f3b9243..96267f5df 100644
--- a/Socket/ClientSocketHandle.hh
+++ b/Socket/ClientSocketHandle.hh
@@ -20,6 +20,10 @@
 // Free Software Foundation, Inc.,
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+/** \file
+    \brief senf::ClientSocketHandle public header
+ */
+
 #ifndef HH_ClientSocketHandle_
 #define HH_ClientSocketHandle_ 1
 
@@ -37,7 +41,7 @@ namespace senf {
     
     template <class Policy> class ServerSocketHandle;
 
-    /** \brief
+    /** \brief Generic SocketHandle with client interface
 	
 	\todo Move all not template-parameter dependent code into a
 	non-template base class
diff --git a/Socket/SocketPolicy.ct b/Socket/SocketPolicy.ct
index 3f07f25c8..d8b2f2265 100644
--- a/Socket/SocketPolicy.ct
+++ b/Socket/SocketPolicy.ct
@@ -20,7 +20,9 @@
 // Free Software Foundation, Inc.,
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-// Definition of non-inline template functions
+/** \file 
+    \brief Policy Framework non-inline template implemenation
+ */
 
 #include "SocketPolicy.ih"
 
diff --git a/Socket/SocketPolicy.hh b/Socket/SocketPolicy.hh
index 297a469aa..eb453aff2 100644
--- a/Socket/SocketPolicy.hh
+++ b/Socket/SocketPolicy.hh
@@ -21,7 +21,7 @@
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 /** \file
-    \brief SocketPolicy public header
+    \brief Policy Framework public header
 
     \todo We should probably remove BufferingPolicy from the
     interface, it does not make much sense (how did I come to include
diff --git a/Socket/SocketPolicy.ih b/Socket/SocketPolicy.ih
index fac273ad1..0e2b58fd6 100644
--- a/Socket/SocketPolicy.ih
+++ b/Socket/SocketPolicy.ih
@@ -20,6 +20,10 @@
 // Free Software Foundation, Inc.,
 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
+/** \file
+    \brief Policy Framework internal header
+ */
+
 #ifndef IH_SocketPolicy_
 #define IH_SocketPolicy_ 1
 
diff --git a/doclib/html-munge.xsl b/doclib/html-munge.xsl
new file mode 100644
index 000000000..241bc8b86
--- /dev/null
+++ b/doclib/html-munge.xsl
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                version="1.0">
+
+  <xsl:output method="html" encoding="html" />
+
+  <xsl:template match="/">
+    <html>
+      <body bgcolor="#FFFFFF">
+        <xsl:apply-templates/>
+      </body>
+    </html>
+  </xsl:template>
+
+  <xsl:template match="dl[dt/b/a/text()='Bug:']">
+    <xsl:copy>
+      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
+      <xsl:attribute name="class">xref-bug</xsl:attribute>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+
+  <xsl:template match="dl[dt/b/a/text()='Fixme:']">
+    <xsl:copy>
+      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
+      <xsl:attribute name="class">xref-fixme</xsl:attribute>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+
+  <xsl:template match="dl[dt/b/a/text()='Todo:']">
+    <xsl:copy>
+      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
+      <xsl:attribute name="class">xref-todo</xsl:attribute>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+
+  <xsl:template match="dl[dt/b/a/text()='Idea:']">
+    <xsl:copy>
+      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
+      <xsl:attribute name="class">xref-idea</xsl:attribute>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+
+  <xsl:template match="*">
+    <xsl:copy>
+      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+
+</xsl:stylesheet>
diff --git a/doclib/senf.css b/doclib/senf.css
index f5f2de4e5..ddfeff0c0 100644
--- a/doclib/senf.css
+++ b/doclib/senf.css
@@ -175,25 +175,24 @@ dl.bug, dl.fixme, dl.todo, dl.idea {
 	padding: 0 10px;
 }
 
-dl:contains("Bug:"), dl:contains("Fix:"), dl:contains("Todo:"), dl:contains("Idea:") { 
+dl.xref-bug, dl.xref-fix, dl.xref-todo, dl.xref-idea { 
 	border: 1px solid #CC8888;
-	padding: 4px;
+	padding: 2px 3px;
+	margin: 4px 0;
 	background-color: #FFEEEE;
 	color: #666666;
-	font-size: 6px;
-	line-height: 6px;
+	font-size: 9px;
 	overflow: hidden;
-	height: 6px;
 }
 
-dl:contains("Bug:"):hover, dl:contains("Fix:"):hover, 
-dl:contains("Todo:"):hover, dl:contains("Idea:"):hover { 
-	line-height: inherit;
-	font-size: inherit;
-	height: auto;
+dl.xref-bug dt, dl.xref-fix dt, dl.xref-todo dt, dl.xref-idea dt,
+dl.xref-bug dd, dl.xref-fix dd, dl.xref-todo dd, dl.xref-idea dd { 
+	display: inline;
+	margin: 0;
+	padding: 0;
 }
 
-dl:contains("Bug:") a, dl:contains("Fix:") a, dl:contains("Todo:") a, dl:contains("Idea:") a { 
+dl.xref-bug a, dl.xref-fix a, dl.xref-todo a, dl.xref-idea a { 
 	color: #6666FF;
 }
 
@@ -202,7 +201,7 @@ dl.fixme {
 	background-color: #FFFFDD;
 }
 
-dl:contains("Fix:") { 
+dl.xref-fix { 
 	border-color: #CCCC88;
 	background-color: #FFFFEE;
 }
@@ -212,7 +211,7 @@ dl.todo {
 	background-color: #DDFFDD;
 }
 
-dl:contains("Todo:") { 
+dl.xref-todo { 
 	border-color: #88CC88;
 	background-color: #EEFFEE;
 }
@@ -222,7 +221,7 @@ dl.idea {
 	background-color: #EEEEEE;
 }
 
-dl:contains("Idea:") { 
+dl.xref-idea { 
 	border-color:  #CCCCCC;
 	background-color: #F8F8F8;
 }
diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py
index d2e0c4882..a9961d60a 100644
--- a/senfscons/SENFSCons.py
+++ b/senfscons/SENFSCons.py
@@ -151,11 +151,13 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
     #        ||| WITHIN THE DOXYGEN BUILDER
     docs = env.Doxygen(doxyfile)[:]
     xmlnode = None
+    htmlnode = None
     tagnode = None
     for doc in docs:
         if isinstance(doc,SCons.Node.FS.Dir): continue
         if doc.name == 'xml.stamp' : xmlnode = doc
-        if os.path.splitext(doc.name)[1] == '.stamp' : continue # file stamp
+        if doc.name == 'html.stamp' : htmlnode = doc
+        if os.path.splitext(doc.name)[1] == '.stamp' : continue # ignore other file stamps
         # otherwise it must be the tag file
         tagnode = doc
 
@@ -164,10 +166,21 @@ def Doxygen(env, doxyfile = "Doxyfile", extra_sources = []):
         # references
         env.AddPostAction(
             docs,
-            env.Action("xsltproc -o %(target)s.temp %(template)s %(target)s && mv %(target)s.temp %(target)s"
+            env.Action("xsltproc --nonet -o %(target)s.temp %(template)s %(target)s && mv %(target)s.temp %(target)s"
                        % { 'target': tagnode.abspath,
                            'template': os.path.join(basedir,"tagmunge.xsl") }))
 
+    if htmlnode and env.get('DOXY_HTML_XSL'):
+        xslfile = env.File(env['DOXY_HTML_XSL'])
+        env.AddPostAction(
+            docs,
+            env.Action(("for html in %s/*.html; do " +
+                        "xsltproc --nonet --html -o $${html}.new %s $${html} && mv $${html}.new $${html}; " +
+                        "done")
+                       % (htmlnode.dir.abspath, xslfile.abspath)))
+        for doc in docs:
+            env.Depends(doc,xslfile)
+
     if xmlnode:
         xrefs = []
         for type in env.get("DOXY_XREF_TYPES",[ "bug", "todo" ]):
-- 
GitLab