1 <?xml version="1.0" encoding="UTF-8"?>
 
   3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
 
   5         <xsl:output method="xml" indent="no"/>
 
   7         <xsl:param name="keyword.namespace" select="'Atmel.Language.C'"/>
 
   9         <xsl:template name="generate.book.title">
 
  10                 <xsl:text>LUFA Library</xsl:text>
 
  13         <xsl:template name="generate.book.id">
 
  14                 <xsl:param name="book.title"/>
 
  17                                 <xsl:value-of select="@id"/>
 
  20                                 <xsl:value-of select="translate($book.title, ' ','')"/>
 
  25         <xsl:template name="generate.index.id">
 
  26                 <xsl:param name="name"/>
 
  27                 <xsl:variable name="book.title">
 
  28                         <xsl:call-template name="generate.book.title"/>
 
  30                 <xsl:variable name="book.id">
 
  31                         <xsl:call-template name="generate.book.id">
 
  32                                 <xsl:with-param name="book.title" select="$book.title"/>
 
  36                 <indexterm id="{$keyword.namespace}.{$name}">
 
  38                                 <xsl:value-of select="$book.title"/>
 
  41                                 <xsl:value-of select="$name"/>
 
  46         <xsl:template match="doxygen">
 
  47                 <xsl:variable name="book.title">
 
  48                         <xsl:call-template name="generate.book.title"/>
 
  51                 <xsl:variable name="book.id">
 
  52                         <xsl:call-template name="generate.book.id">
 
  53                                 <xsl:with-param name="book.title" select="$book.title"/>
 
  57                 <book id="{$book.id}">
 
  59                                 <xsl:value-of select="$book.title"/>
 
  62                         <!-- Add index chapter -->
 
  63                         <xsl:apply-templates select="compounddef[@kind = 'page' and @id = 'indexpage']">
 
  64                                 <xsl:with-param name="element.type" select="'chapter'"/>
 
  65                                 <xsl:with-param name="page.title"   select="'Library Information'"/>
 
  66                         </xsl:apply-templates>
 
  68                         <!-- Add free-floating chapters -->
 
  69                         <xsl:apply-templates select="compounddef[@kind = 'page' and not(@id = 'indexpage') and not(//innerpage/@refid = @id)]">
 
  70                                 <xsl:with-param name="element.type" select="'chapter'"/>
 
  71                         </xsl:apply-templates>
 
  73                         <!-- Add Modules chapter -->
 
  75                                 <title>Modules</title>
 
  76                                 <xsl:apply-templates select="compounddef[@kind = 'group' and not(//innergroup/@refid = @id)]"/>
 
  81         <xsl:template match="compounddef[@kind = 'page']">
 
  82                 <xsl:param name="element.type" select="'section'"/>
 
  83                 <xsl:param name="page.title"   select="title"/>
 
  85                 <xsl:element name="{$element.type}">
 
  86                         <xsl:attribute name="id">
 
  87                                 <xsl:value-of select="@id"/>
 
  90                         <xsl:variable name="name">
 
  91                                 <xsl:text>LUFA.</xsl:text>
 
  92                                 <xsl:value-of select="translate(compoundname, '_', '.')"/>
 
  95                         <xsl:call-template name="generate.index.id">
 
  96                                 <xsl:with-param name="name" select="$name"/>
 
 100                                 <xsl:value-of select="$page.title"/>
 
 103                         <xsl:apply-templates select="detaileddescription"/>
 
 105                         <xsl:if test="not(innerpage) and count(detaileddescription//sect1)">
 
 107                                         <emphasis role="bold">Subsections:</emphasis>
 
 109                                                 <xsl:for-each select="detaileddescription//sect1">
 
 111                                                                 <link linkend="{@id}">
 
 112                                                                         <xsl:value-of select="title"/>
 
 120                         <xsl:for-each select="innerpage">
 
 121                                 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
 
 126         <xsl:template match="compounddef[@kind = 'group']">
 
 129                                 <xsl:value-of select="title"/>
 
 132                         <xsl:variable name="name">
 
 133                                 <xsl:text>LUFA.</xsl:text>
 
 134                                 <xsl:value-of select="translate(compoundname, '_', '.')"/>
 
 137                         <xsl:call-template name="generate.index.id">
 
 138                                 <xsl:with-param name="name" select="$name"/>
 
 141                         <xsl:apply-templates select="detaileddescription"/>
 
 143                         <xsl:if test="count(innergroup)">
 
 145                                         <emphasis role="bold">Subgroups:</emphasis>
 
 147                                                 <xsl:for-each select="innergroup">
 
 149                                                                 <link linkend="{@refid}">
 
 150                                                                         <xsl:value-of select="text()"/>
 
 158                         <xsl:apply-templates select="sectiondef"/>
 
 160                         <xsl:for-each select="innerclass">
 
 161                                 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
 
 164                         <xsl:for-each select="innergroup">
 
 165                                 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'group' and @id = current()/@refid]"/>
 
 170         <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
 
 171                 <xsl:variable name="name" select="compoundname"/>
 
 173                 <section id="{@id}" xreflabel="{$name}">
 
 176                                         <xsl:when test="@kind = 'struct'">
 
 177                                                 <xsl:text>Struct </xsl:text>
 
 180                                         <xsl:when test="@kind = 'union'">
 
 181                                                 <xsl:text>Union </xsl:text>
 
 185                                 <xsl:value-of select="$name"/>
 
 188                         <xsl:call-template name="generate.index.id">
 
 189                                 <xsl:with-param name="name" select="$name"/>
 
 192                         <xsl:apply-templates select="detaileddescription"/>
 
 194                         <xsl:for-each select="sectiondef[@kind = 'public-attrib']">
 
 197                                                 <xsl:value-of select="$name"/>
 
 205                                                                 <entry>Description</entry>
 
 210                                                         <xsl:for-each select="memberdef">
 
 211                                                                 <row id="{@id}" xreflabel="{name}">
 
 213                                                                                 <xsl:value-of select="type"/>
 
 216                                                                                 <xsl:value-of select="name"/>
 
 217                                                                                 <xsl:if test="starts-with(argsstring, '[')">
 
 218                                                                                         <xsl:text>[]</xsl:text>
 
 221                                                                                 <xsl:variable name="struct.element.name">
 
 222                                                                                         <xsl:value-of select="$name"/>
 
 223                                                                                         <xsl:text>.</xsl:text>
 
 224                                                                                         <xsl:value-of select="name"/>
 
 227                                                                                 <xsl:call-template name="generate.index.id">
 
 228                                                                                         <xsl:with-param name="name" select="$struct.element.name"/>
 
 232                                                                                 <xsl:apply-templates select="detaileddescription"/>
 
 243         <xsl:template match="memberdef[@kind = 'function']">
 
 244                 <section id="{@id}" xreflabel="{name}">
 
 246                                 <xsl:text>Function </xsl:text>
 
 247                                 <xsl:value-of select="name"/>
 
 248                                 <xsl:text>()</xsl:text>
 
 251                         <xsl:call-template name="generate.index.id">
 
 252                                 <xsl:with-param name="name" select="name"/>
 
 256                                 <emphasis role="italic">
 
 257                                         <xsl:value-of select="briefdescription"/>
 
 261                         <programlisting language="c">
 
 262                                 <emphasis role="keyword">
 
 263                                         <xsl:value-of select="type"/>
 
 265                                 <xsl:text> </xsl:text>
 
 266                                 <xsl:value-of select="name"/>
 
 267                                 <xsl:text>(</xsl:text>
 
 270                                         <xsl:when test="not(param[1]/declname)">
 
 271                                                 <emphasis role="keyword">void</emphasis>
 
 275                                                 <xsl:for-each select="param">
 
 276                                                         <xsl:if test="position() > 1">
 
 277                                                                 <xsl:text>,</xsl:text>
 
 279                                                         <xsl:text>
	</xsl:text>
 
 280                                                         <emphasis role="keyword">
 
 281                                                                 <xsl:value-of select="type"/>
 
 283                                                         <xsl:text> </xsl:text>
 
 284                                                         <xsl:value-of select="declname"/>
 
 289                                 <xsl:text>)</xsl:text>
 
 292                         <xsl:apply-templates select="detaileddescription"/>
 
 296         <xsl:template match="memberdef[@kind = 'enum']">
 
 297                 <section id="{@id}" xreflabel="{name}">
 
 299                                 <xsl:text>Enum </xsl:text>
 
 300                                 <xsl:value-of select="name"/>
 
 303                         <xsl:call-template name="generate.index.id">
 
 304                                 <xsl:with-param name="name" select="name"/>
 
 307                         <xsl:apply-templates select="detaileddescription"/>
 
 310                                 <title>Members</title>
 
 314                                                         <entry>Enum Value</entry>
 
 315                                                         <entry>Description</entry>
 
 320                                                 <xsl:for-each select="enumvalue">
 
 323                                                                         <para id="{@id}" xreflabel="{name}">
 
 324                                                                                 <xsl:value-of select="name"/>
 
 326                                                                                 <xsl:call-template name="generate.index.id">
 
 327                                                                                         <xsl:with-param name="name" select="name"/>
 
 332                                                                         <xsl:apply-templates select="detaileddescription"/>
 
 342         <xsl:template match="memberdef[@kind = 'define']">
 
 343                 <section id="{@id}" xreflabel="{name}">
 
 345                                 <xsl:text>Macro </xsl:text>
 
 346                                 <xsl:value-of select="name"/>
 
 349                         <xsl:call-template name="generate.index.id">
 
 350                                 <xsl:with-param name="name" select="name"/>
 
 353                         <programlisting language="c">
 
 354                                 <emphasis role="preprocessor">
 
 355                                         <xsl:text>#define </xsl:text>
 
 356                                         <xsl:value-of select="name"/>
 
 357                                         <xsl:if test="count(param) > 0">
 
 358                                                 <xsl:text>(</xsl:text>
 
 359                                                 <xsl:for-each select="param/defname">
 
 360                                                         <xsl:if test="position() > 1">
 
 361                                                                 <xsl:text>,</xsl:text>
 
 363                                                         <xsl:value-of select="."/>
 
 365                                                 <xsl:text>)</xsl:text>
 
 367                                         <xsl:text> </xsl:text>
 
 369                                         <!-- Split long macro definitions across multiple lines -->
 
 370                                         <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
 
 371                                                 <xsl:text>\
	</xsl:text>
 
 374                                         <xsl:value-of select="initializer"/>
 
 376                                 <xsl:text> </xsl:text>
 
 379                         <xsl:apply-templates select="detaileddescription"/>
 
 383         <xsl:template match="memberdef[@kind = 'typedef']">
 
 384                 <section id="{@id}" xreflabel="{name}">
 
 386                                 <xsl:text>Type </xsl:text>
 
 387                                 <xsl:value-of select="name"/>
 
 390                         <xsl:call-template name="generate.index.id">
 
 391                                 <xsl:with-param name="name" select="name"/>
 
 394                         <programlisting language="c">
 
 395                                 <emphasis role="keyword">
 
 396                                         <xsl:text>typedef </xsl:text>
 
 397                                         <xsl:value-of select="type"/>
 
 399                                 <xsl:text> </xsl:text>
 
 400                                 <xsl:value-of select="name"/>
 
 401                                 <xsl:text> </xsl:text>
 
 402                                 <xsl:value-of select="argsstring"/>
 
 405                         <xsl:apply-templates select="detaileddescription"/>
 
 410         <xsl:template match="memberdef[@kind = 'variable']">
 
 411                 <section id="{@id}" xreflabel="{name}">
 
 413                                 <xsl:text>Variable </xsl:text>
 
 414                                 <xsl:value-of select="name"/>
 
 417                         <xsl:call-template name="generate.index.id">
 
 418                                 <xsl:with-param name="name" select="name"/>
 
 421                         <programlisting language="c">
 
 422                                 <emphasis role="keyword">
 
 423                                         <xsl:value-of select="type"/>
 
 425                                 <xsl:text> </xsl:text>
 
 426                                 <xsl:value-of select="name"/>
 
 429                         <xsl:apply-templates select="detaileddescription"/>
 
 433         <xsl:template match="linebreak | simplesectsep">
 
 434                 <!-- MUST be on two separate lines, as this is a *literal* newline -->
 
 439         <xsl:template match="verbatim">
 
 441                         <xsl:apply-templates/>
 
 445         <xsl:template match="sectiondef">
 
 447                         <xsl:value-of select="description"/>
 
 450                 <xsl:apply-templates select="memberdef"/>
 
 453         <xsl:template match="simplesect" mode="struct">
 
 455                         <xsl:apply-templates/>
 
 459         <xsl:template match="simplesect">
 
 461                         <xsl:when test="@kind = 'par'">
 
 464                                                 <xsl:value-of select="title"/>
 
 466                                         <xsl:apply-templates/>
 
 470                         <xsl:when test="@kind = 'return'">
 
 472                                         <title>Returns</title>
 
 473                                         <xsl:apply-templates/>
 
 477                         <xsl:when test="@kind = 'warning'">
 
 479                                         <title>Warning</title>
 
 480                                         <xsl:apply-templates/>
 
 484                         <xsl:when test="@kind = 'pre'">
 
 486                                         <title>Precondition</title>
 
 487                                         <xsl:apply-templates/>
 
 491                         <xsl:when test="@kind = 'see'">
 
 493                                         <title>See also</title>
 
 494                                         <xsl:apply-templates/>
 
 498                         <xsl:when test="@kind = 'note'">
 
 501                                         <xsl:apply-templates/>
 
 508         <xsl:template match="parameterlist[@kind = 'param']">
 
 510                         <title>Parameters</title>
 
 514                                                 <entry>Data Direction</entry>
 
 515                                                 <entry>Parameter Name</entry>
 
 516                                                 <entry>Description</entry>
 
 520                                         <xsl:for-each select="parameteritem">
 
 522                                                         <xsl:apply-templates select="."/>
 
 530         <xsl:template match="parameterlist[@kind = 'retval']">
 
 532                         <title>Return Values</title>
 
 536                                                 <entry>Return Value</entry>
 
 537                                                 <entry>Description</entry>
 
 541                                         <xsl:for-each select="parameteritem">
 
 543                                                         <xsl:apply-templates select="."/>
 
 551         <xsl:template match="parameteritem">
 
 552                 <xsl:if test="parent::parameterlist/@kind = 'param'">
 
 556                                                 <xsl:when test="not(descendant::parametername/@direction)">
 
 557                                                         <emphasis role="italic">?</emphasis>
 
 561                                                         <emphasis role="bold">
 
 562                                                                 [<xsl:value-of select="descendant::parametername/@direction"/>]
 
 572                                 <xsl:value-of select="parameternamelist/parametername"/>
 
 577                         <xsl:apply-templates select="parameterdescription"/>
 
 581         <xsl:template match="parameterdescription">
 
 583                         <xsl:apply-templates/>
 
 587         <xsl:template match="type">
 
 588                 <xsl:apply-templates/>
 
 591         <xsl:template match="bold">
 
 592                 <emphasis role="bold">
 
 593                         <xsl:apply-templates/>
 
 597         <xsl:template match="emphasis">
 
 598                 <emphasis role="italic">
 
 599                         <xsl:apply-templates/>
 
 603         <xsl:template match="small">
 
 604                 <xsl:apply-templates/>
 
 607         <xsl:template match="mdash | ndash">
 
 608                 <!-- Doxygen bug; double dashed are replaced with single HTML dash
 
 609                      entities, even in verbatim-like <tt> sections -->
 
 610                 <xsl:text>--</xsl:text>
 
 613         <xsl:template match="computeroutput | preformatted">
 
 615                         <xsl:apply-templates/>
 
 619         <xsl:template match="codeline">
 
 620                         <xsl:apply-templates/>
 
 623         <xsl:template match="ulink">
 
 625                         <xsl:value-of select="."/>
 
 629         <xsl:template match="superscript">
 
 631                         <xsl:apply-templates/>
 
 635         <xsl:template match="subscript">
 
 637                         <xsl:apply-templates/>
 
 641         <xsl:template match="para">
 
 643                         <xsl:apply-templates/>
 
 647         <xsl:template match="ref">
 
 649                         <!-- Don't show links inside program listings -->
 
 650                         <xsl:when test="ancestor::programlisting">
 
 651                                 <xsl:value-of select="."/>
 
 654                         <!-- Don't show links to file compound definitions, as they are discarded -->
 
 655                         <xsl:when test="ancestor::*/compounddef[@kind = 'file' and @id = current()/@refid]">
 
 656                                 <xsl:value-of select="."/>
 
 659                         <!-- Show links outside program listings -->
 
 661                                 <link linkend="{@refid}">
 
 662                                         <xsl:value-of select="text()"/>
 
 668         <xsl:template match="entry">
 
 670                         <xsl:apply-templates/>
 
 674         <xsl:template match="table[caption]">
 
 677                                 <xsl:value-of select="caption"/>
 
 680                         <tgroup cols="{@cols}">
 
 682                                         <xsl:apply-templates select="row[entry/@thead = 'yes']"/>
 
 686                                         <xsl:apply-templates select="row[entry/@thead != 'yes']"/>
 
 692         <xsl:template match="table[not(caption)]">
 
 694                         <tgroup cols="{@cols}">
 
 696                                         <xsl:apply-templates select="row[entry/@thead = 'yes']"/>
 
 700                                         <xsl:apply-templates select="row[entry/@thead != 'yes']"/>
 
 706         <xsl:template match="row">
 
 708                         <xsl:apply-templates/>
 
 712         <xsl:template match="itemizedlist">
 
 714                         <xsl:apply-templates/>
 
 718         <xsl:template match="orderedlist">
 
 720                         <xsl:apply-templates/>
 
 724         <xsl:template match="listitem">
 
 726                         <xsl:apply-templates/>
 
 730         <xsl:template match="programlisting">
 
 731                 <programlisting language="c">
 
 732                         <xsl:for-each select="codeline[position() > 1 or highlight]">
 
 733                                 <xsl:apply-templates select="."/>
 
 734                                 <xsl:text>
