Add partially complete Doxygen-to-Docbook transform.
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 21 Apr 2013 14:18:12 +0000 (14:18 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 21 Apr 2013 14:18:12 +0000 (14:18 +0000)
LUFA/StudioIntegration/HV1/lufa_docbook_transform.xsl [new file with mode: 0644]
LUFA/StudioIntegration/HV1/transform_base.xsl [new file with mode: 0644]
LUFA/StudioIntegration/makefile

diff --git a/LUFA/StudioIntegration/HV1/lufa_docbook_transform.xsl b/LUFA/StudioIntegration/HV1/lufa_docbook_transform.xsl
new file mode 100644 (file)
index 0000000..0da97ca
--- /dev/null
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+       <xsl:import href="transform_base.xsl"/>
+
+       <xsl:output method="xml" indent="yes"/>
+
+       <xsl:param name="keyword.namespace" select="'Atmel.Language.C'"/>
+
+       <xsl:template name="generate.book.title">
+               <xsl:text>LUFA Library</xsl:text>
+       </xsl:template>
+
+       <xsl:template name="generate.book.id">
+               <xsl:param name="book.title"/>
+               <xsl:choose>
+                       <xsl:when test="@id">
+                               <xsl:value-of select="@id"/>
+                       </xsl:when>
+                       <xsl:otherwise>
+                               <xsl:value-of select="translate($book.title, ' ','')"/>
+                       </xsl:otherwise>
+               </xsl:choose>
+       </xsl:template>
+
+       <xsl:template match="doxygen">
+               <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:call-template>
+               </xsl:variable>
+
+               <book name="{$book.id}">
+                       <title>
+                               <xsl:value-of select="$book.title"/>
+                       </title>
+
+                       <xsl:call-template name="generate.top.level.page">
+                               <xsl:with-param name="top.level.page" select="compounddef[@kind = 'page' and contains(@id, 'index')]"/>
+                       </xsl:call-template>
+
+                       <xsl:for-each select="compounddef[@kind = 'page' and not(contains(@id, 'index'))]">
+                               <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:call-template>
+                               </xsl:if>
+                       </xsl:for-each>
+               </book>
+       </xsl:template>
+
+       <xsl:template name="generate.top.level.page">
+               <xsl:param name="top.level.page"/>
+
+               <chapter id="{$top.level.page/@id}">
+                       <title>
+                               <xsl:value-of select="$top.level.page/title"/>
+                       </title>
+                       <xsl:apply-templates select="$top.level.page/detaileddescription"/>
+
+                       <xsl:for-each select="$top.level.page/innerpage">
+                               <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
+                       </xsl:for-each>
+               </chapter>
+       </xsl:template>
+
+       <xsl:template match="compounddef[@kind = 'page']">
+               <section id="{@id}">
+                       <title>
+                               <xsl:value-of select="title"/>
+                       </title>
+                       <xsl:apply-templates select="detaileddescription"/>
+
+                       <xsl:for-each select="innerpage">
+                               <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
+                       </xsl:for-each>
+               </section>
+       </xsl:template>
+
+       <xsl:template match="linebreak">
+               <xsl:text>&#10;</xsl:text>
+       </xsl:template>
+
+       <xsl:template match="image">
+               <figure>
+                       <title>
+                               <xsl:value-of select="."/>
+                       </title>
+
+                       <mediaobject>
+                               <imageobject>
+                                       <imagedata>
+                                               <xsl:attribute name="fileref">images/<xsl:value-of select="@name"/></xsl:attribute>
+                                       </imagedata>
+                               </imageobject>
+                       </mediaobject>
+               </figure>
+       </xsl:template>
+
+       <xsl:template match="detaileddescription">
+               <xsl:apply-templates/>
+       </xsl:template>
+
+       <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
+               <section>
+                       <xsl:if test="@id">
+                               <xsl:attribute name="id">
+                                       <xsl:value-of select="@id"/>
+                               </xsl:attribute>
+                       </xsl:if>
+
+                       <title>
+                               <xsl:value-of select="title"/>
+                       </title>
+
+                       <xsl:apply-templates/>
+               </section>
+       </xsl:template>
+
+       <xsl:template match="anchor">
+               <xsl:if test="@id">
+                       <indexterm id="{@id}"/>
+               </xsl:if>
+       </xsl:template>
+
+       <xsl:template match="compoundname"/>
+
+       <xsl:template match="title"/>
+
+       <xsl:template match="indexterm"/>
+
+       <xsl:template match="indexentry">
+               <xsl:variable name="prim">
+                       <xsl:choose>
+                               <xsl:when test="contains(primaryie, ',')">
+                                       <xsl:value-of select="normalize-space(substring-before(primaryie, ','))"/>
+                               </xsl:when>
+                               <xsl:otherwise>
+                                       <xsl:value-of select="primaryie"/>
+                               </xsl:otherwise>
+                       </xsl:choose>
+               </xsl:variable>
+
+               <xsl:variable name="sec">
+                       <xsl:choose>
+                               <xsl:when test="contains(primaryie, ',')">
+                                       <xsl:value-of select="normalize-space(substring-after(primaryie, ','))"/>
+                               </xsl:when>
+                               <xsl:when test="seondariye">
+                                       <xsl:value-of select="secondaryie"/>
+                               </xsl:when>
+                               <xsl:otherwise/>
+                       </xsl:choose>
+               </xsl:variable>
+
+               <xsl:variable name="tert">
+                       <xsl:choose>
+                               <xsl:when test="contains(primaryie, ',')">
+                                       <xsl:choose>
+                                               <xsl:when test="secondaryie">
+                                                       <xsl:value-of select="secondaryie"/>
+                                               </xsl:when>
+                                       </xsl:choose>
+                               </xsl:when>
+                               <xsl:when test="tertiaryie">
+                                       <xsl:value-of select="tertiaryie"/>
+                               </xsl:when>
+                               <xsl:otherwise/>
+                       </xsl:choose>
+               </xsl:variable>
+
+               <indexterm>
+                       <xsl:if test="@id">
+                               <xsl:attribute name="id">
+                                       <xsl:value-of select="@id"/>
+                               </xsl:attribute>
+                       </xsl:if>
+                       <xsl:if test="$prim">
+                               <primary>
+                                       <xsl:value-of select="$prim"/>
+                               </primary>
+                       </xsl:if>
+                       <xsl:if test="$sec">
+                               <secondary>
+                                       <xsl:value-of select="$sec"/>
+                               </secondary>
+                       </xsl:if>
+                       <xsl:if test="$tert">
+                               <tertiary>
+                                       <xsl:value-of select="$tert"/>
+                               </tertiary>
+                       </xsl:if>
+               </indexterm>
+       </xsl:template>
+</xsl:stylesheet>
diff --git a/LUFA/StudioIntegration/HV1/transform_base.xsl b/LUFA/StudioIntegration/HV1/transform_base.xsl
new file mode 100644 (file)
index 0000000..03b7901
--- /dev/null
@@ -0,0 +1,737 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<xsl:stylesheet\r
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\r
+  xmlns:exsl="http://exslt.org/common"\r
+  extension-element-prefixes="exsl"\r
+  exclude-result-prefixes="exsl"\r
+  version="1.0">\r
+\r
+  <xsl:output\r
+    method="xml" indent="yes"\r
+    doctype-public="-//OASIS//DTD DocBook XML V4.5//EN"\r
+    doctype-system="http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"/>\r
+\r
+  <xsl:template name="write.api.overview.contents">\r
+\r
+      <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'variable' or memberdef/@kind = 'typedef']) > 0">\r
+        <section>\r
+          <title>Variable and Type Definitions</title>\r
+\r
+          <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'variable' or memberdef/@kind = 'typedef']">\r
+            <section>\r
+              <title>\r
+                <xsl:value-of select="header"/>\r
+              </title>\r
+\r
+              <xsl:apply-templates select="description"/>\r
+              <xsl:apply-templates select="memberdef[@kind = 'variable' or @kind = 'typedef']"/>\r
+            </section>\r
+          </xsl:for-each>\r
+        </section>\r
+      </xsl:if>\r
+\r
+      <xsl:if test="count(ancestor::*/innerclass) > 0">\r
+        <section>\r
+          <title>Structure Definitions</title>\r
+\r
+          <xsl:for-each select="ancestor::*/innerclass">\r
+            <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>\r
+          </xsl:for-each>\r
+        </section>\r
+      </xsl:if>\r
+\r
+      <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'define' or @kind = 'define']) > 0">\r
+        <section>\r
+          <title>Macro Definitions</title>\r
+\r
+          <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'define' or @kind = 'define']">\r
+            <section>\r
+              <title>\r
+                <xsl:value-of select="header"/>\r
+              </title>\r
+\r
+              <xsl:apply-templates select="description"/>\r
+              <xsl:apply-templates select="memberdef[@kind = 'define']"/>\r
+            </section>\r
+          </xsl:for-each>\r
+        </section>\r
+      </xsl:if>\r
+\r
+      <xsl:if test="count(ancestor::*/sectiondef[memberdef/@kind = 'function']) > 0">\r
+        <section>\r
+          <title>Function Definitions</title>\r
+\r
+          <xsl:for-each select="ancestor::*/sectiondef[memberdef/@kind = 'function']">\r
+            <section>\r
+              <title>\r
+                <xsl:value-of select="header"/>\r
+              </title>\r
+\r
+              <xsl:apply-templates select="description"/>\r
+              <xsl:apply-templates select="memberdef[@kind = 'function']"/>\r
+            </section>\r
+          </xsl:for-each>\r
+        </section>\r
+      </xsl:if>\r
+\r
+      <xsl:if test="count(ancestor::*/sectiondef[@kind = 'enum']) > 0">\r
+        <section>\r
+          <title>Enumeration Definitions</title>\r
+\r
+          <xsl:apply-templates select="ancestor::*/sectiondef[@kind = 'enum']"/>\r
+        </section>\r
+      </xsl:if>\r
+\r
+  </xsl:template>\r
+\r
+  <xsl:template match="compounddef">\r
+    <!-- Discard compounddef elements unless a later template matches -->\r
+  </xsl:template>\r
+\r
+  <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">\r
+    <section id="{@id}" xreflabel="{compoundname}">\r
+      <title>\r
+        <xsl:choose>\r
+          <xsl:when test="@kind = 'struct'">\r
+            <xsl:text>Struct </xsl:text>\r
+          </xsl:when>\r
+          <xsl:when test="@kind = 'union'">\r
+            <xsl:text>Union </xsl:text>\r
+          </xsl:when>\r
+        </xsl:choose>\r
+\r
+        <xsl:value-of select="compoundname"/>\r
+      </title>\r
+\r
+      <xsl:apply-templates select="detaileddescription"/>\r
+\r
+      <xsl:for-each select="sectiondef[@kind = 'public-attrib']">\r
+        <informaltable tabstyle="striped">\r
+          <tgroup cols="3">\r
+            <thead>\r
+              <row>\r
+                <entry>Type</entry>\r
+                <entry>Name</entry>\r
+                <entry>Description</entry>\r
+              </row>\r
+            </thead>\r
+            <tbody>\r
+              <xsl:for-each select="memberdef">\r
+                <row id="{@id}" xreflabel="{name}">\r
+                  <entry>\r
+                    <xsl:apply-templates select="type"/>\r
+                  </entry>\r
+                  <entry>\r
+                    <xsl:value-of select="name"/>\r
+                    <xsl:if test="starts-with(argsstring, '[')">\r
+                      <xsl:text>[]</xsl:text>\r
+                    </xsl:if>\r
+                  </entry>\r
+                  <entry>\r
+                    <xsl:apply-templates select="detaileddescription" mode="struct"/>\r
+                  </entry>\r
+                </row>\r
+              </xsl:for-each>\r
+            </tbody>\r
+          </tgroup>\r
+        </informaltable>\r
+        <para>&#xa0;</para>\r
+      </xsl:for-each>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="memberdef[@kind = 'function']">\r
+    <section id="{@id}" xreflabel="{name}">\r
+      <title> Function <xsl:value-of select="name"/>() </title>\r
+\r
+      <para>\r
+        <emphasis role="italic">\r
+          <xsl:value-of select="briefdescription"/>\r
+        </emphasis>\r
+      </para>\r
+\r
+      <programlisting language="c">\r
+        <xsl:value-of select="definition"/>\r
+        <xsl:text>&#10;&#9;&#9;</xsl:text>\r
+        <xsl:apply-templates select="argsstring"/>\r
+      </programlisting>\r
+\r
+      <xsl:apply-templates select="detaileddescription"/>\r
+\r
+      <para>&#xa0;</para>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="memberdef[@kind = 'enum']">\r
+    <section id="{@id}" xreflabel="{name}">\r
+      <title> Enum <xsl:value-of select="name"/> </title>\r
+\r
+      <xsl:apply-templates select="detaileddescription"/>\r
+\r
+      <informaltable tabstyle="striped">\r
+        <tgroup cols="2">\r
+          <thead>\r
+            <row>\r
+              <entry>Enum Value</entry>\r
+              <entry>Description</entry>\r
+            </row>\r
+          </thead>\r
+          <tbody>\r
+            <xsl:for-each select="enumvalue">\r
+              <row>\r
+                <entry>\r
+                  <para id="{@id}" xreflabel="{name}">\r
+                    <xsl:value-of select="name"/>\r
+                  </para>\r
+                </entry>\r
+                <entry>\r
+                  <xsl:apply-templates select="detaileddescription"/>\r
+                </entry>\r
+              </row>\r
+            </xsl:for-each>\r
+          </tbody>\r
+        </tgroup>\r
+      </informaltable>\r
+\r
+      <para>&#xa0;</para>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="memberdef[@kind = 'define']">\r
+    <section id="{@id}" xreflabel="{name}">\r
+      <title> Macro <xsl:value-of select="name"/> </title>\r
+\r
+      <programlisting language="c">\r
+        <xsl:text>#define </xsl:text>\r
+        <xsl:value-of select="name"/>\r
+        <xsl:if test="count(param) > 0">\r
+          <xsl:text>(</xsl:text>\r
+          <xsl:for-each select="param/defname">\r
+            <xsl:if test="position() > 1">\r
+              <xsl:text>, </xsl:text>\r
+            </xsl:if>\r
+            <xsl:value-of select="."/>\r
+          </xsl:for-each>\r
+          <xsl:text>)</xsl:text>\r
+        </xsl:if>\r
+        <xsl:text> </xsl:text>\r
+\r
+        <!-- Split long macro definitions across multiple lines -->\r
+        <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">\r
+          <xsl:text>\&#10;&#09;&#9;</xsl:text>\r
+        </xsl:if>\r
+\r
+        <xsl:value-of select="initializer"/>\r
+      </programlisting>\r
+\r
+      <xsl:apply-templates select="detaileddescription"/>\r
+\r
+      <para>&#xa0;</para>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="memberdef[@kind = 'variable' or @kind = 'typedef']">\r
+    <section id="{@id}" xreflabel="{name}">\r
+      <title>\r
+        <!-- Doxygen gets confused and thinks function pointer type definitions\r
+             are variables, so we need to map them to this common section and\r
+             check the definition to see which of the two it is. -->\r
+        <xsl:choose>\r
+          <xsl:when test="contains(definition,'typedef')">\r
+            <xsl:text>Type </xsl:text>\r
+          </xsl:when>\r
+\r
+          <xsl:otherwise>\r
+            <xsl:text>Variable </xsl:text>\r
+          </xsl:otherwise>\r
+        </xsl:choose>\r
+\r
+        <xsl:value-of select="name"/>\r
+      </title>\r
+\r
+      <programlisting language="c">\r
+        <xsl:value-of select="definition"/>\r
+      </programlisting>\r
+\r
+      <xsl:apply-templates select="detaileddescription"/>\r
+\r
+      <para>&#xa0;</para>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="sectiondef">\r
+    <para>\r
+      <xsl:value-of select="description"/>\r
+    </para>\r
+\r
+    <xsl:apply-templates select="memberdef"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="simplesect" mode="struct">\r
+    <footnote>\r
+      <xsl:apply-templates select="para"/>\r
+    </footnote>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="simplesect">\r
+    <xsl:choose>\r
+      <xsl:when test="@kind = 'warning'">\r
+        <warning>\r
+          <title>Warning</title>\r
+          <xsl:apply-templates select="para"/>\r
+        </warning>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="@kind = 'return'">\r
+        <note>\r
+          <title>Returns</title>\r
+          <xsl:apply-templates select="para"/>\r
+        </note>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="@kind = 'pre'">\r
+        <note>\r
+          <title>Precondition</title>\r
+          <xsl:apply-templates select="para"/>\r
+        </note>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="@kind = 'par'">\r
+        <note>\r
+          <title>\r
+            <xsl:value-of select="title"/>\r
+          </title>\r
+          <xsl:apply-templates select="para"/>\r
+        </note>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="@kind = 'see'">\r
+        <note>\r
+          <title>See also</title>\r
+          <xsl:apply-templates select="para"/>\r
+        </note>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="@kind = 'note'">\r
+        <!-- Notes can have special prefix keywords to transform them into\r
+             special styles for training documents ("AlfonsoNotes(TM)") -->\r
+        <xsl:variable name="note.prefix" select="substring-before(para[1]/text(), ' ')"/>\r
+\r
+        <note>\r
+          <xsl:choose>\r
+            <xsl:when test="$note.prefix = 'TODO:'">\r
+              <xsl:attribute name="role">todo</xsl:attribute>\r
+              <title>To Do</title>\r
+            </xsl:when>\r
+\r
+            <xsl:when test="$note.prefix = 'TIP:'">\r
+              <xsl:attribute name="role">tip</xsl:attribute>\r
+              <title>Tip</title>\r
+            </xsl:when>\r
+\r
+            <xsl:when test="$note.prefix = 'INFO:'">\r
+              <xsl:attribute name="role">info</xsl:attribute>\r
+              <title>Info</title>\r
+            </xsl:when>\r
+\r
+            <xsl:when test="$note.prefix = 'RESULT:'">\r
+              <xsl:attribute name="role">result</xsl:attribute>\r
+              <title>Result</title>\r
+            </xsl:when>\r
+\r
+            <xsl:when test="$note.prefix = 'EXECUTE:'">\r
+              <xsl:attribute name="role">execute</xsl:attribute>\r
+              <title>Execute</title>\r
+            </xsl:when>\r
+\r
+            <xsl:when test="$note.prefix = 'WARNING:'">\r
+              <xsl:attribute name="role">warning</xsl:attribute>\r
+              <title>Warning</title>\r
+            </xsl:when>\r
+\r
+            <xsl:otherwise/>\r
+          </xsl:choose>\r
+\r
+          <xsl:apply-templates select="para"/>\r
+        </note>\r
+      </xsl:when>\r
+\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <!-- Strip off the special note type prefix from the special training document\r
+       style notes ("AlfonsoNotes(TM)") if one is present. -->\r
+  <xsl:template match="para[parent::simplesect/@kind='note']/text()">\r
+    <xsl:variable name="note.prefix" select="substring-before(., ' ')"/>\r
+    <xsl:variable name="note.content" select="substring-after(., ' ')"/>\r
+\r
+    <xsl:choose>\r
+      <xsl:when test="$note.prefix = 'TODO:'">\r
+        <xsl:value-of select="$note.content"/>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="$note.prefix = 'TIP:'">\r
+        <xsl:value-of select="$note.content"/>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="$note.prefix = 'INFO:'">\r
+        <xsl:value-of select="$note.content"/>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="$note.prefix = 'RESULT:'">\r
+        <xsl:value-of select="$note.content"/>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="$note.prefix = 'EXECUTE:'">\r
+        <xsl:value-of select="$note.content"/>\r
+      </xsl:when>\r
+\r
+      <xsl:when test="$note.prefix = 'WARNING:'">\r
+        <xsl:value-of select="$note.content"/>\r
+      </xsl:when>\r
+\r
+      <xsl:otherwise>\r
+        <xsl:value-of select="."/>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="parameterlist[@kind = 'param']">\r
+    <table tabstyle="striped">\r
+      <title>Parameters</title>\r
+      <tgroup cols="3">\r
+        <thead>\r
+          <row>\r
+            <entry>Data Direction</entry>\r
+            <entry>Parameter Name</entry>\r
+            <entry>Description</entry>\r
+          </row>\r
+        </thead>\r
+        <tbody>\r
+          <xsl:for-each select="parameteritem">\r
+            <row>\r
+              <xsl:apply-templates select="."/>\r
+            </row>\r
+          </xsl:for-each>\r
+        </tbody>\r
+      </tgroup>\r
+    </table>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="parameterlist[@kind = 'retval']">\r
+    <table tabstyle="striped">\r
+      <title>Return Values</title>\r
+      <tgroup cols="2">\r
+        <thead>\r
+          <row>\r
+            <entry>Return Value</entry>\r
+            <entry>Description</entry>\r
+          </row>\r
+        </thead>\r
+        <tbody>\r
+          <xsl:for-each select="parameteritem">\r
+            <row>\r
+              <xsl:apply-templates select="."/>\r
+            </row>\r
+          </xsl:for-each>\r
+        </tbody>\r
+      </tgroup>\r
+    </table>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="parameteritem">\r
+    <xsl:if test="parent::parameterlist/@kind = 'param'">\r
+      <entry>\r
+        <para>\r
+          <xsl:choose>\r
+            <xsl:when test="not(descendant::parametername/@direction)">\r
+              <emphasis role="italic">?</emphasis>\r
+            </xsl:when>\r
+            <xsl:otherwise>\r
+              <emphasis role="bold">[<xsl:value-of select="descendant::parametername/@direction"/>]</emphasis>\r
+            </xsl:otherwise>\r
+          </xsl:choose>\r
+        </para>\r
+      </entry>\r
+    </xsl:if>\r
+\r
+    <entry>\r
+      <para>\r
+        <xsl:value-of select="parameternamelist/parametername"/>\r
+      </para>\r
+    </entry>\r
+\r
+    <entry>\r
+      <xsl:apply-templates select="parameterdescription"/>\r
+    </entry>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="type">\r
+    <xsl:apply-templates/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="sect1">\r
+    <section id="{@id}" xreflabel="{title}">\r
+      <title>\r
+        <xsl:value-of select="title"/>\r
+      </title>\r
+\r
+      <xsl:apply-templates select="para"/>\r
+      <xsl:apply-templates select="sect2"/>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="sect2">\r
+    <section id="{@id}" xreflabel="{title}">\r
+      <title>\r
+        <xsl:value-of select="title"/>\r
+      </title>\r
+\r
+      <xsl:apply-templates select="para"/>\r
+      <xsl:apply-templates select="sect3"/>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="sect3">\r
+    <section id="{@id}" xreflabel="{title}">\r
+      <title>\r
+        <xsl:value-of select="title"/>\r
+      </title>\r
+\r
+      <xsl:apply-templates select="para"/>\r
+    </section>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="detaileddescription">\r
+    <xsl:apply-templates select="para"/>\r
+    <xsl:apply-templates select="sect1"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="para">\r
+    <para>\r
+      <xsl:apply-templates/>\r
+    </para>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="bold">\r
+    <emphasis role="bold">\r
+      <xsl:value-of select="."/>\r
+    </emphasis>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="emphasis">\r
+    <emphasis role="italic">\r
+      <xsl:value-of select="."/>\r
+    </emphasis>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="computeroutput">\r
+    <computeroutput>\r
+      <xsl:value-of select="."/>\r
+    </computeroutput>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="ulink">\r
+    <ulink url="{@url}">\r
+      <xsl:value-of select="."/>\r
+    </ulink>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="registered">\r
+    <xsl:text>&#174;</xsl:text>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="copy">\r
+    <xsl:text>&#169;</xsl:text>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="trademark">\r
+    <xsl:text>&#8482;</xsl:text>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="ref">\r
+    <xsl:choose>\r
+      <!-- Don't show links inside program listings -->\r
+      <xsl:when test="ancestor::programlisting">\r
+        <xsl:value-of select="."/>\r
+      </xsl:when>\r
+\r
+      <!-- Show links outside program listings -->\r
+      <xsl:otherwise>\r
+        <link linkend="{@refid}" xrefstyle="nopage">\r
+          <xsl:value-of select="text()"/>\r
+        </link>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="formula">\r
+    <equation>\r
+      <!-- LaTeX equation generation requires JLatexMath and its associated\r
+           FOP plugin, or you will get missing equations in the output -->\r
+      <latex align="center" xmlns="http://forge.scilab.org/p/jlatexmath">\r
+        <xsl:value-of select="."/>\r
+      </latex>\r
+    </equation>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="table">\r
+    <xsl:choose>\r
+      <xsl:when test="caption">\r
+        <table tabstyle="striped">\r
+          <title>\r
+            <xsl:value-of select="caption"/>\r
+          </title>\r
+          <xsl:call-template name="write.table.content"/>\r
+        </table>\r
+      </xsl:when>\r
+      <xsl:otherwise>\r
+        <informaltable tabstyle="striped">\r
+          <xsl:call-template name="write.table.content"/>\r
+        </informaltable>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <xsl:template name="write.table.content">\r
+    <tgroup cols="{@cols}">\r
+      <thead>\r
+        <xsl:for-each select="row[1]">\r
+          <row>\r
+            <xsl:for-each select="entry">\r
+              <entry>\r
+                <xsl:apply-templates select="."/>\r
+              </entry>\r
+            </xsl:for-each>\r
+          </row>\r
+        </xsl:for-each>\r
+      </thead>\r
+      <tbody>\r
+        <xsl:for-each select="row[position() != 1]">\r
+          <row>\r
+            <xsl:for-each select="entry">\r
+              <entry>\r
+                <xsl:apply-templates select="."/>\r
+              </entry>\r
+            </xsl:for-each>\r
+          </row>\r
+        </xsl:for-each>\r
+      </tbody>\r
+    </tgroup>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="itemizedlist">\r
+    <itemizedlist>\r
+      <xsl:apply-templates select="listitem"/>\r
+    </itemizedlist>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="orderedlist">\r
+    <orderedlist>\r
+      <xsl:apply-templates select="listitem"/>\r
+    </orderedlist>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="listitem">\r
+    <listitem>\r
+      <xsl:apply-templates/>\r
+    </listitem>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="programlisting">\r
+    <programlisting language="c">\r
+      <xsl:for-each select="codeline[position() > 1 or highlight]">\r
+        <xsl:apply-templates select="."/>\r
+        <xsl:text>&#10;</xsl:text>\r
+      </xsl:for-each>\r
+    </programlisting>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="highlight">\r
+    <emphasis>\r
+      <xsl:attribute name="role">\r
+        <xsl:value-of select="@class"/>\r
+      </xsl:attribute>\r
+      <xsl:apply-templates/>\r
+    </emphasis>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="sp[ancestor::codeline]">\r
+    <xsl:choose>\r
+      <!-- Need to check if this is the first part of the line - if so we may\r
+           need to strip off any leading <sp/> element indentation -->\r
+      <xsl:when test="ancestor::highlight = ancestor::codeline/highlight[1]">\r
+        <!-- Doxygen retains a level of indentation in some code fragments - obtain\r
+             the base indentation level by counting the leading <sp/> elements of the\r
+             first code line, and use that to remove the indentation on the rest -->\r
+        <xsl:variable name="leading.spaces" select="count(ancestor::programlisting/codeline[highlight][1]/highlight[1]/sp[not(preceding-sibling::text())])"/>\r
+\r
+        <xsl:if test="position() > $leading.spaces">\r
+          <xsl:text> </xsl:text>\r
+        </xsl:if>\r
+      </xsl:when>\r
+\r
+      <xsl:otherwise>\r
+        <xsl:text> </xsl:text>\r
+      </xsl:otherwise>\r
+    </xsl:choose>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="image">\r
+    <figure>\r
+      <title>\r
+        <xsl:value-of select="."/>\r
+      </title>\r
+\r
+      <mediaobject>\r
+        <imageobject>\r
+          <imagedata scalefit="1" width="{@width}">\r
+            <xsl:attribute name="fileref">html/<xsl:value-of select="@name"/></xsl:attribute>\r
+          </imagedata>\r
+        </imageobject>\r
+      </mediaobject>\r
+    </figure>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="anchor">\r
+    <anchor id="{@id}"/>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="dot">\r
+    <!-- We get raw DOT syntax rather than a rendered image: write the DOT code\r
+         to a new unique file, and make a image reference to a SVG version of\r
+         that file. The build system should then call dot to render all generated\r
+         DOT files into their SVG equivalents before rendering the PDF. -->\r
+    <xsl:variable name="filename" select="generate-id(.)" />\r
+    <exsl:document href="{$filename}.dot" method="text">\r
+      <xsl:value-of select="." />\r
+    </exsl:document>\r
+\r
+    <figure>\r
+      <title>\r
+        <xsl:value-of select="ancestor::*/title"/>\r
+      </title>\r
+      <mediaobject>\r
+        <imageobject>\r
+          <imagedata format="SVG">\r
+            <xsl:attribute name="fileref">\r
+                <xsl:value-of select="$filename" />\r
+                <xsl:text>.svg</xsl:text>\r
+            </xsl:attribute>\r
+          </imagedata>\r
+        </imageobject>\r
+      </mediaobject>\r
+    </figure>\r
+  </xsl:template>\r
+\r
+  <xsl:template match="argsstring" name="split.functions.args">\r
+    <xsl:param name="text" select="."/>\r
+    <xsl:value-of select="substring-before(concat($text,','),',')"/>\r
+    <xsl:if test="contains($text,',')">\r
+      <xsl:text>,&#10;&#09;&#9;</xsl:text>\r
+      <xsl:call-template name="split.functions.args">\r
+        <xsl:with-param name="text" select="substring-after($text,',')"/>\r
+      </xsl:call-template>\r
+    </xsl:if>\r
+  </xsl:template>\r
+</xsl:stylesheet>\r
index 5b50a22..daaa2dc 100644 (file)
@@ -40,6 +40,10 @@ VSIX_ASSETS          := $(LUFA_ROOT)/DoxygenPages/Images/LUFA_thumb.png \
                         Blob/Atmel.Studio.Services.Interfaces.dll       \
                         Blob/LUFA.dll                                   \
                         Blob/LUFA.pkgdef
                         Blob/Atmel.Studio.Services.Interfaces.dll       \
                         Blob/LUFA.dll                                   \
                         Blob/LUFA.pkgdef
