From 60597adb1019174fe190ff84e46284a72a8b1ae2 Mon Sep 17 00:00:00 2001 From: Jake Leahy Date: Thu, 9 Nov 2023 17:33:57 +1100 Subject: [PATCH] Fix using `--stdout` with `jsondoc` (#22925) Fixes the assertion defect that happens when using `jsondoc --stdout` (There is no outfile since its just stdout) ``` Error: unhandled exception: options.nim(732, 3) `not conf.outFile.isEmpty` [AssertionDefect] ``` Also makes the output easier to parse by ending each module output with a new line. --- compiler/docgen.nim | 2 +- compiler/msgs.nim | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/docgen.nim b/compiler/docgen.nim index ea7cfad8cf..29eeced9be 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -1806,7 +1806,7 @@ proc writeOutputJson*(d: PDoc, useWarning = false) = "moduleDescription": modDesc, "entries": d.jEntriesFinal} if optStdout in d.conf.globalOptions: - write(stdout, $content) + writeLine(stdout, $content) else: let dir = d.destFile.splitFile.dir createDir(dir) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index f69e7733e0..5c30acff3c 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -725,6 +725,8 @@ proc genSuccessX*(conf: ConfigRef) = elif conf.outFile.isEmpty and conf.cmd notin {cmdJsonscript} + cmdDocLike + cmdBackends: # for some cmd we expect a valid absOutFile output = "unknownOutput" + elif optStdout in conf.globalOptions: + output = "stdout" else: output = $conf.absOutFile if conf.filenameOption != foAbs: output = output.AbsoluteFile.extractFilename