Skip to content

Commit c453916

Browse files
committed
nim doc now shows correct import name in title (with --docroot)
1 parent 897cb4b commit c453916

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

compiler/options.nim

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,24 @@ when (NimMajor, NimMinor) < (1, 1) or not declared(isRelativeTo):
761761
let ret = relativePath(path, base)
762762
result = path.len > 0 and not ret.startsWith ".."
763763

764+
const stdlibDirs = [
765+
"pure", "core", "arch",
766+
"pure/collections",
767+
"pure/concurrency",
768+
"pure/unidecode", "impure",
769+
"wrappers", "wrappers/linenoise",
770+
"windows", "posix", "js"]
771+
772+
const
773+
pkgPrefix = "pkg/"
774+
stdPrefix = "std/"
775+
764776
proc getRelativePathFromConfigPath*(conf: ConfigRef; f: AbsoluteFile): RelativeFile =
765777
let f = $f
778+
for dir in stdlibDirs:
779+
let path = conf.libpath.string / dir / f.lastPathPart
780+
if path.cmpPaths(f.string) == 0:
781+
return RelativeFile(stdPrefix & f.splitFile.name)
766782
template search(paths) =
767783
for it in paths:
768784
let it = $it
@@ -784,18 +800,8 @@ proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): AbsoluteFile
784800
result = rawFindFile2(conf, RelativeFile f.toLowerAscii)
785801
patchModule(conf)
786802

787-
const stdlibDirs = [
788-
"pure", "core", "arch",
789-
"pure/collections",
790-
"pure/concurrency",
791-
"pure/unidecode", "impure",
792-
"wrappers", "wrappers/linenoise",
793-
"windows", "posix", "js"]
794-
795803
proc findModule*(conf: ConfigRef; modulename, currentModule: string): AbsoluteFile =
796804
# returns path to module
797-
const pkgPrefix = "pkg/"
798-
const stdPrefix = "std/"
799805
var m = addFileExt(modulename, NimExt)
800806
if m.startsWith(pkgPrefix):
801807
result = findFile(conf, m.substr(pkgPrefix.len), suppressStdlib = true)

tools/kochdocs.nim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,19 @@ proc buildDoc(nimArgs, destPath: string) =
257257
destPath / changeFileExt(splitFile(d).name, "html"), d]
258258
i.inc
259259
for d in items(doc0):
260-
commands[i] = nim & " doc0 $# --git.url:$# -o:$# --index:on $#" %
260+
commands[i] = nim & " doc0 $# --git.url:$# -o:$# --index:on --docroot $#" %
261261
[nimArgs, gitUrl,
262262
destPath / changeFileExt(splitFile(d).name, "html"), d]
263263
i.inc
264264
for d in items(doc):
265265
let extra = if isJsOnly(d): "--backend:js" else: ""
266266
var nimArgs2 = nimArgs
267267
if d.isRelativeTo("compiler"): doAssert false
268-
commands[i] = nim & " doc $# $# --git.url:$# --outdir:$# --index:on $#" %
268+
commands[i] = nim & " doc $# $# --git.url:$# --outdir:$# --index:on --docroot $#" %
269269
[extra, nimArgs2, gitUrl, destPath, d]
270270
i.inc
271271
for d in items(withoutIndex):
272-
commands[i] = nim & " doc $# --git.url:$# -o:$# $#" %
272+
commands[i] = nim & " doc $# --git.url:$# -o:$# --docroot $#" %
273273
[nimArgs, gitUrl,
274274
destPath / changeFileExt(splitFile(d).name, "html"), d]
275275
i.inc

0 commit comments

Comments
 (0)