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
parent e98bd3aceb
commit 9031c8fb0f

View File

@@ -149,14 +149,16 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef,
if filename.len == 0:
inc(d.id)
let nameOnly = splitFile(d.filename).name
let subdir = getNimcacheDir(conf) / RelativeDir(nameOnly)
createDir(subdir)
outp = subdir / RelativeFile(nameOnly & "_snippet_" & $d.id & ".nim")
outp = getNimcacheDir(conf) / RelativeDir(nameOnly) /
RelativeFile(nameOnly & "_snippet_" & $d.id & ".nim")
elif isAbsolute(filename):
outp = AbsoluteFile filename
outp = AbsoluteFile(filename)
else:
# 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
let importStmt = if d.isPureRst: "" else: "import \"$1\"\n" % [d.filename]
writeFile(outp, importStmt & content)