summary refs log tree commit diff stats
path: root/compiler/pathutils.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-02-06 02:17:00 -0800
committerGitHub <noreply@github.com>2020-02-06 11:17:00 +0100
commit7ec7731f824b933cdd4f4a1f816c1f3e4862bef6 (patch)
treeb1aee83d00485f447539390e5eb807df5704b7b8 /compiler/pathutils.nim
parent574f61315d015033dbf20e4840a645057b0c2060 (diff)
downloadNim-7ec7731f824b933cdd4f4a1f816c1f3e4862bef6.tar.gz
fix #13150 `nim doc --project` now works reliably (#13223)
* fix #13150 `nim doc --project` works with duplicate names and with imports below main project file

* add to help; fixup after #13212 isRelativeTo got merged
* fix test tests/compilerapi/tcompilerapi.nim
* remove nimblePkg field; compute on the fly instead
* kochdocs: compiler docs now under compiler/
* --docRoot now has smart default: best among @pkg, @path
Diffstat (limited to 'compiler/pathutils.nim')
-rw-r--r--compiler/pathutils.nim7
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/pathutils.nim b/compiler/pathutils.nim
index e3dd69628..1c35eb0b2 100644
--- a/compiler/pathutils.nim
+++ b/compiler/pathutils.nim
@@ -67,7 +67,7 @@ when true:
 
   proc `/`*(base: AbsoluteDir; f: RelativeFile): AbsoluteFile =
     let base = postProcessBase(base)
-    assert(not isAbsolute(f.string))
+    assert(not isAbsolute(f.string), f.string)
     result = AbsoluteFile newStringOfCap(base.string.len + f.string.len)
     var state = 0
     addNormalizePath(base.string, result.string, state)
@@ -83,7 +83,10 @@ when true:
 
   proc relativeTo*(fullPath: AbsoluteFile, baseFilename: AbsoluteDir;
                    sep = DirSep): RelativeFile =
-    RelativeFile(relativePath(fullPath.string, baseFilename.string, sep))
+    # this currently fails for `tests/compilerapi/tcompilerapi.nim`
+    # it's needed otherwise would returns an absolute path
+    # assert not baseFilename.isEmpty, $fullPath
+    result = RelativeFile(relativePath(fullPath.string, baseFilename.string, sep))
 
   proc toAbsolute*(file: string; base: AbsoluteDir): AbsoluteFile =
     if isAbsolute(file): result = AbsoluteFile(file)