nimdoc.cfg 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 (and without pragmas, tags, etc.),
  33. # for attribute embedding.
  34. # * $itemID: numerical unique entry of the item in the HTML.
  35. # * $itemSym: short symbolic name of the item for easier hyperlinking.
  36. # * $itemSymEnc: quoted version for URLs or attributes.
  37. # * $itemSymOrID: the symbolic name or the ID if that is not unique.
  38. # * $itemSymOrIDEnc: quoted version for URLs or attributes.
  39. # * $name: reduced name of the item.
  40. # * $uniqueName: name with parameters for routine types or $name for others.
  41. # * $seeSrc: generated HTML from doc.item.seesrc (if some switches are used).
  42. doc.item = """
  43. <div id="$itemSymOrID">
  44. <dt><pre>$header</pre></dt>
  45. <dd>
  46. $deprecationMsg
  47. $desc
  48. $seeSrc
  49. </dd>
  50. </div>
  51. """
  52. # Chunk of HTML emitted for each entry in the HTML table of contents.
  53. # See doc.item for available substitution variables.
  54. # This is used for TOC items which are not overloadable (e.g. types).
  55. # `$header_plain` would be too verbose here, so we use $name.
  56. doc.item.toc = """
  57. <li><a class="reference" href="#$itemSymOrIDEnc"
  58. title="$header_plain">$name</a></li>
  59. """
  60. # This is used for TOC items which are grouped by the same name (e.g. procs).
  61. doc.item.tocTable = """
  62. <li><a class="reference" href="#$itemSymOrIDEnc"
  63. title="$header_plain">$header_plain</a></li>
  64. """
  65. # HTML rendered for doc.item's seeSrc variable. Note that this will render to
  66. # the empty string if you don't pass anything through --git.url. Available
  67. # substitutaion variables here are:
  68. # * $commit: branch/commit to use in source link.
  69. # * $devel: branch to use in edit link.
  70. # * $path: relative path to the file being processed.
  71. # * $line: line of the item in the original source file.
  72. # * $url: whatever you did pass through the --git.url switch (which also
  73. # gets variables path/line replaced!)
  74. doc.item.seesrc = """&nbsp;&nbsp;<a
  75. href="${url}/tree/${commit}/${path}#L${line}"
  76. class="link-seesrc" target="_blank">Source</a>
  77. &nbsp;&nbsp;<a href="${url}/edit/${devel}/${path}#L${line}" class="link-seesrc" target="_blank" >Edit</a>
  78. """
  79. doc.deprecationmsg = """
  80. <div class="deprecation-message">
  81. <b>$label</b> $message
  82. </div>
  83. """
  84. doc.toc = """
  85. <ul class="simple simple-toc" id="toc-list">
  86. $content
  87. </ul>
  88. """
  89. doc.body_toc_groupsection = """
  90. <div class="search-groupby">
  91. Group by:
  92. <select onchange="groupBy(this.value)">
  93. <option value="section">Section</option>
  94. <option value="type">Type</option>
  95. </select>
  96. </div>
  97. """
  98. @if boot:
  99. # This is enabled with the "boot" directive to generate
  100. # the compiler documentation.
  101. # As a user, tweak the block below instead.
  102. # You can add your own global-links entries
  103. doc.body_toc_group = """
  104. <div class="row">
  105. <div class="three columns">
  106. <div class="theme-switch-wrapper">
  107. <label class="theme-switch" for="checkbox">
  108. <input type="checkbox" id="checkbox" />
  109. <div class="slider round"></div>
  110. </label>
  111. &nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
  112. </div>
  113. <div id="global-links">
  114. <ul class="simple-boot">
  115. <li><a href="manual.html">Manual</a></li>
  116. <li><a href="lib.html">Standard library</a></li>
  117. <li> <a href="$theindexhref">Index</a></li>
  118. <li><a href="compiler/$theindexhref">Compiler docs</a></li>
  119. <li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
  120. <li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
  121. </ul>
  122. </div>
  123. <div id="searchInputDiv">
  124. Search: <input type="text" id="searchInput"
  125. onkeyup="search()" />
  126. </div>
  127. $body_toc_groupsection
  128. $tableofcontents
  129. </div>
  130. $seeSrc
  131. <div class="nine columns" id="content">
  132. <div id="tocRoot"></div>
  133. $deprecationMsg
  134. <p class="module-desc">$moduledesc</p>
  135. $content
  136. </div>
  137. </div>
  138. """
  139. @else
  140. # keep in sink with other `doc.body_toc_group` or better, refactor
  141. doc.body_toc_group = """
  142. <div class="row">
  143. <div class="three columns">
  144. <div class="theme-switch-wrapper">
  145. <label class="theme-switch" for="checkbox">
  146. <input type="checkbox" id="checkbox" />
  147. <div class="slider round"></div>
  148. </label>
  149. &nbsp;&nbsp;&nbsp; <em>Dark Mode</em>
  150. </div>
  151. <div id="global-links">
  152. <ul class="simple">
  153. <li>
  154. <a href="$theindexhref">Index</a>
  155. </li>
  156. </ul>
  157. </div>
  158. <div id="searchInputDiv">
  159. Search: <input type="text" id="searchInput"
  160. onkeyup="search()" />
  161. </div>
  162. <div>
  163. Group by:
  164. <select onchange="groupBy(this.value)">
  165. <option value="section">Section</option>
  166. <option value="type">Type</option>
  167. </select>
  168. </div>
  169. $tableofcontents
  170. </div>
  171. $seeSrc
  172. <div class="nine columns" id="content">
  173. <div id="tocRoot"></div>
  174. $deprecationMsg
  175. <p class="module-desc">$moduledesc</p>
  176. $content
  177. </div>
  178. </div>
  179. """
  180. @end
  181. doc.body_toc %= "${doc.body_toc_group}" # should only be used for boot
  182. doc.body_no_toc = """
  183. $moduledesc
  184. $content
  185. """
  186. # $1 - number of listing in document, $2 - language (e.g. langNim), $3 - anchor
  187. doc.listing_start = "<pre$3 class=\"listing\">"
  188. doc.listing_end = "</pre>"
  189. # * $analytics: Google analytics location, includes <script> tags
  190. doc.file = """<?xml version="1.0" encoding="utf-8" ?>
  191. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  192. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  193. <!-- This file is generated by Nim. -->
  194. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  195. <head>
  196. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  197. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  198. <!-- Favicon -->
  199. <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=="/>
  200. <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=">
  201. <!-- Google fonts -->
  202. <link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
  203. <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
  204. <!-- CSS -->
  205. <title>$title</title>
  206. <link rel="stylesheet" type="text/css" href="$nimdoccss">
  207. <script type="text/javascript" src="$dochackjs"></script>
  208. <script type="text/javascript">
  209. function main() {
  210. var pragmaDots = document.getElementsByClassName("pragmadots");
  211. for (var i = 0; i < pragmaDots.length; i++) {
  212. pragmaDots[i].onclick = function(event) {
  213. // Hide tease
  214. event.target.parentNode.style.display = "none";
  215. // Show actual
  216. event.target.parentNode.nextElementSibling.style.display = "inline";
  217. }
  218. }
  219. function switchTheme(e) {
  220. if (e.target.checked) {
  221. document.documentElement.setAttribute('data-theme', 'dark');
  222. localStorage.setItem('theme', 'dark');
  223. } else {
  224. document.documentElement.setAttribute('data-theme', 'light');
  225. localStorage.setItem('theme', 'light');
  226. }
  227. }
  228. const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
  229. if (toggleSwitch !== null) {
  230. toggleSwitch.addEventListener('change', switchTheme, false);
  231. }
  232. var currentTheme = localStorage.getItem('theme');
  233. if (!currentTheme && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  234. currentTheme = 'dark';
  235. }
  236. if (currentTheme) {
  237. document.documentElement.setAttribute('data-theme', currentTheme);
  238. if (currentTheme === 'dark' && toggleSwitch !== null) {
  239. toggleSwitch.checked = true;
  240. }
  241. }
  242. }
  243. window.addEventListener('DOMContentLoaded', main);
  244. </script>
  245. </head>
  246. <body>
  247. <div class="document" id="documentId">
  248. <div class="container">
  249. <h1 class="title">$title</h1>$subtitle
  250. $content
  251. <div class="row">
  252. <div class="twelve-columns footer">
  253. <span class="nim-sprite"></span>
  254. <br/>
  255. <small style="color: var(--hint);">Made with Nim. Generated: $date $time UTC</small>
  256. </div>
  257. </div>
  258. </div>
  259. </div>
  260. $analytics
  261. </body>
  262. </html>
  263. """