Minor documentation improvements.
[pub/USBasp.git] / LUFA / StudioIntegration / HV1 / lufa_docbook_transform.xslt
index 4247b47..680cea5 100644 (file)
@@ -47,6 +47,7 @@
                <xsl:variable name="book.title">
                        <xsl:call-template name="generate.book.title"/>
                </xsl:variable>
                <xsl:variable name="book.title">
                        <xsl:call-template name="generate.book.title"/>
                </xsl:variable>
+
                <xsl:variable name="book.id">
                        <xsl:call-template name="generate.book.id">
                                <xsl:with-param name="book.title" select="$book.title"/>
                <xsl:variable name="book.id">
                        <xsl:call-template name="generate.book.id">
                                <xsl:with-param name="book.title" select="$book.title"/>
 
                        <!-- Add index chapter -->
                        <xsl:call-template name="generate.top.level.page">
 
                        <!-- Add index chapter -->
                        <xsl:call-template name="generate.top.level.page">
-                               <xsl:with-param name="top.level.page" select="compounddef[@kind = 'page' and contains(@id, 'index')]"/>
+                               <xsl:with-param name="top.level.page" select="compounddef[@kind = 'page' and @id = 'indexpage']"/>
+                               <xsl:with-param name="top.level.page.title" select="'Library Information'"/>
                        </xsl:call-template>
 
                        <!-- Add free-floating chapters -->
                        </xsl:call-template>
 
                        <!-- Add free-floating chapters -->
-                       <xsl:for-each select="compounddef[@kind = 'page' and not(contains(@id, 'index'))]">
+                       <xsl:for-each select="compounddef[@kind = 'page' and not(@id = 'indexpage')]">
                                <xsl:if test="not(//innerpage[@refid = current()/@id])">
                                        <xsl:call-template name="generate.top.level.page">
                                                <xsl:with-param name="top.level.page" select="current()"/>
                                <xsl:if test="not(//innerpage[@refid = current()/@id])">
                                        <xsl:call-template name="generate.top.level.page">
                                                <xsl:with-param name="top.level.page" select="current()"/>
@@ -72,7 +74,7 @@
                                </xsl:if>
                        </xsl:for-each>
 
                                </xsl:if>
                        </xsl:for-each>
 
-                       <!-- Add Module chapter -->
+                       <!-- Add Modules chapter -->
                        <chapter>
                                <title>Modules</title>
                                <xsl:for-each select="compounddef[@kind = 'group']">
                        <chapter>
                                <title>Modules</title>
                                <xsl:for-each select="compounddef[@kind = 'group']">
 
        <xsl:template name="generate.top.level.page">
                <xsl:param name="top.level.page"/>
 
        <xsl:template name="generate.top.level.page">
                <xsl:param name="top.level.page"/>
+               <xsl:param name="top.level.page.title" select="$top.level.page/title"/>
 
                <chapter id="{$top.level.page/@id}">
                        <title>
 
                <chapter id="{$top.level.page/@id}">
                        <title>
-                               <xsl:value-of select="$top.level.page/title"/>
+                               <xsl:value-of select="$top.level.page.title"/>
                        </title>
 
                        <xsl:apply-templates select="$top.level.page/detaileddescription"/>
                        </title>
 
                        <xsl:apply-templates select="$top.level.page/detaileddescription"/>
                </chapter>
        </xsl:template>
 
                </chapter>
        </xsl:template>
 
-       <xsl:template match="compounddef">
-               <!-- Discard compounddef elements unless a later template matches -->
-       </xsl:template>
-
        <xsl:template match="compounddef[@kind = 'page']">
                <section id="{@id}">
                        <title>
        <xsl:template match="compounddef[@kind = 'page']">
                <section id="{@id}">
                        <title>
                                <xsl:value-of select="title"/>
                        </title>
 
                                <xsl:value-of select="title"/>
                        </title>
 
