From 96e7ee91cced216e287b9dadb6eec97147347989 Mon Sep 17 00:00:00 2001 From: Araq Date: Tue, 21 Feb 2012 21:03:36 +0100 Subject: [PATCH] added docgen.rst2html for the forum; fixed tester bug concerning removeDir --- compiler/docgen.nim | 54 +++++++++++++++++++++++++++++++++++++++++++ config/nimdoc.cfg | 2 +- config/nimdoc.tex.cfg | 2 +- tests/specials.nim | 8 ++++++- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/compiler/docgen.nim b/compiler/docgen.nim index 65cd8fdd40..14a8b35c28 100755 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -881,3 +881,57 @@ proc CommandRst2TeX = splitter = "\\-" CommandRstAux(gProjectFull, TexExt) +# ---------- forum --------------------------------------------------------- + +proc setupConfig*() = + setConfigVar("split.item.toc", "20") + setConfigVar("doc.section", """ +
+

$sectionTitle

+
+$content +
+""") + setConfigVar("doc.section.toc", """ +
  • + $sectionTitle + +
  • +""") + setConfigVar("doc.item", """ +
    $header
    +
    +$desc +
    +""") + setConfigVar("doc.item.toc", """ +
  • $name
  • +""") + setConfigVar("doc.toc", """ +""") + setConfigVar("doc.body_toc", """ +$tableofcontents +
    +$moduledesc +$content +
    +""") + setConfigVar("doc.body_no_toc", "$moduledesc $content") + setConfigVar("doc.file", "$content") + +proc rstToHtml*(s: string): string = + ## exported for *nimforum*. + const filen = "input" + var d = newDocumentor(filen) + var dummyHasToc = false + var rst = rstParse(s, false, filen, 0, 1, dummyHasToc) + d.modDesc = renderRstToOut(d, rst) + let res = genOutFile(d) + result = res.ropeToStr + diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index d9a5b1ae2c..d47dccb635 100755 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -1,5 +1,5 @@ # This is the config file for the documentation generator. -# (c) 2011 Andreas Rumpf +# (c) 2012 Andreas Rumpf # Feel free to edit the templates as you need. split.item.toc = "20" diff --git a/config/nimdoc.tex.cfg b/config/nimdoc.tex.cfg index ecb95fe01f..8b59f2ee95 100755 --- a/config/nimdoc.tex.cfg +++ b/config/nimdoc.tex.cfg @@ -1,6 +1,6 @@ # This is the config file for the documentation generator that produces TeX # output. -# (c) 2011 Andreas Rumpf +# (c) 2012 Andreas Rumpf # Feel free to edit the templates as you need. split.item.toc = "20" diff --git a/tests/specials.nim b/tests/specials.nim index d10452b98b..05eda60614 100644 --- a/tests/specials.nim +++ b/tests/specials.nim @@ -15,7 +15,13 @@ const rodfilesDir = "tests/rodfiles" -proc delNimCache() = removeDir(rodfilesDir / "nimcache") +proc delNimCache() = + let dir = rodfilesDir / "nimcache" + try: + removeDir(dir) + except EOS: + echo "[Warning] could not delete: ", dir + proc plusCache(options: string): string = return options & " --symbolFiles:on" proc runRodFiles(r: var TResults, options: string) =