+MSHELP_GEN_PARAMS   := --stringparam generate.toc "book toc"            \
+                       --stringparam chunk.quietly "1"                  \
+                       --stringparam chunk.section.depth "2"            \
+                       --stringparam chunk.first.sections "1"
 
 all: generate_xml check_filenames generate_vsix
 
 
 all: generate_xml check_filenames generate_vsix
 
@@ -79,11 +83,11 @@ $(MSHELP_OUTPUT_XML): $(DOXYGEN_COMBINED_XML)
        @echo Converting Doxygen XML to Docbook...
        @-mkdir mshelp 2> /dev/null
        @xsltproc HV1/lufa_docbook_transform.xsl $(DOXYGEN_COMBINED_XML) > mshelp/lufa_docbook.xml
        @echo Converting Doxygen XML to Docbook...
        @-mkdir mshelp 2> /dev/null
        @xsltproc HV1/lufa_docbook_transform.xsl $(DOXYGEN_COMBINED_XML) > mshelp/lufa_docbook.xml
-       @cd mshelp && xsltproc ../Docbook/mshelp/docbook.xsl lufa_docbook.xml
+       @cd mshelp && xsltproc $(MSHELP_GEN_PARAMS) ../Docbook/mshelp/docbook.xsl lufa_docbook.xml
 
        @echo Copying help assets...
        @-mkdir mshelp/images 2> /dev/null
 
        @echo Copying help assets...
        @-mkdir mshelp/images 2> /dev/null
-       @cp -r $(LUFA_ROOT)/DoxygenPages/Images/* mshelp/images
+       @cp `find $(LUFA_ROOT)/DoxygenPages/Images -type f` mshelp/images
 
        @echo Archiving help content...
        @cd mshelp && zip ../$(MSHELP_OUTPUT_XML) -q -0  -r *.html images
 
        @echo Archiving help content...
        @cd mshelp && zip ../$(MSHELP_OUTPUT_XML) -q -0  -r *.html images