-                       <xsl:variable name="book.title">
-                               <xsl:call-template name="generate.book.title"/>
-                       </xsl:variable>
-
                        <xsl:variable name="name">
                                <xsl:choose>
                                        <xsl:when test="contains(compoundname, '_')">
                                                <xsl:value-of select="translate(compoundname, '_', '/')"/>
                                                <xsl:text>.h</xsl:text>
                                        </xsl:when>
                        <xsl:variable name="name">
                                <xsl:choose>
                                        <xsl:when test="contains(compoundname, '_')">
                                                <xsl:value-of select="translate(compoundname, '_', '/')"/>
                                                <xsl:text>.h</xsl:text>
                                        </xsl:when>
+
                                        <xsl:otherwise>
                                                <xsl:value-of select="compoundname"/>
                                                <xsl:text>.h</xsl:text>
                                        <xsl:otherwise>
                                                <xsl:value-of select="compoundname"/>
                                                <xsl:text>.h</xsl:text>
                                                <xsl:value-of select="translate(compoundname, '_', '.')"/>
                                                <xsl:text>.h</xsl:text>
                                        </xsl:when>
                                                <xsl:value-of select="translate(compoundname, '_', '.')"/>
                                                <xsl:text>.h</xsl:text>
                                        </xsl:when>
+
                                        <xsl:otherwise>
                                                <xsl:value-of select="compoundname"/>
                                                <xsl:text>.h</xsl:text>
                                        <xsl:otherwise>
                                                <xsl:value-of select="compoundname"/>
                                                <xsl:text>.h</xsl:text>
                                        <xsl:when test="@kind = 'struct'">
                                                <xsl:text>Struct </xsl:text>
                                        </xsl:when>
                                        <xsl:when test="@kind = 'struct'">
                                                <xsl:text>Struct </xsl:text>
                                        </xsl:when>
+
                                        <xsl:when test="@kind = 'union'">
                                                <xsl:text>Union </xsl:text>
                                        </xsl:when>
                                </xsl:choose>
                                        <xsl:when test="@kind = 'union'">
                                                <xsl:text>Union </xsl:text>
                                        </xsl:when>
                                </xsl:choose>
+
                                <xsl:value-of select="$name"/>
                        </title>
 
                                <xsl:value-of select="$name"/>
                        </title>
 
 
                        <xsl:apply-templates select="detaileddescription"/>
 
 
                        <xsl:apply-templates select="detaileddescription"/>
 
-                       <xsl:for-each select="sectiondef[@kind='public-attrib']">
+                       <xsl:for-each select="sectiondef[@kind = 'public-attrib']">
                                <table tabstyle="striped">
                                        <title>
                                                <xsl:value-of select="$name"/>
                                <table tabstyle="striped">
                                        <title>
                                                <xsl:value-of select="$name"/>
                                                        <xsl:for-each select="memberdef">
                                                                <row id="{@id}" xreflabel="{name}">
                                                                        <entry>
                                                        <xsl:for-each select="memberdef">
                                                                <row id="{@id}" xreflabel="{name}">
                                                                        <entry>
-                                                                               <xsl:apply-templates select="type"/>
+                                                                               <xsl:value-of select="type"/>
                                                                        </entry>
                                                                        <entry>
                                                                                <xsl:value-of select="name"/>
                                                                        </entry>
                                                                        <entry>
                                                                                <xsl:value-of select="name"/>
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'function']">
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'function']">
-               <xsl:variable name="name" select="name"/>
-
                <section id="{@id}" xreflabel="{name}">
                        <title>
                                <xsl:text>Function </xsl:text>
                <section id="{@id}" xreflabel="{name}">
                        <title>
                                <xsl:text>Function </xsl:text>
-                               <xsl:value-of select="$name"/>
+                               <xsl:value-of select="name"/>
                                <xsl:text>()</xsl:text>
                        </title>
 
                        <xsl:call-template name="generate.index.id">
                                <xsl:text>()</xsl:text>
                        </title>
 
                        <xsl:call-template name="generate.index.id">
