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:template name="generate.book.title">
 
   8                 <xsl:text>LUFA Library</xsl:text>
 
  11         <xsl:template name="generate.book.id">
 
  12                 <xsl:param name="book.title"/>
 
  15                                 <xsl:value-of select="@id"/>
 
  18                                 <xsl:value-of select="translate($book.title, ' ','')"/>
 
  23         <xsl:template name="generate.index.id">
 
  24                 <xsl:param name="name"/>
 
  25                 <xsl:variable name="book.title">
 
  26                         <xsl:call-template name="generate.book.title"/>
 
  28                 <xsl:variable name="book.id">
 
  29                         <xsl:call-template name="generate.book.id">
 
  30                                 <xsl:with-param name="book.title" select="$book.title"/>
 
  34                 <indexterm id="{$name}">
 
  36                                 <xsl:value-of select="$book.title"/>
 
  39                                 <xsl:value-of select="$name"/>
 
  44         <xsl:template match="doxygen">
 
  45                 <xsl:variable name="book.title">
 
  46                         <xsl:call-template name="generate.book.title"/>
 
  49                 <xsl:variable name="book.id">
 
  50                         <xsl:call-template name="generate.book.id">
 
  51                                 <xsl:with-param name="book.title" select="$book.title"/>
 
  55                 <book id="{$book.id}">
 
  57                                 <xsl:value-of select="$book.title"/>
 
  60                         <!-- Add index chapter -->
 
  61                         <xsl:apply-templates select="compounddef[@kind = 'page' and @id = 'indexpage']">
 
  62                                 <xsl:with-param name="element.type" select="'chapter'"/>
 
  63                                 <xsl:with-param name="page.title"   select="'Library Information'"/>
 
  64                         </xsl:apply-templates>
 
  66                         <!-- Add free-floating chapters -->
 
  67                         <xsl:apply-templates select="compounddef[@kind = 'page' and not(@id = 'indexpage') and not(//innerpage/@refid = @id)]">
 
  68                                 <xsl:with-param name="element.type" select="'chapter'"/>
 
  69                         </xsl:apply-templates>
 
  71                         <!-- Add Modules chapter -->
 
  73                                 <title>Modules</title>
 
  74                                 <xsl:apply-templates select="compounddef[@kind = 'group' and not(//innergroup/@refid = @id)]"/>
 
  79         <xsl:template match="compounddef[@kind = 'page']">
 
  80                 <xsl:param name="element.type" select="'section'"/>
 
  81                 <xsl:param name="page.title"   select="title"/>
 
  83                 <xsl:element name="{$element.type}">
 
  84                         <xsl:attribute name="id">
 
  85                                 <xsl:value-of select="@id"/>
 
  88                         <xsl:variable name="name">
 
  89                                 <xsl:text>LUFA.</xsl:text>
 
  90                                 <xsl:value-of select="translate(compoundname, '_', '.')"/>
 
  93                         <xsl:call-template name="generate.index.id">
 
  94                                 <xsl:with-param name="name" select="$name"/>
 
  98                                 <xsl:value-of select="$page.title"/>
 
 101                         <xsl:apply-templates select="detaileddescription"/>
 
 103                         <xsl:if test="not(innerpage) and count(detaileddescription//sect1)">
 
 105                                         <emphasis role="bold">Subsections:</emphasis>
 
 107                                                 <xsl:for-each select="detaileddescription//sect1">
 
 109                                                                 <link linkend="{@id}">
 
 110                                                                         <xsl:value-of select="title"/>
 
 118                         <xsl:for-each select="innerpage">
 
 119                                 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'page' and @id = current()/@refid]"/>
 
 124         <xsl:template match="compounddef[@kind = 'group']">
 
 127                                 <xsl:value-of select="title"/>
 
 130                         <xsl:variable name="name">
 
 131                                 <xsl:text>LUFA.</xsl:text>
 
 132                                 <xsl:value-of select="translate(compoundname, '_', '.')"/>
 
 135                         <xsl:call-template name="generate.index.id">
 
 136                                 <xsl:with-param name="name" select="$name"/>
 
 139                         <xsl:apply-templates select="detaileddescription"/>
 
 141                         <xsl:if test="count(innergroup)">
 
 143                                         <emphasis role="bold">Subgroups:</emphasis>
 
 145                                                 <xsl:for-each select="innergroup">
 
 147                                                                 <link linkend="{@refid}">
 
 148                                                                         <xsl:value-of select="text()"/>
 
 156                         <xsl:apply-templates select="sectiondef"/>
 
 158                         <xsl:for-each select="innerclass">
 
 159                                 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
 
 162                         <xsl:for-each select="innergroup">
 
 163                                 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'group' and @id = current()/@refid]"/>
 
 168         <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
 
 169                 <xsl:variable name="name" select="compoundname"/>
 
 171                 <section id="{@id}" xreflabel="{$name}">
 
 174                                         <xsl:when test="@kind = 'struct'">
 
 175                                                 <xsl:text>Struct </xsl:text>
 
 178                                         <xsl:when test="@kind = 'union'">
 
 179                                                 <xsl:text>Union </xsl:text>
 
 183                                 <xsl:value-of select="$name"/>
 
 186                         <xsl:call-template name="generate.index.id">
 
 187                                 <xsl:with-param name="name" select="$name"/>
 
 190                         <xsl:apply-templates select="detaileddescription"/>
 
 192                         <xsl:for-each select="sectiondef[@kind = 'public-attrib']">
 
 195                                                 <xsl:value-of select="$name"/>
 
 203                                                                 <entry>Description</entry>
 
 208                                                         <xsl:for-each select="memberdef">
 
 209                                                                 <row id="{@id}" xreflabel="{name}">
 
 211                                                                                 <xsl:value-of select="type"/>
 
 214                                                                                 <xsl:value-of select="name"/>
 
 215                                                                                 <xsl:if test="starts-with(argsstring, '[')">
 
 216                                                                                         <xsl:text>[]</xsl:text>
 
 219                                                                                 <xsl:variable name="struct.element.name">
 
 220                                                                                         <xsl:value-of select="$name"/>
 
 221                                                                                         <xsl:text>.</xsl:text>
 
 222                                                                                         <xsl:value-of select="name"/>
 
 225                                                                                 <xsl:call-template name="generate.index.id">
 
 226                                                                                         <xsl:with-param name="name" select="$struct.element.name"/>
 
 230                                                                                 <xsl:apply-templates select="detaileddescription"/>
 
 241         <xsl:template match="memberdef[@kind = 'function']">
 
 242                 <section id="{@id}" xreflabel="{name}">
 
 244                                 <xsl:text>Function </xsl:text>
 
 245                                 <xsl:value-of select="name"/>
 
 246                                 <xsl:text>()</xsl:text>
 
 249                         <xsl:call-template name="generate.index.id">
 
 250                                 <xsl:with-param name="name" select="name"/>
 
 254                                 <emphasis role="italic">
 
 255                                         <xsl:value-of select="briefdescription"/>
 
 259                         <programlisting language="c">
 
 260                                 <emphasis role="keyword">
 
 261                                         <xsl:value-of select="type"/>
 
 263                                 <xsl:text> </xsl:text>
 
 264                                 <xsl:value-of select="name"/>
 
 265                                 <xsl:text>(</xsl:text>
 
 268                                         <xsl:when test="not(param[1]/declname)">
 
 269                                                 <emphasis role="keyword">void</emphasis>
 
 273                                                 <xsl:for-each select="param">
 
 274                                                         <xsl:if test="position() > 1">
 
 275                                                                 <xsl:text>,</xsl:text>
 
 277                                                         <xsl:text>
	</xsl:text>
 
 278                                                         <emphasis role="keyword">
 
 279                                                                 <xsl:value-of select="type"/>
 
 281                                                         <xsl:text> </xsl:text>
 
 282                                                         <xsl:value-of select="declname"/>
 
 287                                 <xsl:text>)</xsl:text>
 
 290                         <xsl:apply-templates select="detaileddescription"/>
 
 294         <xsl:template match="memberdef[@kind = 'enum']">
 
 295                 <section id="{@id}" xreflabel="{name}">
 
 297                                 <xsl:text>Enum </xsl:text>
 
 298                                 <xsl:value-of select="name"/>
 
 301                         <xsl:call-template name="generate.index.id">
 
 302                                 <xsl:with-param name="name" select="name"/>
 
 305                         <xsl:apply-templates select="detaileddescription"/>
 
 308                                 <title>Members</title>
 
 312                                                         <entry>Enum Value</entry>
 
 313                                                         <entry>Description</entry>
 
 318                                                 <xsl:for-each select="enumvalue">
 
 321                                                                         <para id="{@id}" xreflabel="{name}">
 
 322                                                                                 <xsl:value-of select="name"/>
 
 324                                                                                 <xsl:call-template name="generate.index.id">
 
 325                                                                                         <xsl:with-param name="name" select="name"/>
 
 330                                                                         <xsl:apply-templates select="detaileddescription"/>
 
 340         <xsl:template match="memberdef[@kind = 'define']">
 
 341                 <section id="{@id}" xreflabel="{name}">
 
 343                                 <xsl:text>Macro </xsl:text>
 
 344                                 <xsl:value-of select="name"/>
 
 347                         <xsl:call-template name="generate.index.id">
 
 348                                 <xsl:with-param name="name" select="name"/>
 
 351                         <programlisting language="c">
 
 352                                 <emphasis role="preprocessor">
 
 353                                         <xsl:text>#define </xsl:text>
 
 354                                         <xsl:value-of select="name"/>
 
 355                                         <xsl:if test="count(param) > 0">
 
 356                                                 <xsl:text>(</xsl:text>
 
 357                                                 <xsl:for-each select="param/defname">
 
 358                                                         <xsl:if test="position() > 1">
 
 359                                                                 <xsl:text>,</xsl:text>
 
 361                                                         <xsl:value-of select="."/>
 
 363                                                 <xsl:text>)</xsl:text>
 
 365                                         <xsl:text> </xsl:text>
 
 367                                         <!-- Split long macro definitions across multiple lines -->
 
 368                                         <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
 
 369                                                 <xsl:text>\
	</xsl:text>
 
 372                                         <xsl:value-of select="initializer"/>
 
 374                                 <xsl:text> </xsl:text>
 
 377                         <xsl:apply-templates select="detaileddescription"/>
 
 381         <xsl:template match="memberdef[@kind = 'typedef']">
 
 382                 <section id="{@id}" xreflabel="{name}">
 
 384                                 <xsl:text>Type </xsl:text>
 
 385                                 <xsl:value-of select="name"/>
 
 388                         <xsl:call-template name="generate.index.id">
 
 389                                 <xsl:with-param name="name" select="name"/>
 
 392                         <programlisting language="c">
 
 393                                 <emphasis role="keyword">
 
 394                                         <xsl:text>typedef </xsl:text>
 
 395                                         <xsl:value-of select="type"/>
 
 397                                 <xsl:text> </xsl:text>
 
 398                                 <xsl:value-of select="name"/>
 
 399                                 <xsl:text> </xsl:text>
 
 400                                 <xsl:value-of select="argsstring"/>
 
 403                         <xsl:apply-templates select="detaileddescription"/>
 
 408         <xsl:template match="memberdef[@kind = 'variable']">
 
 409                 <section id="{@id}" xreflabel="{name}">
 
 411                                 <xsl:text>Variable </xsl:text>
 
 412                                 <xsl:value-of select="name"/>
 
 415                         <xsl:call-template name="generate.index.id">
 
 416                                 <xsl:with-param name="name" select="name"/>
 
 419                         <programlisting language="c">
 
 420                                 <emphasis role="keyword">
 
 421                                         <xsl:value-of select="type"/>
 
 423                                 <xsl:text> </xsl:text>
 
 424                                 <xsl:value-of select="name"/>
 
 427                         <xsl:apply-templates select="detaileddescription"/>
 
 431         <xsl:template match="linebreak | simplesectsep">
 
 432                 <!-- MUST be on two separate lines, as this is a *literal* newline -->
 
 437         <xsl:template match="verbatim">
 
 439                         <xsl:apply-templates/>
 
 443         <xsl:template match="sectiondef">
 
 445                         <xsl:value-of select="description"/>
 
 448                 <xsl:apply-templates select="memberdef"/>
 
 451         <xsl:template match="simplesect" mode="struct">
 
 453                         <xsl:apply-templates/>
 
 457         <xsl:template match="simplesect">
 
 459                         <xsl:when test="@kind = 'par'">
 
 462                                                 <xsl:value-of select="title"/>
 
 464                                         <xsl:apply-templates/>
 
 468                         <xsl:when test="@kind = 'return'">
 
 470                                         <title>Returns</title>
 
 471                                         <xsl:apply-templates/>
 
 475                         <xsl:when test="@kind = 'warning'">
 
 477                                         <title>Warning</title>
 
 478                                         <xsl:apply-templates/>
 
 482                         <xsl:when test="@kind = 'pre'">
 
 484                                         <title>Precondition</title>
 
 485                                         <xsl:apply-templates/>
 
 489                         <xsl:when test="@kind = 'see'">
 
 491                                         <title>See also</title>
 
 492                                         <xsl:apply-templates/>
 
 496                         <xsl:when test="@kind = 'note'">
 
 499                                         <xsl:apply-templates/>
 
 506         <xsl:template match="parameterlist[@kind = 'param']">
 
 508                         <title>Parameters</title>
 
 512                                                 <entry>Data Direction</entry>
 
 513                                                 <entry>Parameter Name</entry>
 
 514                                                 <entry>Description</entry>
 
 518                                         <xsl:for-each select="parameteritem">
 
 520                                                         <xsl:apply-templates select="."/>
 
 528         <xsl:template match="parameterlist[@kind = 'retval']">
 
 530                         <title>Return Values</title>
 
 534                                                 <entry>Return Value</entry>
 
 535                                                 <entry>Description</entry>
 
 539                                         <xsl:for-each select="parameteritem">
 
 541                                                         <xsl:apply-templates select="."/>
 
 549         <xsl:template match="parameteritem">
 
 550                 <xsl:if test="parent::parameterlist/@kind = 'param'">
 
 554                                                 <xsl:when test="not(descendant::parametername/@direction)">
 
 555                                                         <emphasis role="italic">?</emphasis>
 
 559                                                         <emphasis role="bold">
 
 560                                                                 [<xsl:value-of select="descendant::parametername/@direction"/>]
 
 570                                 <xsl:value-of select="parameternamelist/parametername"/>
 
 575                         <xsl:apply-templates select="parameterdescription"/>
 
 579         <xsl:template match="parameterdescription">
 
 581                         <xsl:apply-templates/>
 
 585         <xsl:template match="type">
 
 586                 <xsl:apply-templates/>
 
 589         <xsl:template match="bold">
 
 590                 <emphasis role="bold">
 
 591                         <xsl:apply-templates/>
 
 595         <xsl:template match="emphasis">
 
 596                 <emphasis role="italic">
 
 597                         <xsl:apply-templates/>
 
 601         <xsl:template match="small">
 
 602                 <xsl:apply-templates/>
 
 605         <xsl:template match="mdash | ndash">
 
 606                 <!-- Doxygen bug; double dashed are replaced with single HTML dash
 
 607                      entities, even in verbatim-like <tt> sections -->
 
 608                 <xsl:text>--</xsl:text>
 
 611         <xsl:template match="computeroutput | preformatted">
 
 613                         <xsl:apply-templates/>
 
 617         <xsl:template match="codeline">
 
 618                         <xsl:apply-templates/>
 
 621         <xsl:template match="ulink">
 
 623                         <xsl:value-of select="."/>
 
 627         <xsl:template match="superscript">
 
 629                         <xsl:apply-templates/>
 
 633         <xsl:template match="subscript">
 
 635                         <xsl:apply-templates/>
 
 639         <xsl:template match="para">
 
 641                         <xsl:apply-templates/>
 
 645         <xsl:template match="ref">
 
 647                         <!-- Don't show links inside program listings -->
 
 648                         <xsl:when test="ancestor::programlisting">
 
 649                                 <xsl:value-of select="."/>
 
 652                         <!-- Don't show links to file compound definitions, as they are discarded -->
 
 653                         <xsl:when test="ancestor::*/compounddef[@kind = 'file' and @id = current()/@refid]">
 
 654                                 <xsl:value-of select="."/>
 
 657                         <!-- Show links outside program listings -->
 
 659                                 <link linkend="{@refid}">
 
 660                                         <xsl:value-of select="text()"/>
 
 666         <xsl:template match="entry">
 
 668                         <xsl:apply-templates/>
 
 672         <xsl:template match="table[caption]">
 
 675                                 <xsl:value-of select="caption"/>
 
 678                         <tgroup cols="{@cols}">
 
 680                                         <xsl:apply-templates select="row[entry/@thead = 'yes']"/>
 
 684                                         <xsl:apply-templates select="row[entry/@thead != 'yes']"/>
 
 690         <xsl:template match="table[not(caption)]">
 
 692                         <tgroup cols="{@cols}">
 
 694                                         <xsl:apply-templates select="row[entry/@thead = 'yes']"/>
 
 698                                         <xsl:apply-templates select="row[entry/@thead != 'yes']"/>
 
 704         <xsl:template match="row">
 
 706                         <xsl:apply-templates/>
 
 710         <xsl:template match="itemizedlist">
 
 712                         <xsl:apply-templates/>
 
 716         <xsl:template match="orderedlist">
 
 718                         <xsl:apply-templates/>
 
 722         <xsl:template match="listitem">
 
 724                         <xsl:apply-templates/>
 
 728         <xsl:template match="programlisting">
 
 729                 <programlisting language="c">
 
 730                         <xsl:for-each select="codeline[position() > 1 or highlight]">
 
 731                                 <xsl:apply-templates select="."/>
 
 732                                 <xsl:text>
