plain.xsl 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet
  3. version = "1.0"
  4. xmlns = "http://www.w3.org/1999/xhtml"
  5. xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
  6. >
  7. <xsl:output
  8. method = "xml"
  9. encoding = "UTF-8"
  10. doctype-public = "-//W3C//DTD XHTML 1.0 Transitional//EN"
  11. doctype-system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
  12. indent = "no"
  13. media-type = "text/html"
  14. />
  15. <xsl:param name="css" select="'styles/plain.css'"/>
  16. <xsl:param name="title" select="'Configuration Documentation'"/>
  17. <xsl:variable name="typeLookup" select="document('../types.xml')/types" />
  18. <xsl:variable name="usageLookup" select="document('../usage.xml')/usage" />
  19. <!-- Twiddle this variable to get the columns as even as possible -->
  20. <xsl:variable name="maxNumberAdjust" select="2" />
  21. <xsl:template match="/">
  22. <html lang="en" xml:lang="en">
  23. <head>
  24. <title><xsl:value-of select="$title" /> - <xsl:value-of select="/configdoc/title" /></title>
  25. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  26. <link rel="stylesheet" type="text/css" href="{$css}" />
  27. </head>
  28. <body>
  29. <div id="content">
  30. <div id="library"><xsl:value-of select="/configdoc/title" /></div>
  31. <h1><xsl:value-of select="$title" /></h1>
  32. <div id="tocContainer">
  33. <h2>Table of Contents</h2>
  34. <ul id="toc">
  35. <xsl:apply-templates mode="toc">
  36. <xsl:with-param name="overflowNumber" select="round(count(/configdoc/namespace) div 2) + $maxNumberAdjust" />
  37. </xsl:apply-templates>
  38. </ul>
  39. </div>
  40. <div id="typesContainer">
  41. <h2>Types</h2>
  42. <xsl:apply-templates select="$typeLookup" mode="types" />
  43. </div>
  44. <xsl:apply-templates />
  45. </div>
  46. </body>
  47. </html>
  48. </xsl:template>
  49. <xsl:template match="type" mode="types">
  50. <div class="type-block">
  51. <xsl:attribute name="id">type-<xsl:value-of select="@id" /></xsl:attribute>
  52. <h3><code><xsl:value-of select="@id" /></code>: <xsl:value-of select="@name" /></h3>
  53. <div class="type-description">
  54. <xsl:copy-of xmlns:xhtml="http://www.w3.org/1999/xhtml" select="xhtml:div/node()" />
  55. </div>
  56. </div>
  57. </xsl:template>
  58. <xsl:template match="title" mode="toc" />
  59. <xsl:template match="namespace" mode="toc">
  60. <xsl:param name="overflowNumber" />
  61. <xsl:variable name="number"><xsl:number level="single" /></xsl:variable>
  62. <xsl:variable name="directiveNumber"><xsl:number level="any" count="directive" /></xsl:variable>
  63. <xsl:if test="count(directive)&gt;0">
  64. <li>
  65. <!-- BEGIN multicolumn code -->
  66. <xsl:if test="$number &gt;= $overflowNumber">
  67. <xsl:attribute name="class">col-2</xsl:attribute>
  68. </xsl:if>
  69. <xsl:if test="$number = $overflowNumber">
  70. <xsl:attribute name="style">margin-top:-<xsl:value-of select="($number * 2 + $directiveNumber - 3) * 1.2" />em</xsl:attribute>
  71. </xsl:if>
  72. <!-- END multicolumn code -->
  73. <a href="#{@id}"><xsl:value-of select="name" /></a>
  74. <ul>
  75. <xsl:apply-templates select="directive" mode="toc">
  76. <xsl:with-param name="overflowNumber" select="$overflowNumber" />
  77. </xsl:apply-templates>
  78. </ul>
  79. <xsl:if test="$number + 1 = $overflowNumber">
  80. <div class="col-l" />
  81. </xsl:if>
  82. </li>
  83. </xsl:if>
  84. </xsl:template>
  85. <xsl:template match="directive" mode="toc">
  86. <xsl:variable name="number">
  87. <xsl:number level="any" count="directive|namespace" />
  88. </xsl:variable>
  89. <xsl:if test="not(deprecated)">
  90. <li>
  91. <a href="#{@id}"><xsl:value-of select="name" /></a>
  92. </li>
  93. </xsl:if>
  94. </xsl:template>
  95. <xsl:template match="title" />
  96. <xsl:template match="namespace">
  97. <div class="namespace">
  98. <xsl:apply-templates />
  99. <xsl:if test="count(directive)=0">
  100. <p>No configuration directives defined for this namespace.</p>
  101. </xsl:if>
  102. </div>
  103. </xsl:template>
  104. <xsl:template match="namespace/name">
  105. <h2 id="{../@id}"><xsl:value-of select="." /></h2>
  106. </xsl:template>
  107. <xsl:template match="namespace/description">
  108. <div class="description">
  109. <xsl:copy-of xmlns:xhtml="http://www.w3.org/1999/xhtml" select="xhtml:div/node()" />
  110. </div>
  111. </xsl:template>
  112. <xsl:template match="directive">
  113. <div>
  114. <xsl:attribute name="class"><!--
  115. -->directive<!--
  116. --><xsl:if test="deprecated"> deprecated</xsl:if><!--
  117. --></xsl:attribute>
  118. <xsl:apply-templates>
  119. <xsl:with-param name="id" select="@id" />
  120. </xsl:apply-templates>
  121. </div>
  122. </xsl:template>
  123. <xsl:template match="directive/name">
  124. <xsl:param name="id" />
  125. <xsl:apply-templates select="../aliases/alias" mode="anchor" />
  126. <h3 id="{$id}"><xsl:value-of select="$id" /></h3>
  127. </xsl:template>
  128. <xsl:template match="alias" mode="anchor">
  129. <a id="{.}"></a>
  130. </xsl:template>
  131. <!-- Do not pass through -->
  132. <xsl:template match="alias"></xsl:template>
  133. <xsl:template match="directive/constraints">
  134. <xsl:param name="id" />
  135. <table class="constraints">
  136. <xsl:apply-templates />
  137. <xsl:if test="../aliases/alias">
  138. <xsl:apply-templates select="../aliases" mode="constraints" />
  139. </xsl:if>
  140. <xsl:apply-templates select="$usageLookup/directive[@id=$id]" />
  141. </table>
  142. </xsl:template>
  143. <xsl:template match="directive/aliases" mode="constraints">
  144. <tr>
  145. <th>Aliases</th>
  146. <td>
  147. <xsl:for-each select="alias">
  148. <xsl:if test="position()&gt;1">, </xsl:if>
  149. <xsl:value-of select="." />
  150. </xsl:for-each>
  151. </td>
  152. </tr>
  153. </xsl:template>
  154. <xsl:template match="directive/description">
  155. <div class="description">
  156. <xsl:copy-of xmlns:xhtml="http://www.w3.org/1999/xhtml" select="xhtml:div/node()" />
  157. </div>
  158. </xsl:template>
  159. <xsl:template match="directive/deprecated">
  160. <div class="deprecated-notice">
  161. <strong>Warning:</strong>
  162. This directive was deprecated in version <xsl:value-of select="version" />.
  163. <a href="#{use}">%<xsl:value-of select="use" /></a> should be used instead.
  164. </div>
  165. </xsl:template>
  166. <xsl:template match="usage/directive">
  167. <tr>
  168. <th>Used in</th>
  169. <td>
  170. <ul>
  171. <xsl:apply-templates />
  172. </ul>
  173. </td>
  174. </tr>
  175. </xsl:template>
  176. <xsl:template match="usage/directive/file">
  177. <li>
  178. <em><xsl:value-of select="@name" /></em> on line<xsl:if test="count(line)&gt;1">s</xsl:if>
  179. <xsl:text> </xsl:text>
  180. <xsl:for-each select="line">
  181. <xsl:if test="position()&gt;1">, </xsl:if>
  182. <xsl:value-of select="." />
  183. </xsl:for-each>
  184. </li>
  185. </xsl:template>
  186. <xsl:template match="constraints/version">
  187. <tr>
  188. <th>Version added</th>
  189. <td><xsl:value-of select="." /></td>
  190. </tr>
  191. </xsl:template>
  192. <xsl:template match="constraints/type">
  193. <tr>
  194. <th>Type</th>
  195. <td>
  196. <xsl:variable name="type" select="text()" />
  197. <xsl:attribute name="class">type type-<xsl:value-of select="$type" /></xsl:attribute>
  198. <a>
  199. <xsl:attribute name="href">#type-<xsl:value-of select="$type" /></xsl:attribute>
  200. <xsl:value-of select="$typeLookup/type[@id=$type]/@name" />
  201. <xsl:if test="@allow-null='yes'">
  202. (or null)
  203. </xsl:if>
  204. </a>
  205. </td>
  206. </tr>
  207. </xsl:template>
  208. <xsl:template match="constraints/allowed">
  209. <tr>
  210. <th>Allowed values</th>
  211. <td>
  212. <xsl:for-each select="value"><!--
  213. --><xsl:if test="position()&gt;1">, </xsl:if>
  214. &quot;<xsl:value-of select="." />&quot;<!--
  215. --></xsl:for-each>
  216. </td>
  217. </tr>
  218. </xsl:template>
  219. <xsl:template match="constraints/default">
  220. <tr>
  221. <th>Default</th>
  222. <td><pre><xsl:value-of select="." xml:space="preserve" /></pre></td>
  223. </tr>
  224. </xsl:template>
  225. <xsl:template match="constraints/external">
  226. <tr>
  227. <th>External deps</th>
  228. <td>
  229. <ul>
  230. <xsl:apply-templates />
  231. </ul>
  232. </td>
  233. </tr>
  234. </xsl:template>
  235. <xsl:template match="constraints/external/project">
  236. <li><xsl:value-of select="." /></li>
  237. </xsl:template>
  238. </xsl:stylesheet>
  239. <!-- vim: et sw=4 sts=4
  240. -->