gtk-doc xml patch (take 3)



I have attached a new version of my patch to get gtkdoc-mkhtml to use xsltproc when working with XML input. I ported accross most of the visual aspects of the gtk-doc.dsl file. It now does the navigation headers and footers, and shades the function prototypes and arg descriptions.

I put a sample of the output up at:
   http://www.daa.com.au/~james/files/xml-html/libglade.html

James.

--
Email: james daa com au              | Linux.conf.au 2003 Call for Papers out
WWW:   http://www.daa.com.au/~james/ |   http://conf.linux.org.au/cfp.html


Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk-doc/ChangeLog,v
retrieving revision 1.113
diff -u -p -r1.113 ChangeLog
--- ChangeLog	28 May 2002 23:43:28 -0000	1.113
+++ ChangeLog	2 Jun 2002 06:03:48 -0000
@@ -1,3 +1,18 @@
+2002-05-31  James Henstridge  <james daa com au>
+
+	* gtkdoc-mkdb.in (OutputSGML): put XIncludes in the $book_bottom
+	variable.
+	(OutputBook): add the XInclude namespace declaration to the book
+	element.
+
+	* gtkdoc-mkhtml.in (declaration): if the document looks like XML,
+	process it with xsltproc.
+
+	* configure.in: check for xsltproc.
+
+	* gtk-doc.xsl: start of XSLT template for converting docbook/xml
+	to HTML.
+
 2002-05-29  Matthias Clasen  <maclas gmx de>
 
 	Fixes for #77193:
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/gtk-doc/Makefile.am,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile.am
--- Makefile.am	17 May 2002 23:45:25 -0000	1.16
+++ Makefile.am	2 Jun 2002 06:03:48 -0000
@@ -15,11 +15,13 @@ gtkdocdata_DATA = \
 	gtkdoc-common.pl	\
         gtk-doc.dsl		\
 	gtk-doc.dcl		\
+	gtk-doc.xsl		\
 	xml.dcl
 
 EXTRA_DIST= \
 	gtk-doc.spec.in	\
 	gtk-doc.dcl  	\
+	gtk-doc.xsl	\
 	xml.dcl
 
 dist-hook:
Index: configure.in
===================================================================
RCS file: /cvs/gnome/gtk-doc/configure.in,v
retrieving revision 1.22
diff -u -p -r1.22 configure.in
--- configure.in	1 Feb 2002 23:05:39 -0000	1.22
+++ configure.in	2 Jun 2002 06:03:49 -0000
@@ -27,6 +27,13 @@ if test -z "$JADE"; then
   fi
 fi
 
+dnl
+dnl Check for xsltproc
+dnl
+AC_PATH_PROG(XSLTPROC, xsltproc)
+if test -z "$XSLTPROC"; then
+  AC_MSG_ERROR([xsltproc not found])
+fi
 
 dnl
 dnl Set PACKAGE_DATA_DIR so we can find the script containing common routines.
Index: gtkdoc-mkdb.in
===================================================================
RCS file: /cvs/gnome/gtk-doc/gtkdoc-mkdb.in,v
retrieving revision 1.49
diff -u -p -r1.49 gtkdoc-mkdb.in
--- gtkdoc-mkdb.in	28 May 2002 23:43:28 -0000	1.49
+++ gtkdoc-mkdb.in	2 Jun 2002 06:03:56 -0000
@@ -61,13 +61,12 @@ my %optctl = (module => \$MODULE,
 	      'output-format' => \$OUTPUT_FORMAT);
 GetOptions(\%optctl, "module=s", "source-dir:s", "output-dir:s", "version", "outputallsymbols", "main-sgml-file:s", "help", "sgml-mode", "output-format:s");
 
-my $empty_element_end;
+my ($empty_element_end);
 
 if (lc($OUTPUT_FORMAT) eq "xml") {
     $OUTPUT_FORMAT = "xml";
     $empty_element_end = "/>";
-}
-else {
+} else {
     $OUTPUT_FORMAT = "sgml";
     $empty_element_end = ">";
 }
