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:apply-templates select="sectiondef"/>
 
 145                         <xsl:for-each select="innerclass">
 
 146                                 <xsl:apply-templates select="ancestor::*/compounddef[@id = current()/@refid]"/>
 
 149                         <xsl:for-each select="innergroup">
 
 150                                 <xsl:apply-templates select="ancestor::*/compounddef[@kind = 'group' and @id = current()/@refid]"/>
 
 155         <xsl:template match="compounddef[@kind = 'struct' or @kind = 'union']">
 
 156                 <xsl:variable name="name" select="compoundname"/>
 
 158                 <section id="{@id}" xreflabel="{$name}">
 
 161                                         <xsl:when test="@kind = 'struct'">
 
 162                                                 <xsl:text>Struct </xsl:text>
 
 165                                         <xsl:when test="@kind = 'union'">
 
 166                                                 <xsl:text>Union </xsl:text>
 
 170                                 <xsl:value-of select="$name"/>
 
 173                         <xsl:call-template name="generate.index.id">
 
 174                                 <xsl:with-param name="name" select="$name"/>
 
 177                         <xsl:apply-templates select="detaileddescription"/>
 
 179                         <xsl:for-each select="sectiondef[@kind = 'public-attrib']">
 
 180                                 <table tabstyle="striped">
 
 182                                                 <xsl:value-of select="$name"/>
 
 190                                                                 <entry>Description</entry>
 
 195                                                         <xsl:for-each select="memberdef">
 
 196                                                                 <row id="{@id}" xreflabel="{name}">
 
 198                                                                                 <xsl:value-of select="type"/>
 
 201                                                                                 <xsl:value-of select="name"/>
 
 202                                                                                 <xsl:if test="starts-with(argsstring, '[')">
 
 203                                                                                         <xsl:text>[]</xsl:text>
 
 206                                                                                 <xsl:variable name="struct.element.name">
 
 207                                                                                         <xsl:value-of select="$name"/>
 
 208                                                                                         <xsl:text>.</xsl:text>
 
 209                                                                                         <xsl:value-of select="name"/>
 
 212                                                                                 <xsl:call-template name="generate.index.id">
 
 213                                                                                         <xsl:with-param name="name" select="$struct.element.name"/>
 
 217                                                                                 <xsl:apply-templates select="detaileddescription"/>
 
 228         <xsl:template match="memberdef[@kind = 'function']">
 
 229                 <section id="{@id}" xreflabel="{name}">
 
 231                                 <xsl:text>Function </xsl:text>
 
 232                                 <xsl:value-of select="name"/>
 
 233                                 <xsl:text>()</xsl:text>
 
 236                         <xsl:call-template name="generate.index.id">
 
 237                                 <xsl:with-param name="name" select="name"/>
 
 241                                 <emphasis role="italic">
 
 242                                         <xsl:value-of select="briefdescription"/>
 
 246                         <programlisting language="c">
 
 247                                 <emphasis role="keyword">
 
 248                                         <xsl:value-of select="type"/>
 
 250                                 <xsl:text> </xsl:text>
 
 251                                 <xsl:value-of select="name"/>
 
 252                                 <xsl:text>(</xsl:text>
 
 255                                         <xsl:when test="not(param[1]/declname)">
 
 256                                                 <emphasis role="keyword">void</emphasis>
 
 260                                                 <xsl:for-each select="param">
 
 261                                                         <xsl:if test="position() > 1">
 
 262                                                                 <xsl:text>,</xsl:text>
 
 264                                                         <xsl:text>
	</xsl:text>
 
 265                                                         <emphasis role="keyword">
 
 266                                                                 <xsl:value-of select="type"/>
 
 268                                                         <xsl:text> </xsl:text>
 
 269                                                         <xsl:value-of select="declname"/>
 
 274                                 <xsl:text>)</xsl:text>
 
 277                         <xsl:apply-templates select="detaileddescription"/>
 
 281         <xsl:template match="memberdef[@kind = 'enum']">
 
 282                 <section id="{@id}" xreflabel="{name}">
 
 284                                 <xsl:text>Enum </xsl:text>
 
 285                                 <xsl:value-of select="name"/>
 
 288                         <xsl:call-template name="generate.index.id">
 
 289                                 <xsl:with-param name="name" select="name"/>
 
 292                         <xsl:apply-templates select="detaileddescription"/>
 
 294                         <table tabstyle="striped">
 
 295                                 <title>Members</title>
 
 299                                                         <entry>Enum Value</entry>
 
 300                                                         <entry>Description</entry>
 
 305                                                 <xsl:for-each select="enumvalue">
 
 308                                                                         <para id="{@id}" xreflabel="{name}">
 
 309                                                                                 <xsl:value-of select="name"/>
 
 311                                                                                 <xsl:call-template name="generate.index.id">
 
 312                                                                                         <xsl:with-param name="name" select="name"/>
 
 317                                                                         <xsl:apply-templates select="detaileddescription"/>
 
 327         <xsl:template match="memberdef[@kind = 'define']">
 
 328                 <section id="{@id}" xreflabel="{name}">
 
 330                                 <xsl:text>Macro </xsl:text>
 
 331                                 <xsl:value-of select="name"/>
 
 334                         <xsl:call-template name="generate.index.id">
 
 335                                 <xsl:with-param name="name" select="name"/>
 
 338                         <programlisting language="c">
 
 339                                 <emphasis role="preprocessor">
 
 340                                         <xsl:text>#define </xsl:text>
 
 341                                         <xsl:value-of select="name"/>
 
 342                                         <xsl:if test="count(param) > 0">
 
 343                                                 <xsl:text>(</xsl:text>
 
 344                                                 <xsl:for-each select="param/defname">
 
 345                                                         <xsl:if test="position() > 1">
 
 346                                                                 <xsl:text>,</xsl:text>
 
 348                                                         <xsl:value-of select="."/>
 
 350                                                 <xsl:text>)</xsl:text>
 
 352                                         <xsl:text> </xsl:text>
 
 354                                         <!-- Split long macro definitions across multiple lines -->
 
 355                                         <xsl:if test="(string-length(initializer) > 50) or (count(param) > 0)">
 
 356                                                 <xsl:text>\
	</xsl:text>
 
 359                                         <xsl:value-of select="initializer"/>
 
 361                                 <xsl:text> </xsl:text>
 
 364                         <xsl:apply-templates select="detaileddescription"/>
 
 368         <xsl:template match="memberdef[@kind = 'typedef']">
 
 369                 <section id="{@id}" xreflabel="{name}">
 
 371                                 <xsl:text>Type </xsl:text>
 
 372                                 <xsl:value-of select="name"/>
 
 375                         <xsl:call-template name="generate.index.id">
 
 376                                 <xsl:with-param name="name" select="name"/>
 
 379                         <programlisting language="c">
 
 380                                 <emphasis role="keyword">
 
 381                                         <xsl:text>typedef </xsl:text>
 
 382                                         <xsl:value-of select="type"/>
 
 384                                 <xsl:text> </xsl:text>
 
 385                                 <xsl:value-of select="name"/>
 
 386                                 <xsl:text> </xsl:text>
 
 387                                 <xsl:value-of select="argsstring"/>
 
 390                         <xsl:apply-templates select="detaileddescription"/>
 
 395         <xsl:template match="memberdef[@kind = 'variable']">
 
 396                 <section id="{@id}" xreflabel="{name}">
 
 398                                 <xsl:text>Variable </xsl:text>
 
 399                                 <xsl:value-of select="name"/>
 
 402                         <xsl:call-template name="generate.index.id">
 
 403                                 <xsl:with-param name="name" select="name"/>
 
 406                         <programlisting language="c">
 
 407                                 <emphasis role="keyword">
 
 408                                         <xsl:value-of select="type"/>
 
 410                                 <xsl:text> </xsl:text>
 
 411                                 <xsl:value-of select="name"/>
 
 414                         <xsl:apply-templates select="detaileddescription"/>
 
 418         <xsl:template match="linebreak | simplesectsep">
 
 419                 <!-- MUST be on two separate lines, as this is a *literal* newline -->
 
 424         <xsl:template match="verbatim">
 
 426                         <xsl:apply-templates/>
 
 430         <xsl:template match="sectiondef">
 
 432                         <xsl:value-of select="description"/>
 
 435                 <xsl:apply-templates select="memberdef"/>
 
 438         <xsl:template match="simplesect" mode="struct">
 
 440                         <xsl:apply-templates/>
 
 444         <xsl:template match="simplesect">
 
 446                         <xsl:when test="@kind = 'par'">
 
 449                                                 <xsl:value-of select="title"/>
 
 451                                         <xsl:apply-templates/>
 
 455                         <xsl:when test="@kind = 'return'">
 
 457                                         <title>Returns</title>
 
 458                                         <xsl:apply-templates/>
 
 462                         <xsl:when test="@kind = 'warning'">
 
 464                                         <title>Warning</title>
 
 465                                         <xsl:apply-templates/>
 
 469                         <xsl:when test="@kind = 'pre'">
 
 471                                         <title>Precondition</title>
 
 472                                         <xsl:apply-templates/>
 
 476                         <xsl:when test="@kind = 'see'">
 
 478                                         <title>See also</title>
 
 479                                         <xsl:apply-templates/>
 
 483                         <xsl:when test="@kind = 'note'">
 
 486                                         <xsl:apply-templates/>
 
 493         <xsl:template match="parameterlist[@kind = 'param']">
 
 494                 <table tabstyle="striped">
 
 495                         <title>Parameters</title>
 
 499                                                 <entry>Data Direction</entry>
 
 500                                                 <entry>Parameter Name</entry>
 
 501                                                 <entry>Description</entry>
 
 505                                         <xsl:for-each select="parameteritem">
 
 507                                                         <xsl:apply-templates select="."/>
 
 515         <xsl:template match="parameterlist[@kind = 'retval']">
 
 516                 <table tabstyle="striped">
 
 517                         <title>Return Values</title>
 
 521                                                 <entry>Return Value</entry>
 
 522                                                 <entry>Description</entry>
 
 526                                         <xsl:for-each select="parameteritem">
 
 528                                                         <xsl:apply-templates select="."/>
 
 536         <xsl:template match="parameteritem">
 
 537                 <xsl:if test="parent::parameterlist/@kind = 'param'">
 
 541                                                 <xsl:when test="not(descendant::parametername/@direction)">
 
 542                                                         <emphasis role="italic">?</emphasis>
 
 546                                                         <emphasis role="bold">
 
 547                                                                 [<xsl:value-of select="descendant::parametername/@direction"/>]
 
 557                                 <xsl:value-of select="parameternamelist/parametername"/>
 
 562                         <xsl:apply-templates select="parameterdescription"/>
 
 566         <xsl:template match="parameterdescription">
 
 568                         <xsl:apply-templates/>
 
 572         <xsl:template match="type">
 
 573                 <xsl:apply-templates/>
 
 576         <xsl:template match="bold">
 
 577                 <emphasis role="bold">
 
 578                         <xsl:apply-templates/>
 
 582         <xsl:template match="emphasis">
 
 583                 <emphasis role="italic">
 
 584                         <xsl:apply-templates/>
 
 588         <xsl:template match="small">
 
 589                 <xsl:apply-templates/>
 
 592         <xsl:template match="mdash | ndash">
 
 593                 <!-- Doxygen bug; double dashed are replaced with single HTML dash
 
 594                      entities, even in verbatim-like <tt> sections -->
 
 595                 <xsl:text>--</xsl:text>
 
 598         <xsl:template match="computeroutput | preformatted">
 
 600                         <xsl:apply-templates/>
 
 604         <xsl:template match="codeline">
 
 605                         <xsl:apply-templates/>
 
 608         <xsl:template match="ulink">
 
 610                         <xsl:value-of select="."/>
 
 614         <xsl:template match="superscript">
 
 616                         <xsl:apply-templates/>
 
 620         <xsl:template match="subscript">
 
 622                         <xsl:apply-templates/>
 
 626         <xsl:template match="para">
 
 628                         <xsl:apply-templates/>
 
 632         <xsl:template match="ref">
 
 634                         <!-- Don't show links inside program listings -->
 
 635                         <xsl:when test="ancestor::programlisting">
 
 636                                 <xsl:value-of select="."/>
 
 639                         <!-- Don't show links to file compound definitions, as they are discarded -->
 
 640                         <xsl:when test="ancestor::*/compounddef[@kind = 'file' and @id = current()/@refid]">
 
 641                                 <xsl:value-of select="."/>
 
 644                         <!-- Show links outside program listings -->
 
 646                                 <link linkend="{@refid}">
 
 647                                         <xsl:value-of select="text()"/>
 
 653         <xsl:template match="entry">
 
 655                         <xsl:apply-templates/>
 
 659         <xsl:template match="table">
 
 661                         <xsl:when test="caption">
 
 662                                 <table tabstyle="striped">
 
 664                                                 <xsl:value-of select="caption"/>
 
 667                                         <xsl:call-template name="write.table.content"/>
 
 672                                 <informaltable tabstyle="striped">
 
 673                                         <xsl:call-template name="write.table.content"/>
 
 679         <xsl:template name="write.table.content">
 
 680                 <tgroup cols="{@cols}">
 
 682                                 <xsl:for-each select="row[1]">
 
 684                                                 <xsl:apply-templates select="entry"/>
 
 690                                 <xsl:for-each select="row[position() != 1]">
 
 692                                                 <xsl:apply-templates select="entry"/>
 
 699         <xsl:template match="itemizedlist">
 
 701                         <xsl:apply-templates/>
 
 705         <xsl:template match="orderedlist">
 
 707                         <xsl:apply-templates/>
 
 711         <xsl:template match="listitem">
 
 713                         <xsl:apply-templates/>
 
 717         <xsl:template match="programlisting">
 
 718                 <programlisting language="c">
 
 719                         <xsl:for-each select="codeline[position() > 1 or highlight]">
 
 720                                 <xsl:apply-templates select="."/>
 
 721                                 <xsl:text>