-                               <xsl:with-param name="name" select="$name"/>
+                               <xsl:with-param name="name" select="name"/>
                        </xsl:call-template>
 
                        <para>
                        </xsl:call-template>
 
                        <para>
                                                        <xsl:if test="position() > 1">
                                                                <xsl:text>,</xsl:text>
                                                        </xsl:if>
                                                        <xsl:if test="position() > 1">
                                                                <xsl:text>,</xsl:text>
                                                        </xsl:if>
-                                                       <xsl:text>&#10;&#9;&#9;</xsl:text>
+                                                       <xsl:text>&#10;&#9;</xsl:text>
                                                        <emphasis role="keyword">
                                                                <xsl:value-of select="type"/>
                                                        </emphasis>
                                                        <emphasis role="keyword">
                                                                <xsl:value-of select="type"/>
                                                        </emphasis>
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'enum']">
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'enum']">
-               <xsl:variable name="name" select="name"/>
-
                <section id="{@id}" xreflabel="{name}">
                        <title>
                                <xsl:text>Enum </xsl:text>
                <section id="{@id}" xreflabel="{name}">
                        <title>
                                <xsl:text>Enum </xsl:text>
-                               <xsl:value-of select="$name"/>
+                               <xsl:value-of select="name"/>
                        </title>
 
                        <xsl:call-template name="generate.index.id">
                        </title>
 
                        <xsl:call-template name="generate.index.id">
-                               <xsl:with-param name="name" select="$name"/>
+                               <xsl:with-param name="name" select="name"/>
                        </xsl:call-template>
 
                        <xsl:apply-templates select="detaileddescription"/>
                        </xsl:call-template>
 
                        <xsl:apply-templates select="detaileddescription"/>
                                                                <entry>
                                                                        <para id="{@id}" xreflabel="{name}">
                                                                                <xsl:value-of select="name"/>
                                                                <entry>
                                                                        <para id="{@id}" xreflabel="{name}">
                                                                                <xsl:value-of select="name"/>
-                                                                               <indexterm id="{$keyword.namespace}.{$name}.{name}"/>
+                                                                               <indexterm id="{$keyword.namespace}.{name}"/>
                                                                        </para>
                                                                </entry>
                                                                <entry>
                                                                        </para>
                                                                </entry>
                                                                <entry>
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'define']">
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'define']">
-               <xsl:variable name="name" select="name"/>
-
                <section id="{@id}" xreflabel="{name}">
                        <title>
                                <xsl:text>Macro </xsl:text>
                <section id="{@id}" xreflabel="{name}">
                        <title>
                                <xsl:text>Macro </xsl:text>
                        </title>
 
                        <xsl:call-template name="generate.index.id">
                        </title>
 
                        <xsl:call-template name="generate.index.id">
-                               <xsl:with-param name="name" select="$name"/>
+                               <xsl:with-param name="name" select="name"/>
                        </xsl:call-template>
 
                        <programlisting language="c">
                        </xsl:call-template>
 
                        <programlisting language="c">
 
                                        <!-- Split long macro definitions across multiple lines -->
                                        <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
 
                                        <!-- Split long macro definitions across multiple lines -->
                                        <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
-                                               <xsl:text>\&#10;&#09;&#9;</xsl:text>
+                                               <xsl:text>\&#10;&#9;</xsl:text>
                                        </xsl:if>
 
                                        <xsl:value-of select="initializer"/>
                                        </xsl:if>
 
                                        <xsl:value-of select="initializer"/>
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">
        </xsl:template>
 
        <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">
-               <xsl:variable name="name" select="name"/>
-
                <section id="{@id}" xreflabel="{name}">
                        <!-- Doxygen gets confused and thinks function pointer type definitions
                                 are variables, so we need to map them to this common section and
                                 check the definition to see which of the two it is. -->
                        <xsl:choose>
                <section id="{@id}" xreflabel="{name}">
                        <!-- Doxygen gets confused and thinks function pointer type definitions
                                 are variables, so we need to map them to this common section and
                                 check the definition to see which of the two it is. -->
                        <xsl:choose>