@@ -337,8 +336,12 @@ sub OutputSGML {
 	    }
 
 	    if ($num_symbols > 0) {
-		$book_top .= "<!ENTITY $section_id SYSTEM \"sgml/$file\">\n";
-		$book_bottom .= "    &$section_id;\n";
+		if (lc($OUTPUT_FORMAT) eq "xml") {
+		    $book_bottom .= "    <xi:include href=\"xml/$file.xml\"/>\n";
+		} else {
+		    $book_top.="<!ENTITY $section_id SYSTEM \"sgml/$file.sgml\">\n";
+		    $book_bottom .= "    &$section_id;\n";
+		}
 
 		if ($section_includes eq "") {
 		    $section_includes = $includes;
@@ -1188,6 +1191,14 @@ sub OutputSGMLFile {
     # since it changes every day (and it is only used in the man pages):
     # "<refentry id="$section_id" revision="$mday $month $year">"
 
+    if (lc($OUTPUT_FORMAT) eq "xml") {
+        print OUTPUT <<EOF;
+<?xml version="1.0"?>
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD Docbook XML V4.1.2//EN" 
+                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd";>
+EOF
+    }
+
     print OUTPUT <<EOF;
 <refentry id="$section_id">
 <refmeta>
@@ -1278,20 +1289,21 @@ sub OutputBook {
 	  print OUTPUT <<EOF;
 <?xml version="1.0"?>
 <!DOCTYPE book PUBLIC "-//OASIS//DTD Docbook XML V4.1.2//EN" 
-               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"; [
+               "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd";>
+<book id="index" xmlns:xi="http://www.w3.org/2001/XInclude";>
 EOF
-      }
-      else {
+      } else {
 	print OUTPUT <<EOF;
 <!doctype book PUBLIC "-//DavenPort//DTD DocBook V3.0//EN" [
 EOF
-	}
-
-      print OUTPUT $book_top;
-
-      print OUTPUT <<EOF;
+        print OUTPUT $book_top;
+        print OUTPUT <<EOF;
 ]>
 <book id="index">
+EOF
+      }
+
+print OUTPUT <<EOF;
   <bookinfo>
     <title>[Insert name here] Reference Manual</title>
   </bookinfo>
Index: gtkdoc-mkhtml.in
===================================================================
RCS file: /cvs/gnome/gtk-doc/gtkdoc-mkhtml.in,v
retrieving revision 1.8
diff -u -p -r1.8 gtkdoc-mkhtml.in
--- gtkdoc-mkhtml.in	17 May 2002 23:45:25 -0000	1.8
+++ gtkdoc-mkhtml.in	2 Jun 2002 06:03:56 -0000
@@ -23,7 +23,9 @@ gtkdocdir= datadir@/gtk-doc
 declaration=$gtkdocdir/gtk-doc.dcl
 
 if head -1 $document | grep -q "<?xml"; then
-  declaration=$gtkdocdir/xml.dcl
+  is_xml=true
+else
+  is_xml=false
 fi
 
 # Delete the old index.sgml file, if it exists.
@@ -31,7 +33,13 @@ if test -f index.sgml; then
       rm -f index.sgml
 fi
 
- JADE@ -t sgml -w no-idref -d $gtkdocdir/gtk-doc.dsl $declaration $document
+if $is_xml; then
+  @XSLTPROC@ --xinclude $gtkdocdir/gtk-doc.xsl $document
+else
+  @JADE@ -t sgml -w no-idref -d $gtkdocdir/gtk-doc.dsl \
+      $gtkdocdir/gtk-doc.dcl $document
+fi
+
 sed s%href=\"%href=\"$module/% < index.sgml > index.sgml.tmp && mv index.sgml.tmp index.sgml
 
 echo "timestamp" > ../html.stamp
--- /dev/null	Fri Aug 31 04:30:55 2001
+++ gtk-doc.xsl	Sun Jun  2 14:02:37 2002
@@ -0,0 +1,319 @@
+<?xml version='1.0'?> <!--*- mode: xml -*-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+                version='1.0'
+                xmlns="http://www.w3.org/TR/xhtml1/transitional";
+                exclude-result-prefixes="#default">
+
+  <!-- import the chunked XSL stylesheet -->
+  <xsl:import href="http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl"/>
+
+  <xsl:output method="xml" indent="yes"/>
+
+  <!-- change some parameters -->
+  <xsl:param name="toc.section.depth">1</xsl:param>
+
+  <xsl:param name="chapter.autolabel" select="0"/>
+  <xsl:param name="use.id.as.filename" select="'1'"/>
+  <xsl:param name="html.ext" select="'.html'"/>
+
+  <!-- ========================================================= -->
+  <!-- template to create the index.sgml anchor index -->
+
+  <xsl:template match="book|article">
+    <xsl:apply-imports/>
+
+    <!-- generate the index.sgml href index -->
+    <xsl:call-template name="generate.index"/>
+  </xsl:template>    
+
+  <xsl:template name="generate.index">
+    <xsl:call-template name="write.text.chunk">
+      <xsl:with-param name="filename" select="'index.sgml'"/>
+      <xsl:with-param name="content">
+        <!-- check all anchor and refentry elements -->
+        <xsl:apply-templates select="//anchor|refentry"
+                             mode="generate.index.mode"/>
+      </xsl:with-param>
+      <xsl:with-param name="encoding" select="'utf-8'"/>
+    </xsl:call-template>
+  </xsl:template>
+
+  <xsl:template match="*" mode="generate.index.mode">
+    <xsl:if test="not(@href)">
+      <xsl:text>&lt;ANCHOR id=&quot;</xsl:text>
+      <xsl:value-of select="@id"/>
+      <xsl:text>&quot; href=&quot;</xsl:text>
+      <xsl:call-template name="href.target"/>
+      <xsl:text>&quot;&gt;
+</xsl:text>
+    </xsl:if>
+  </xsl:template>
+
+  <!-- ========================================================= -->
+  <!-- template to output gtkdoclink elements for the unknown targets -->
+
+  <xsl:template match="link">
+    <xsl:choose>
+      <xsl:when test="id(@linkend)">
+        <xsl:apply-imports/>
+      </xsl:when>
+      <xsl:otherwise>
+        <GTKDOCLINK HREF="{ linkend}">
+          <xsl:apply-templates/>
+        </GTKDOCLINK>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
+  <!-- ========================================================= -->
+  <!-- Below are the visual portions of the stylesheet.  They provide
+       the normal gtk-doc output style. -->
+
+  <xsl:param name="shade.verbatim" select="0"/>
+  <xsl:param name="refentry.separator" select="0"/>
+
+  <xsl:template match="refsect2">
+    <xsl:if test="preceding-sibling::refsect2">
+      <hr/>
+    </xsl:if>
+    <xsl:apply-imports/>
+  </xsl:template>
+
+  <xsl:template name="user.head.content">
+    <style>
+      <xsl:text>
+        .synopsis, .programlisting {
+            background: #D6E8FF;
+            padding: 4px;
+        }
+        .informaltable {
+            background: #FFD0D0;
+            padding: 4px;
+        }
+      </xsl:text>
+    </style>
+  </xsl:template>
+
+  <xsl:template match="title" mode="book.titlepage.recto.mode">
+    <table width="100%" border="0" bgcolor="#000000"
+           cellpadding="1" cellspacing="0">
+      <tr>
+        <th align="center" valign="center">
+          <p class="{name(.)}">
+            <font color="#FFFFFF" size="7">
+              <xsl:value-of select="."/>
+            </font>
+          </p>
+        </th>
+      </tr>
+    </table>
+  </xsl:template>
+
+  <xsl:template name="header.navigation">
+    <xsl:param name="prev" select="/foo"/>
+    <xsl:param name="next" select="/foo"/>
+    <xsl:variable name="home" select="/*[1]"/>
+    <xsl:variable name="up" select="parent::*"/>
+
+    <xsl:if test="$suppress.navigation = '0' and $home != .">
+      <table bgcolor="#000000" width="100%" summary="Navigation header"
+             cellpadding="1" cellspacing="0">
+        <tr>
+          <th colspan="4" align="center">
+            <font color="#FFFFFF" size="5">
+              <xsl:apply-templates select="$home" mode="object.title.markup"/>
+            </font>
+          </th>
+        </tr>
+        <tr>
+          <td width="25%" bgcolor="#C00000" align="left">
+            <xsl:if test="count($prev) > 0">
+              <a accesskey="p">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$prev"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:text>&lt;&lt;&lt;&#160;</xsl:text>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-prev</xsl:with-param>
+                    </xsl:call-template>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+          <td width="25%" bgcolor="#0000C0" align="center">
+            <xsl:if test="$home != .">
+              <a accesskey="h">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$home"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-home</xsl:with-param>
+                    </xsl:call-template>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+          <td width="25%" bgcolor="#00C000" align="center">
+            <xsl:if test="count($up) > 0 and $up != $home">
+              <a accesskey="u">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$up"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-up</xsl:with-param>
+                    </xsl:call-template>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+          <td width="25%" bgcolor="#C00000" align="right">
+            <xsl:if test="count($next) > 0">
+              <a accesskey="n">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$next"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-next</xsl:with-param>
+                    </xsl:call-template>
+                    <xsl:text>&#160;&gt;&gt;&gt;</xsl:text>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+        </tr>
+      </table>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template name="footer.navigation">
+    <xsl:param name="prev" select="/foo"/>
+    <xsl:param name="next" select="/foo"/>
+    <xsl:variable name="home" select="/*[1]"/>
+    <xsl:variable name="up" select="parent::*"/>
+
+    <xsl:if test="$suppress.navigation = '0'">
+      <table bgcolor="#000000" width="100%" summary="Navigation footer"
+             cellpadding="1" cellspacing="0">
+        <tr>
+          <td width="25%" bgcolor="#C00000" align="left">
+            <xsl:if test="count($prev) > 0">
+              <a accesskey="p">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$prev"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:text>&lt;&lt;&lt;&#160;</xsl:text>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-prev</xsl:with-param>
+                    </xsl:call-template>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+          <td width="25%" bgcolor="#0000C0" align="center">
+            <xsl:if test="$home != .">
+              <a accesskey="h">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$home"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-home</xsl:with-param>
+                    </xsl:call-template>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+          <td width="25%" bgcolor="#00C000" align="center">
+            <xsl:if test="count($up) > 0 and $up != $home">
+              <a accesskey="u">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$up"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-up</xsl:with-param>
+                    </xsl:call-template>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+          <td width="25%" bgcolor="#C00000" align="right">
+            <xsl:if test="count($next) > 0">
+              <a accesskey="n">
+                <xsl:attribute name="href">
+                  <xsl:call-template name="href.target">
+                    <xsl:with-param name="object" select="$next"/>
+                  </xsl:call-template>
+                </xsl:attribute>
+                <font color="#FFFFFF" size="3">
+                  <b>
+                    <xsl:call-template name="gentext">
+                      <xsl:with-param name="key">nav-next</xsl:with-param>
+                    </xsl:call-template>
+                    <xsl:text>&#160;&gt;&gt;&gt;</xsl:text>
+                  </b>
+                </font>
+              </a>
+            </xsl:if>
+          </td>
+        </tr>
+        <tr>
+          <td colspan="2" align="left">
+            <xsl:if test="count($prev) > 0">
+              <font color="#FFFFFF" size="3">
+                <b>
+                  <xsl:apply-templates select="$prev"
+                                       mode="object.title.markup"/>
+                </b>
+              </font>
+            </xsl:if>
+          </td>
+          <td colspan="2" align="right">
+            <xsl:if test="count($next) > 0">
+              <font color="#FFFFFF" size="3">
+                <b>
+                  <xsl:apply-templates select="$next"
+                                       mode="object.title.markup"/>
+                </b>
+              </font>
+            </xsl:if>
+          </td>
+        </tr>
+      </table>
+    </xsl:if>
+  </xsl:template>
+
+</xsl:stylesheet>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]