</xsl:text>
 
 726         <xsl:template match="highlight">
 
 727                 <emphasis role="{@class}">
 
 728                         <xsl:apply-templates/>
 
 732         <xsl:template match="sp[ancestor::codeline]">
 
 733                 <xsl:text> </xsl:text>
 
 736         <xsl:template match="image">
 
 739                                 <imagedata align="center">
 
 740                                         <xsl:attribute name="fileref">
 
 741                                                 <xsl:text>images/</xsl:text>
 
 742                                                 <xsl:value-of select="@name"/>
 
 749         <xsl:template match="detaileddescription">
 
 750                 <xsl:apply-templates/>
 
 753         <xsl:template match="sect1 | sect2 | sect3 | sect4 | sect5 | sect6 | sect7 | sect8 | sect9">
 
 756                                 <xsl:attribute name="id">
 
 757                                         <xsl:value-of select="@id"/>
 
 762                                 <xsl:value-of select="title"/>
 
 765                         <xsl:apply-templates/>
 
 769         <xsl:template match="anchor">
 
 771                         <indexterm id="{@id}"/>
 
 775         <xsl:template match="title"/>
 
 777         <xsl:template match="htmlonly"/>
 
 779         <xsl:template match="*">
 
 780                 <xsl:message>NO XSL TEMPLATE MATCH: <xsl:value-of select="name()"/></xsl:message>