cuberef2xhtml.xslt 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:transform version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:t="https://assault.cubers.net/docs/xml">
  3. <!--
  4. This file transforms the ../reference.xml document into an XHTML webpage.
  5. Written by: Rabid Viper Productions.
  6. Special thanks to Adrian 'driAn' Henke for the original document
  7. that all these XML-related files are based upon.
  8. You may be able to redistribute this content under specific
  9. conditions. Please read the licensing information, available
  10. at https://assault.cubers.net/docs/license.html for the
  11. conditions that would apply to what you may be redistributing.
  12. -->
  13. <xsl:output method="html" omit-xml-declaration="yes" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
  14. <xsl:template match="t:key">
  15. <i>
  16. <xsl:choose>
  17. <xsl:when test="@name">
  18. <xsl:value-of select="@name"/>
  19. </xsl:when>
  20. <xsl:otherwise>
  21. <xsl:value-of select="@alias"/>
  22. </xsl:otherwise>
  23. </xsl:choose>
  24. </i>
  25. <xsl:if test="@description">
  26. <xsl:text> - </xsl:text>
  27. <xsl:value-of select="@description"/>
  28. </xsl:if>
  29. </xsl:template>
  30. <xsl:template name="identifierLink">
  31. <a>
  32. <xsl:attribute name="href">
  33. <xsl:text>#identifier_</xsl:text>
  34. <xsl:value-of select="translate(@name, ' ', '_')"/>
  35. </xsl:attribute>
  36. <xsl:attribute name="title">
  37. <xsl:value-of select="@name"/>
  38. </xsl:attribute>
  39. <xsl:value-of select="@name"/>
  40. </a>
  41. </xsl:template>
  42. <xsl:template match="/t:cuberef">
  43. <html>
  44. <head>
  45. <meta http-equiv="Content-Type" content="application/xhtml+xml;charset=UTF-8" />
  46. <meta name="robots" content="NOODP" />
  47. <meta name="author" content="Rabid Viper Productions" />
  48. <meta name="copyright" content="You may be able to redistribute this content under specific conditions.
  49. Please read the licensing information, available @ https://assault.cubers.net/docs/license.html for the
  50. conditions that would apply to what you may be redistributing." />
  51. <title>AssaultCube Documentation :: CubeScript</title>
  52. <link rel="stylesheet" href="css/main.css" />
  53. <link rel="stylesheet" href="css/docs.css" />
  54. <link rel="stylesheet" href="css/referencexml.css" />
  55. <link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
  56. </head>
  57. <body>
  58. <div id="container">
  59. <div id="docsheader">
  60. AssaultCube Documentation
  61. </div>
  62. <div id="logo">
  63. <a href="index.html"><img src="images/aclogo.png"
  64. alt="AssaultCube" width="193px" height="81px" /></a>
  65. </div>
  66. <div id="menubar">
  67. &#160;
  68. </div>
  69. <div class="docsmain">
  70. <div id="gohome">
  71. <a href="index.html">Go to documentation index &#8629;</a>
  72. </div>
  73. <div id="topbutton">
  74. <a href="#">&#8593; Top of the page?</a>
  75. </div>
  76. <h2>
  77. CubeScript
  78. </h2>
  79. <p>
  80. CubeScript is the scripting language of AssaultCube and it is similar to scripting languages of other games, except
  81. that its a bit more powerful because it is almost a full programming language.
  82. </p>
  83. <p>
  84. CubeScript consists of the command itself, followed by any number of arguments separated by whitespace. You can:
  85. </p>
  86. <!-- Try to keep these examples very, very simple... -->
  87. <ul style="list-style-type : square;">
  88. <li>
  89. Use <span class="code">""</span> to quote strings that have whitespace within them.
  90. <ul><li>Input example: <span class="code">alias grass "is greener"</span></li></ul>
  91. </li>
  92. <li>
  93. Use <span class="code">$</span> to capture the value of a variable/alias/bracketed-string as an argument for a command.
  94. <ul>
  95. <li>Input example: <span class="code">echo "The grass" $grass</span></li>
  96. <li>Output: <span class="code">The grass is greener</span></li>
  97. <li>Input example: <span class="code">echo "Your FOV is" $fov</span></li>
  98. <li>Output: <span class="code">Your FOV is 90.0</span></li>
  99. </ul>
  100. </li>
  101. <li>
  102. Use <span class="code">;</span> to sequence multiple commands into one.
  103. <ul>
  104. <li>Input example: <span class="code">alias grass "is yellow"; echo "The grass" $grass</span></li>
  105. <li>Output: <span class="code">The grass is yellow</span></li>
  106. </ul>
  107. </li>
  108. <li>
  109. You can also use <span class="code">()</span> or <span class="code">[]</span> to quote strings (i.e. instead of "").
  110. These can be nested infinitely and may contain linefeeds.
  111. The normal brackets <span class="code">()</span> are special, as they evaluate commands contained within them,
  112. before evaluating the surrounding command.
  113. <ul>
  114. <li>Input example: <span class="code">alias 4x2 (* 2 (+ 1 3))</span></li>
  115. <li>Input command: <span class="code">echo $4x2</span></li>
  116. <li>Output: <span class="code">8</span></li>
  117. <li>Input example: <span class="code">alias grass [ is greener ]</span></li>
  118. </ul>
  119. </li>
  120. <li>
  121. Lastly, you can use the automatically-set aliases of <span class="code">$arg1</span>
  122. (.. and <span class="code">$arg2</span>, <span class="code">$arg3</span>, etc) in your scripts.
  123. <ul>
  124. <li>Input example: <span class="code">alias grass [ if (= $arg1 1) [ echo "The grass is green" ] [ if (= $arg1 2) [ echo "The grass is yellow" ] ] ]</span></li>
  125. <li>Input command: <span class="code">grass 1</span></li>
  126. <li>Output: <span class="code">The grass is green</span></li>
  127. <li>Input command: <span class="code">grass 2</span></li>
  128. <li>Output: <span class="code">The grass is brown</span></li>
  129. </ul>
  130. </li>
  131. </ul>
  132. <p>
  133. It is recommended to read examples of this in your ./config/ folder to understand them better. The documentation below
  134. contains a reference of ALL of the CubeScript commands at your disposal. Have fun!
  135. </p>
  136. <div id="content">
  137. <!-- contents -->
  138. <div id="contents">
  139. <p>
  140. <xsl:value-of select="t:description"/>
  141. </p>
  142. <div class="dottedline"></div>
  143. <h3>CATEGORIES:</h3>
  144. <ul id="categorylist">
  145. <xsl:for-each select="t:sections/t:section">
  146. <xsl:sort select="@sortindex[not(../../@sort) or ../../@sort = 'true' or ../../@sort = '1']" />
  147. <li>
  148. <a>
  149. <xsl:attribute name="href">
  150. <xsl:text>#section_</xsl:text>
  151. <xsl:value-of select="translate(@name, ' ', '_')" />
  152. </xsl:attribute>
  153. <xsl:value-of select="@name"/>
  154. </a>
  155. </li>
  156. </xsl:for-each>
  157. </ul>
  158. </div>
  159. <!-- sections -->
  160. <xsl:for-each select="t:sections/t:section">
  161. <xsl:sort select="@sortindex[not(../../@sort) or ../../@sort = 'true' or ../../@sort = '1']"/>
  162. <div class="dottedline"></div>
  163. <div class="section">
  164. <h3>
  165. <!-- section anchor -->
  166. <xsl:attribute name="id">
  167. <xsl:text>section_</xsl:text>
  168. <xsl:value-of select="translate(@name, ' ', '_')"/>
  169. </xsl:attribute>
  170. <xsl:value-of select="@name"/>
  171. </h3>
  172. <!-- description -->
  173. <p>
  174. <xsl:value-of select="t:description"/>
  175. </p>
  176. <!-- identifiers -->
  177. <xsl:for-each select="t:identifiers/*">
  178. <xsl:sort select="@name[not(../../@sort) or ../../@sort = 'true' or ../../@sort = '1']"/>
  179. <xsl:variable name="readOnly" select="t:value/@readOnly and (t:value/@readOnly = 'true' or t:value/@readOnly = '1')"/>
  180. <div class="identifier">
  181. <!-- identifier anchor -->
  182. <xsl:attribute name="id">
  183. <xsl:text>identifier_</xsl:text>
  184. <xsl:value-of select="translate(@name, ' ', '_')"/>
  185. </xsl:attribute>
  186. <!-- display name -->
  187. <div class="displayname">
  188. <xsl:call-template name="identifierLink"/>
  189. <xsl:text> </xsl:text>
  190. <xsl:choose>
  191. <xsl:when test="t:arguments"><!-- command args -->
  192. <xsl:for-each select="t:arguments/*">
  193. <xsl:value-of select="@token"/>
  194. <xsl:text> </xsl:text>
  195. </xsl:for-each>
  196. </xsl:when>
  197. <xsl:when test="t:value and not($readOnly)"><!-- variable value -->
  198. <xsl:text> </xsl:text>
  199. <xsl:value-of select="t:value/@token"/>
  200. </xsl:when>
  201. </xsl:choose>
  202. </div>
  203. <!-- description -->
  204. <div class="description">
  205. <xsl:value-of select="t:description"/>
  206. </div>
  207. <!-- arguments or value description -->
  208. <xsl:choose>
  209. <xsl:when test="t:arguments/*"><!-- command args -->
  210. <div class="argumentDescriptions">
  211. <table>
  212. <tr>
  213. <th>Argument</th>
  214. <th>Description</th>
  215. <th>Values</th>
  216. </tr>
  217. <xsl:for-each select="t:arguments/*">
  218. <tr>
  219. <td class="token">
  220. <xsl:value-of select="@token"/>
  221. </td>
  222. <td class="description">
  223. <xsl:value-of select="@description"/>
  224. <xsl:if test="@optional">
  225. <xsl:text> (optional)</xsl:text>
  226. </xsl:if>
  227. </td>
  228. <td class="values">
  229. <xsl:value-of select="@valueNotes"/>
  230. </td>
  231. </tr>
  232. </xsl:for-each>
  233. </table>
  234. </div>
  235. </xsl:when>
  236. <xsl:when test="t:value"> <!-- var value -->
  237. <div class="valueDescription">
  238. <table>
  239. <tr>
  240. <xsl:if test="not($readOnly)">
  241. <th>
  242. Token
  243. </th>
  244. </xsl:if>
  245. <th>
  246. Description
  247. </th>
  248. <th>Values</th>
  249. <th>Range</th>
  250. <th>Default</th>
  251. </tr>
  252. <tr>
  253. <xsl:if test="not($readOnly)">
  254. <td class="token">
  255. <xsl:value-of select="t:value/@token"/>
  256. </td>
  257. </xsl:if>
  258. <td class="description">
  259. <xsl:value-of select="t:value/@description"/>
  260. </td>
  261. <td class="values">
  262. <xsl:value-of select="t:value/@valueNotes"/>
  263. </td>
  264. <td class="range">
  265. <xsl:value-of select="t:value/@minValue"/>
  266. <xsl:text>..</xsl:text>
  267. <xsl:value-of select="t:value/@maxValue"/>
  268. </td>
  269. <td class="defaultValue">
  270. <xsl:value-of select="t:value/@defaultValue"/>
  271. </td>
  272. </tr>
  273. </table>
  274. </div>
  275. </xsl:when>
  276. </xsl:choose>
  277. <!-- remarks -->
  278. <xsl:if test="t:remarks">
  279. <div class="remarks">
  280. <xsl:for-each select="t:remarks/t:remark">
  281. <div class="remark">
  282. <xsl:value-of select="."/>
  283. </div>
  284. </xsl:for-each>
  285. </div>
  286. </xsl:if>
  287. <!-- examples -->
  288. <xsl:if test="t:examples">
  289. <div class="examples">
  290. <xsl:for-each select="t:examples/t:example">
  291. <p>
  292. Example:
  293. <span class="code">
  294. <xsl:value-of select="t:code"/>
  295. </span>
  296. <xsl:if test="t:explanation">
  297. <xsl:for-each select="t:explanation">
  298. <span class="exampleExplanation">
  299. <xsl:value-of select="."/>
  300. </span>
  301. </xsl:for-each>
  302. </xsl:if>
  303. </p>
  304. </xsl:for-each>
  305. </div>
  306. </xsl:if>
  307. <!-- return value -->
  308. <xsl:if test="t:return">
  309. <p>
  310. Return value: <xsl:value-of select="t:return/@description"/> <xsl:if test="t:return/@valueNotes">, <xsl:value-of select="t:return/@valueNotes"/></xsl:if>
  311. </p>
  312. </xsl:if>
  313. <!-- default keys -->
  314. <xsl:if test="t:defaultKeys/*">
  315. <div class="defaultKeys">
  316. <br/>
  317. <xsl:choose>
  318. <xsl:when test="count(t:defaultKeys/*) = 1">
  319. <xsl:text>default key: </xsl:text>
  320. <xsl:apply-templates select="t:defaultKeys/*"/>
  321. </xsl:when>
  322. <xsl:otherwise>
  323. <xsl:text>default keys:</xsl:text>
  324. <br/>
  325. <xsl:for-each select="t:defaultKeys/*">
  326. <xsl:apply-templates select="."/>
  327. <br/>
  328. </xsl:for-each>
  329. </xsl:otherwise>
  330. </xsl:choose>
  331. </div>
  332. </xsl:if>
  333. <!-- references -->
  334. <xsl:if test="t:references">
  335. <div class="references">
  336. See also:
  337. <!-- refer to identifiers (identifier anchor) -->
  338. <xsl:for-each select="t:references/t:identifierReference">
  339. <a>
  340. <xsl:attribute name="href">
  341. <xsl:text>#identifier_</xsl:text>
  342. <xsl:value-of select="translate(@identifier, ' ', '_')"/>
  343. </xsl:attribute>
  344. <xsl:attribute name="class">internal</xsl:attribute>
  345. <xsl:choose>
  346. <xsl:when test="@name">
  347. <xsl:value-of select="@name"/>
  348. </xsl:when>
  349. <xsl:otherwise>
  350. <xsl:value-of select="@identifier"/>
  351. </xsl:otherwise>
  352. </xsl:choose>
  353. </a>
  354. <xsl:if test="position() != last()">
  355. <xsl:text>, </xsl:text>
  356. </xsl:if>
  357. </xsl:for-each>
  358. <!-- refer to web resources -->
  359. <xsl:for-each select="t:references/t:webReference">
  360. <xsl:text>, </xsl:text><!-- we assume it's never the only entry! -->
  361. <a>
  362. <xsl:attribute name="href">
  363. <xsl:value-of select="@url"/>
  364. </xsl:attribute>
  365. <xsl:attribute name="class">external</xsl:attribute>
  366. <xsl:attribute name="target">_blank</xsl:attribute>
  367. <xsl:value-of select="@name"/>
  368. </a>
  369. </xsl:for-each>
  370. <!-- refer to wiki resources -->
  371. <xsl:for-each select="t:references/t:wikiReference">
  372. <xsl:text>, </xsl:text><!-- we assume it's never the only entry! -->
  373. <a>
  374. <xsl:attribute name="href">https://wiki.cubers.net/action/view/<xsl:value-of select="@article"/></xsl:attribute>
  375. <xsl:attribute name="class">external</xsl:attribute>
  376. <xsl:attribute name="target">_blank</xsl:attribute>
  377. <xsl:value-of select="@article"/>
  378. </a>
  379. </xsl:for-each>
  380. </div>
  381. </xsl:if>
  382. </div>
  383. </xsl:for-each>
  384. </div>
  385. </xsl:for-each>
  386. </div>
  387. </div>
  388. <!-- XML: CONTENTS PANEL -->
  389. <div class="commandlist">
  390. CubeScript command &amp; variable list
  391. </div>
  392. <div id="contentspanel">
  393. <xsl:if test="t:sections">
  394. <xsl:for-each select="t:sections/t:section">
  395. <xsl:sort select="@sortindex[not(../../@sort) or ../../@sort = 'true' or ../../@sort = '1']"/>
  396. <div class="sectiontitle">
  397. <a>
  398. <xsl:attribute name="href">
  399. <xsl:text>#section_</xsl:text>
  400. <xsl:value-of select="translate(@name, ' ', '_')"/>
  401. </xsl:attribute>
  402. <xsl:value-of select="@name"/>
  403. </a>
  404. </div>
  405. <div class="identifiers">
  406. <xsl:if test="t:identifiers">
  407. <ul>
  408. <xsl:for-each select="t:identifiers/*">
  409. <xsl:sort select="@name[not(../../@sort) or ../../@sort = 'true' or ../../@sort = '1']"/>
  410. <li>
  411. <xsl:call-template name="identifierLink"/>
  412. </li>
  413. </xsl:for-each>
  414. </ul>
  415. </xsl:if>
  416. </div>
  417. </xsl:for-each>
  418. </xsl:if>
  419. </div>
  420. </div>
  421. </body>
  422. </html>
  423. </xsl:template>
  424. </xsl:transform>