summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKaushal Modi <kaushal.modi@gmail.com>2020-05-11 14:45:35 -0400
committerGitHub <noreply@github.com>2020-05-11 20:45:35 +0200
commit86669ef5b4c9711d81e961c2f68a05aa4f4d9ece (patch)
tree0b344f83bf7f19060276832e28a44c0010024a02
parent76f7e958141eabc6dc317189fa12c123584e1b6e (diff)
downloadNim-86669ef5b4c9711d81e961c2f68a05aa4f4d9ece.tar.gz
Make --backend:cpp|js work for :test: code-blocks as well (#14306)
Continues https://github.com/nim-lang/Nim/commit/9502e39b634eea8e04f07ddc110b466387f42322

Ref:
- https://github.com/nim-lang/Nim/commit/9502e39b634eea8e04f07ddc110b466387f42322#commitcomment-39087584
- https://github.com/nim-lang/Nim/pull/14278

Fixes https://github.com/nim-lang/Nim/issues/13129 .
-rw-r--r--compiler/docgen.nim3
-rw-r--r--lib/packages/docutils/rstgen.nim2
2 files changed, 3 insertions, 2 deletions
diff --git a/compiler/docgen.nim b/compiler/docgen.nim
index c01d5633f..d774fd508 100644
--- a/compiler/docgen.nim
+++ b/compiler/docgen.nim
@@ -216,7 +216,8 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
       # Include the current file if we're parsing a nim file
       let importStmt = if d.isPureRst: "" else: "import \"$1\"\n" % [d.filename.replace("\\", "/")]
       writeFile(outp, importStmt & content)
-      let c = if cmd.startsWith("nim "): os.getAppFilename() & cmd.substr(3)
+      let c = if cmd.startsWith("nim <backend> "): os.getAppFilename() & " " & $conf.backend & cmd.substr("nim <backend>".len)
+              elif cmd.startsWith("nim "): os.getAppFilename() & cmd.substr("nim".len)
               else: cmd
       let c2 = c % quoteShell(outp)
       rawMessage(conf, hintExecuting, c2)
diff --git a/lib/packages/docutils/rstgen.nim b/lib/packages/docutils/rstgen.nim
index 13dff68e9..edd987a76 100644
--- a/lib/packages/docutils/rstgen.nim
+++ b/lib/packages/docutils/rstgen.nim
@@ -865,7 +865,7 @@ proc parseCodeBlockField(d: PDoc, n: PRstNode, params: var CodeBlockParams) =
   of "test":
     params.testCmd = n.getFieldValue.strip
     if params.testCmd.len == 0:
-      params.testCmd = "nim c -r $1"
+      params.testCmd = "nim <backend> -r $1" # The nim backend is auto-set in docgen.nim
     else:
       params.testCmd = unescape(params.testCmd)
   of "status", "exitcode":