-                               <xsl:when test="contains(definition,'typedef')">
+                               <xsl:when test="contains(definition, 'typedef')">
                                        <title>
                                                <xsl:text>Type </xsl:text>
                                                <xsl:value-of select="name"/>
                                        </title>
 
                                        <xsl:call-template name="generate.index.id">
                                        <title>
                                                <xsl:text>Type </xsl:text>
                                                <xsl:value-of select="name"/>
                                        </title>
 
                                        <xsl:call-template name="generate.index.id">
-                                               <xsl:with-param name="name" select="$name"/>
+                                               <xsl:with-param name="name" select="name"/>
                                        </xsl:call-template>
 
                                        <programlisting language="c">
                                        </xsl:call-template>
 
                                        <programlisting language="c">
                                        </title>
 
                                        <xsl:call-template name="generate.index.id">
                                        </title>
 
                                        <xsl:call-template name="generate.index.id">
-                                               <xsl:with-param name="name" select="$name"/>
+                                               <xsl:with-param name="name" select="name"/>
                                        </xsl:call-template>
 
                                        <programlisting language="c">
                                        </xsl:call-template>
 
                                        <programlisting language="c">
                </section>
        </xsl:template>
 
                </section>
        </xsl:template>
 
-       <xsl:template match="linebreak">
+       <xsl:template match="linebreak | simplesectsep">
                <literallayout>
                </literallayout>
        </xsl:template>
                <literallayout>
                </literallayout>
        </xsl:template>
 
        <xsl:template match="simplesect">
                <xsl:choose>
 
        <xsl:template match="simplesect">
                <xsl:choose>
-                       <xsl:when test="@kind = 'warning'">
-                               <warning>
-                                       <title>Warning</title>
-                                       <xsl:apply-templates select="para"/>
-                               </warning>
+                       <xsl:when test="@kind = 'par'">
+                               <note>
+                                       <title>
+                                               <xsl:value-of select="title"/>
+                                       </title>
+                                       <xsl:apply-templates/>
+                               </note>
                        </xsl:when>
 
                        <xsl:when test="@kind = 'return'">
                                <note>
                                        <title>Returns</title>
                        </xsl:when>
 
                        <xsl:when test="@kind = 'return'">
                                <note>
                                        <title>Returns</title>
-                                       <xsl:apply-templates select="para"/>
+                                       <xsl:apply-templates/>
                                </note>
                        </xsl:when>
 
                                </note>
                        </xsl:when>
 
-                       <xsl:when test="@kind = 'pre'">
-                               <note>
-                                       <title>Precondition</title>
-                                       <xsl:apply-templates select="para"/>
-                               </note>
+                       <xsl:when test="@kind = 'warning'">
+                               <warning>
+                                       <title>Warning</title>
+                                       <xsl:apply-templates/>
+                               </warning>
                        </xsl:when>
 
                        </xsl:when>
 
-                       <xsl:when test="@kind = 'par'">
+                       <xsl:when test="@kind = 'pre'">
                                <note>
                                <note>
-                                       <title>
-                                               <xsl:value-of select="title"/>
-                                       </title>
-                                       <xsl:apply-templates select="para"/>
+                                       <title>Precondition</title>
+                                       <xsl:apply-templates/>
                                </note>
                        </xsl:when>
 
                        <xsl:when test="@kind = 'see'">
                                <note>
                                        <title>See also</title>
                                </note>
                        </xsl:when>
 
                        <xsl:when test="@kind = 'see'">
                                <note>
                                        <title>See also</title>
-                                       <xsl:apply-templates select="para"/>
+                                       <xsl:apply-templates/>
                                </note>
                        </xsl:when>
 
                        <xsl:when test="@kind = 'note'">
                                <note>
                                        <title>Note</title>
                                </note>
                        </xsl:when>
 
                        <xsl:when test="@kind = 'note'">
                                <note>
                                        <title>Note</title>
-                                       <xsl:apply-templates select="para"/>
+                                       <xsl:apply-templates/>
                                </note>
                        </xsl:when>
 
                                </note>
                        </xsl:when>
 
                                                <xsl:when test="not(descendant::parametername/@direction)">
                                                        <emphasis role="italic">?</emphasis>
                                                </xsl:when>
                                                <xsl:when test="not(descendant::parametername/@direction)">
                                                        <emphasis role="italic">?</emphasis>
                                                </xsl:when>
