nimdoc.cfg 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. # This is the config file for the documentation generator.
  2. # (c) 2016 Andreas Rumpf
  3. # Feel free to edit the templates as you need. If you modify this file, it
  4. # might be worth updating the hardcoded values in packages/docutils/rstgen.nim
  5. split.item.toc = "20"
  6. # too long entries in the table of contents wrap around
  7. # after this number of characters
  8. doc.section = """
  9. <div class="section" id="$sectionID">
  10. <h1><a class="toc-backref" href="#$sectionID">$sectionTitle</a></h1>
  11. <dl class="item">
  12. $content
  13. </dl></div>
  14. """
  15. doc.section.toc = """
  16. <li>
  17. <a class="reference reference-toplevel" href="#$sectionID" id="$sectionTitleID">$sectionTitle</a>
  18. <ul class="simple simple-toc-section">
  19. $content
  20. </ul>
  21. </li>
  22. """
  23. doc.section.toc2 = """
  24. <ul class="simple nested-toc-section">$plainName
  25. $content
  26. </ul>
  27. """
  28. # Chunk of HTML emitted for each entry in the HTML table of contents.
  29. # Available variables are:
  30. # * $desc: the actual docstring of the item.
  31. # * $header: the full version of name, including types, pragmas, tags, etc.
  32. # * $header_plain: like header but without HTML, for attribute embedding.
  33. # * $itemID: numerical unique entry of the item in the HTML.
  34. # * $itemSym: short symbolic name of the item for easier hyperlinking.
  35. # * $itemSymEnc: quoted version for URLs or attributes.
  36. # * $itemSymOrID: the symbolic name or the ID if that is not unique.
  37. # * $itemSymOrIDEnc: quoted version for URLs or attributes.
  38. # * $name: reduced name of the item.
  39. # * $seeSrc: generated HTML from doc.item.seesrc (if some switches are used).
  40. doc.item = """
  41. <a id="$itemSymOrID"></a>
  42. <dt><pre>$header</pre></dt>
  43. <dd>
  44. $deprecationMsg
  45. $desc
  46. $seeSrc
  47. </dd>
  48. """
  49. # Chunk of HTML emitted for each entry in the HTML table of contents.
  50. # See doc.item for available substitution variables.
  51. doc.item.toc = """
  52. <li><a class="reference" href="#$itemSymOrIDEnc"
  53. title="$header_plain">$name</a></li>
  54. """
  55. # This is used for TOC items which are grouped by the same name (e.g. procs).
  56. doc.item.tocTable = """
  57. <li><a class="reference" href="#$itemSymOrIDEnc"
  58. title="$header_plain">$itemSymOrID</a></li>
  59. """
  60. # HTML rendered for doc.item's seeSrc variable. Note that this will render to
  61. # the empty string if you don't pass anything through --git.url. Available
  62. # substitutaion variables here are:
  63. # * $commit: branch/commit to use in source link.
  64. # * $devel: branch to use in edit link.
  65. # * $path: relative path to the file being processed.
  66. # * $line: line of the item in the original source file.
  67. # * $url: whatever you did pass through the --git.url switch (which also
  68. # gets variables path/line replaced!)
  69. doc.item.seesrc = """&nbsp;&nbsp;<a
  70. href="${url}/tree/${commit}/${path}#L${line}"
  71. class="link-seesrc" target="_blank">Source</a>
  72. &nbsp;&nbsp;<a href="${url}/edit/${devel}/${path}#L${line}" class="link-seesrc" target="_blank" >Edit</a>
  73. """
  74. doc.deprecationmsg = """
  75. <div class="deprecation-message">
  76. <b>$label</b> $message
  77. </div>
  78. """
  79. doc.toc = """
  80. <ul class="simple simple-toc" id="toc-list">
  81. $content
  82. </ul>
  83. """
  84. doc.body_toc_groupsection = """
  85. <div class="search-groupby">
  86. Group by:
  87. <select onchange="groupBy(this.value)">
  88. <option value="section">Section</option>
  89. <option value="type">Type</option>
  90. </select>
  91. </div>
  92. """
  93. @if boot:
  94. # This is enabled with the "boot" directive to generate
  95. # the compiler documentation.
  96. # As a user, tweak the block below instead.
  97. # You can add your own global-links entries
  98. doc.body_toc_group = """
  99. <div class="row">
  100. <div class="three columns">
  101. <div class="theme-switch-wrapper">
  102. <label class="theme-switch" for="checkbox">
  103. <input type="checkbox" id="checkbox" />
  104. <div class="slider round"></div>
  105. </label>
  106. &nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
  107. </div>
  108. <div id="global-links">
  109. <ul class="simple-boot">
  110. <li>
  111. <a href="manual.html">Manual</a>
  112. </li>
  113. <li>
  114. <a href="lib.html">Standard library</a>
  115. </li>
  116. <li>
  117. <a href="$theindexhref">Index</a>
  118. </li>
  119. <li>
  120. <a href="compiler/$theindexhref">Compiler docs</a>
  121. </li>
  122. <li>
  123. <a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a>
  124. </li>
  125. </ul>
  126. </div>
  127. <div id="searchInputDiv">
  128. Search: <input type="text" id="searchInput"
  129. onkeyup="search()" />
  130. </div>
  131. $body_toc_groupsection
  132. $tableofcontents
  133. </div>
  134. $seeSrc
  135. <div class="nine columns" id="content">
  136. <div id="tocRoot"></div>
  137. $deprecationMsg
  138. <p class="module-desc">$moduledesc</p>
  139. $content
  140. </div>
  141. </div>
  142. """
  143. @else
  144. # keep in sink with other `doc.body_toc_group` or better, refactor
  145. doc.body_toc_group = """
  146. <div class="row">
  147. <div class="three columns">
  148. <div class="theme-switch-wrapper">
  149. <label class="theme-switch" for="checkbox">
  150. <input type="checkbox" id="checkbox" />
  151. <div class="slider round"></div>
  152. </label>
  153. &nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
  154. </div>
  155. <div id="global-links">
  156. <ul class="simple">
  157. <li>
  158. <a href="$theindexhref">Index</a>
  159. </li>
  160. </ul>
  161. </div>
  162. <div id="searchInputDiv">
  163. Search: <input type="text" id="searchInput"
  164. onkeyup="search()" />
  165. </div>
  166. <div>
  167. Group by:
  168. <select onchange="groupBy(this.value)">
  169. <option value="section">Section</option>
  170. <option value="type">Type</option>
  171. </select>
  172. </div>
  173. $tableofcontents
  174. </div>
  175. $seeSrc
  176. <div class="nine columns" id="content">
  177. <div id="tocRoot"></div>
  178. $deprecationMsg
  179. <p class="module-desc">$moduledesc</p>
  180. $content
  181. </div>
  182. </div>
  183. """
  184. @end
  185. doc.body_toc %= "${doc.body_toc_group}" # should only be used for boot
  186. doc.body_no_toc = """
  187. $moduledesc
  188. $content
  189. """
  190. doc.listing_start = "<pre class=\"listing\">"
  191. doc.listing_end = "</pre>"
  192. # * $analytics: Google analytics location, includes <script> tags
  193. doc.file = """<?xml version="1.0" encoding="utf-8" ?>
  194. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  195. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  196. <!-- This file is generated by Nim. -->
  197. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  198. <head>
  199. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  200. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  201. <!-- Favicon -->
  202. <link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
  203. <link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
  204. <!-- Google fonts -->
  205. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  206. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  207. <!-- CSS -->
  208. <title>$title</title>
  209. <link rel="stylesheet" type="text/css" href="$nimdoccss">
  210. <script type="text/javascript" src="$dochackjs"></script>
  211. <script type="text/javascript">
  212. function main() {
  213. var pragmaDots = document.getElementsByClassName("pragmadots");
  214. for (var i = 0; i < pragmaDots.length; i++) {
  215. pragmaDots[i].onclick = function(event) {
  216. // Hide tease
  217. event.target.parentNode.style.display = "none";
  218. // Show actual
  219. event.target.parentNode.nextElementSibling.style.display = "inline";
  220. }
  221. }
  222. const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
  223. function switchTheme(e) {
  224. if (e.target.checked) {
  225. document.documentElement.setAttribute('data-theme', 'dark');
  226. localStorage.setItem('theme', 'dark');
  227. } else {
  228. document.documentElement.setAttribute('data-theme', 'light');
  229. localStorage.setItem('theme', 'light');
  230. }
  231. }
  232. toggleSwitch.addEventListener('change', switchTheme, false);
  233. const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
  234. if (currentTheme) {
  235. document.documentElement.setAttribute('data-theme', currentTheme);
  236. if (currentTheme === 'dark') {
  237. toggleSwitch.checked = true;
  238. }
  239. }
  240. }
  241. </script>
  242. </head>
  243. <body onload="main()">
  244. <div class="document" id="documentId">
  245. <div class="container">
  246. <h1 class="title">$title</h1>
  247. $content
  248. <div class="row">
  249. <div class="twelve-columns footer">
  250. <span class="nim-sprite"></span>
  251. <br/>
  252. <small style="color: var(--hint);">Made with Nim. Generated: $date $time UTC</small>
  253. </div>
  254. </div>
  255. </div>
  256. </div>
  257. $analytics
  258. </body>
  259. </html>
  260. """