</xsl:text>
 
 739         <xsl:template match="highlight">
 
 740                 <emphasis role="{@class}">
 
 741                         <xsl:apply-templates/>
 
 745         <xsl:template match="highlight[1]/text()">
 
 747                         <xsl:when test="substring(., 1, 1) = '*'">
 
 748                                 <xsl:value-of select="substring(., 2)"/>
 
 752                                 <xsl:value-of select="."/>
 
 757         <xsl:template match="sp[ancestor::codeline]">
 
 758                 <xsl:text> </xsl:text>
 
 761         <xsl:template match="image">
 
 764                                 <imagedata align="center">
 
 765                                         <xsl:attribute name="fileref">
 
 766                                                 <xsl:text>images/</xsl:text>
 
 767                                                 <xsl:value-of select="@name"/>
 
 774         <xsl:template match="detaileddescription">
 
 775                 <xsl:apply-templates/>
 
 778         <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
 
 781                                 <xsl:attribute name="id">
 
 782                                         <xsl:value-of select="@id"/>
 
 787                                 <xsl:value-of select="title"/>
 
 790                         <xsl:apply-templates/>
 
 794         <xsl:template match="anchor">
 
 796                         <indexterm id="{@id}"/>
 
 800         <xsl:template match="title"/>
 
 802         <xsl:template match="htmlonly"/>
 
 804         <xsl:template match="*">
 
 805                 <xsl:message>NO XSL TEMPLATE MATCH: <xsl:value-of select="local-name()"/></xsl:message>