Make sure the test snippet directory exists

This commit is contained in:
LemonBoy 2019-01-29 11:51:04 +01:00 • committed by Andreas Rumpf
commit 9031c8fb0f

View file

@ -149,14 +149,16 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
if filename.len == 0: if filename.len == 0:
inc(d.id) inc(d.id)
let nameOnly = splitFile(d.filename).name let nameOnly = splitFile(d.filename).name
let subdir = getNimcacheDir(conf) / RelativeDir(nameOnly) outp = getNimcacheDir(conf) / RelativeDir(nameOnly) /
createDir(subdir) RelativeFile(nameOnly & "_snippet_" & $d.id & ".nim")
outp = subdir / RelativeFile(nameOnly & "_snippet_" & $d.id & ".nim")
elif isAbsolute(filename): elif isAbsolute(filename):
outp = AbsoluteFile filename outp = AbsoluteFile(filename)
else: else:
# Nim's convention: every path is relative to the file it was written in: # Nim's convention: every path is relative to the file it was written in:
outp = splitFile(d.filename).dir.AbsoluteDir / RelativeFile(filename) let nameOnly = splitFile(d.filename).name
outp = AbsoluteDir(nameOnly) / RelativeFile(filename)
# Make sure the destination directory exists
createDir(outp.splitFile.dir)
# Include the current file if we're parsing a nim file # Include the current file if we're parsing a nim file
let importStmt = if d.isPureRst: "" else: "import \"$1\"\n" % [d.filename] let importStmt = if d.isPureRst: "" else: "import \"$1\"\n" % [d.filename]
writeFile(outp, importStmt & content) writeFile(outp, importStmt & content)