+
                                                <xsl:otherwise>
                                                        <emphasis role="bold">
                                                                [<xsl:value-of select="descendant::parametername/@direction"/>]
                                                <xsl:otherwise>
                                                        <emphasis role="bold">
                                                                [<xsl:value-of select="descendant::parametername/@direction"/>]
                </entry>
        </xsl:template>
 
                </entry>
        </xsl:template>
 
-       <xsl:template match="type">
-               <xsl:apply-templates/>
-       </xsl:template>
-
-       <xsl:template match="para">
+       <xsl:template match="parameterdescription">
                <para>
                        <xsl:apply-templates/>
                </para>
        </xsl:template>
 
                <para>
                        <xsl:apply-templates/>
                </para>
        </xsl:template>
 
+       <xsl:template match="type">
+               <xsl:apply-templates/>
+       </xsl:template>
+
        <xsl:template match="bold">
                <emphasis role="bold">
        <xsl:template match="bold">
                <emphasis role="bold">
-                       <xsl:value-of select="."/>
+                       <xsl:apply-templates/>
                </emphasis>
        </xsl:template>
 
        <xsl:template match="emphasis">
                <emphasis role="italic">
                </emphasis>
        </xsl:template>
 
        <xsl:template match="emphasis">
                <emphasis role="italic">
-                       <xsl:value-of select="."/>
+                       <xsl:apply-templates/>
                </emphasis>
        </xsl:template>
 
                </emphasis>
        </xsl:template>
 
-       <xsl:template match="computeroutput">
-               <computeroutput>
-                       <xsl:value-of select="."/>
-               </computeroutput>
+       <xsl:template match="small">
+               <xsl:apply-templates/>
        </xsl:template>
 
        </xsl:template>
 
-       <xsl:template match="ulink">
-               <ulink url="{@url}">
-                       <xsl:value-of select="."/>
-               </ulink>
+       <xsl:template match="mdash | ndash">
+               <xsl:text>--</xsl:text>
        </xsl:template>
 
        </xsl:template>
 
-       <xsl:template match="registered">
-               <xsl:text>&#174;</xsl:text>
+       <xsl:template match="computeroutput | preformatted">
+               <computeroutput>
+                       <xsl:apply-templates/>
+               </computeroutput>
        </xsl:template>
 
        </xsl:template>
 
-       <xsl:template match="copy">
-               <xsl:text>&#169;</xsl:text>
+       <xsl:template match="codeline">
+                       <xsl:apply-templates/>
        </xsl:template>
 
        </xsl:template>
 
-       <xsl:template match="trademark">
-               <xsl:text>&#8482;</xsl:text>
+       <xsl:template match="ulink">
+               <ulink url="{@url}">
+                       <xsl:value-of select="."/>
+               </ulink>
        </xsl:template>
 
        <xsl:template match="superscript">
                <superscript>
        </xsl:template>
 
        <xsl:template match="superscript">
                <superscript>
-                       <xsl:value-of select="."/>
+                       <xsl:apply-templates/>
                </superscript>
        </xsl:template>
 
        <xsl:template match="subscript">
                <subscript>
                </superscript>
        </xsl:template>
 
        <xsl:template match="subscript">
                <subscript>
-                       <xsl:value-of select="."/>
+                       <xsl:apply-templates/>
                </subscript>
        </xsl:template>
 
                </subscript>
        </xsl:template>
 
+       <xsl:template match="para">
+               <para>
+                       <xsl:apply-templates/>
+               </para>
+       </xsl:template>
+
        <xsl:template match="ref">
                <xsl:choose>
                        <!-- Don't show links inside program listings -->
        <xsl:template match="ref">
                <xsl:choose>
                        <!-- Don't show links inside program listings -->
                                <xsl:value-of select="."/>
                        </xsl:when>
 
                                <xsl:value-of select="."/>
                        </xsl:when>
 