</xsl:text>
 
 737         <xsl:template match="highlight">
 
 738                 <emphasis role="{@class}">
 
 739                         <xsl:apply-templates/>
 
 743         <xsl:template match="highlight[1]/text()">
 
 745                         <xsl:when test="substring(., 1, 1) = '*'">
 
 746                                 <xsl:value-of select="substring(., 2)"/>
 
 750                                 <xsl:value-of select="."/>
 
 755         <xsl:template match="sp[ancestor::codeline]">
 
 756                 <xsl:text> </xsl:text>
 
 759         <xsl:template match="image">
 
 762                                 <imagedata align="center">
 
 763                                         <xsl:attribute name="fileref">
 
 764                                                 <xsl:text>images/</xsl:text>
 
 765                                                 <xsl:value-of select="@name"/>
 
 772         <xsl:template match="detaileddescription">
 
 773                 <xsl:apply-templates/>
 
 776         <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
 
 779                                 <xsl:attribute name="id">
 
 780                                         <xsl:value-of select="@id"/>
 
 785                                 <xsl:value-of select="title"/>
 
 788                         <xsl:apply-templates/>
 
 792         <xsl:template match="anchor">
 
 794                         <indexterm id="{@id}"/>
 
 798         <xsl:template match="title"/>
 
 800         <xsl:template match="htmlonly"/>
 
 802         <xsl:template match="*">
 
 803                 <xsl:message>NO XSL TEMPLATE MATCH: <xsl:value-of select="local-name()"/></xsl:message>