+                       <!-- Don't show links to file compound definitions, as they are discarded -->
+                       <xsl:when test="ancestor::*/compounddef[@kind = 'file' and @id = current()/@refid]">
+                               <xsl:value-of select="."/>
+                       </xsl:when>
+
                        <!-- Show links outside program listings -->
                        <xsl:otherwise>
                                <link linkend="{@refid}">
                        <!-- Show links outside program listings -->
                        <xsl:otherwise>
                                <link linkend="{@refid}">
                </xsl:choose>
        </xsl:template>
 
                </xsl:choose>
        </xsl:template>
 
+       <xsl:template match="entry">
+               <entry>
+                       <xsl:apply-templates/>
+               </entry>
+       </xsl:template>
+
        <xsl:template match="table">
                <xsl:choose>
                        <xsl:when test="caption">
        <xsl:template match="table">
                <xsl:choose>
                        <xsl:when test="caption">
                                        <title>
                                                <xsl:value-of select="caption"/>
                                        </title>
                                        <title>
                                                <xsl:value-of select="caption"/>
                                        </title>
+
                                        <xsl:call-template name="write.table.content"/>
                                </table>
                        </xsl:when>
                                        <xsl:call-template name="write.table.content"/>
                                </table>
                        </xsl:when>
+
                        <xsl:otherwise>
                                <informaltable tabstyle="striped">
                                        <xsl:call-template name="write.table.content"/>
                        <xsl:otherwise>
                                <informaltable tabstyle="striped">
                                        <xsl:call-template name="write.table.content"/>
                        <thead>
                                <xsl:for-each select="row[1]">
                                        <row>
                        <thead>
                                <xsl:for-each select="row[1]">
                                        <row>
-                                               <xsl:for-each select="entry">
-                                                       <entry>
-                                                               <xsl:apply-templates select="."/>
-                                                       </entry>
-                                               </xsl:for-each>
+                                               <xsl:apply-templates select="entry"/>
                                        </row>
                                </xsl:for-each>
                        </thead>
                        <tbody>
                                <xsl:for-each select="row[position() != 1]">
                                        <row>
                                        </row>
                                </xsl:for-each>
                        </thead>
                        <tbody>
                                <xsl:for-each select="row[position() != 1]">
                                        <row>
-                                               <xsl:for-each select="entry">
-                                                       <entry>
-                                                               <xsl:apply-templates select="."/>
-                                                       </entry>
-                                               </xsl:for-each>
+                                               <xsl:apply-templates select="entry"/>
                                        </row>
                                </xsl:for-each>
                        </tbody>
                                        </row>
                                </xsl:for-each>
                        </tbody>
 
        <xsl:template match="itemizedlist">
                <itemizedlist>
 
        <xsl:template match="itemizedlist">
                <itemizedlist>
-                       <xsl:apply-templates select="listitem"/>
+                       <xsl:apply-templates/>
                </itemizedlist>
        </xsl:template>
 
        <xsl:template match="orderedlist">
                <orderedlist>
                </itemizedlist>
        </xsl:template>
 
        <xsl:template match="orderedlist">
                <orderedlist>
-                       <xsl:apply-templates select="listitem"/>
+                       <xsl:apply-templates/>
                </orderedlist>
        </xsl:template>
 
                </orderedlist>
        </xsl:template>
 
        <xsl:template match="image">
                <mediaobject>
                        <imageobject>
        <xsl:template match="image">
                <mediaobject>
                        <imageobject>
-                               <imagedata>
+                               <imagedata align="center">
                                        <xsl:attribute name="fileref">
                                                <xsl:text>images/</xsl:text>
                                                <xsl:value-of select="@name"/>
                                        <xsl:attribute name="fileref">
                                                <xsl:text>images/</xsl:text>
                                                <xsl:value-of select="@name"/>
 
        <xsl:template match="title"/>
 
 
        <xsl:template match="title"/>
 
+       <xsl:template match="*">
+               <xsl:message>NO XSL TEMPLATE MATCH: <xsl:value-of select="name()"/></xsl:message>
+       </xsl:template>
+
 </xsl:stylesheet>
 </xsl:stylesheet>