Skip to content

Commit

Permalink
nim doc now shows correct import name in title (with --docroot)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Feb 10, 2021
1 parent 897cb4b commit c453916
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
26 changes: 16 additions & 10 deletions compiler/options.nim
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,24 @@ when (NimMajor, NimMinor) < (1, 1) or not declared(isRelativeTo):
let ret = relativePath(path, base)
result = path.len > 0 and not ret.startsWith ".."

const stdlibDirs = [
"pure", "core", "arch",
"pure/collections",
"pure/concurrency",
"pure/unidecode", "impure",
"wrappers", "wrappers/linenoise",
"windows", "posix", "js"]

const
pkgPrefix = "pkg/"
stdPrefix = "std/"

proc getRelativePathFromConfigPath*(conf: ConfigRef; f: AbsoluteFile): RelativeFile =
let f = $f
for dir in stdlibDirs:
let path = conf.libpath.string / dir / f.lastPathPart
if path.cmpPaths(f.string) == 0:
return RelativeFile(stdPrefix & f.splitFile.name)
template search(paths) =
for it in paths:
let it = $it
Expand All @@ -784,18 +800,8 @@ proc findFile*(conf: ConfigRef; f: string; suppressStdlib = false): AbsoluteFile
result = rawFindFile2(conf, RelativeFile f.toLowerAscii)
patchModule(conf)

const stdlibDirs = [
"pure", "core", "arch",
"pure/collections",
"pure/concurrency",
"pure/unidecode", "impure",
"wrappers", "wrappers/linenoise",
"windows", "posix", "js"]

proc findModule*(conf: ConfigRef; modulename, currentModule: string): AbsoluteFile =
# returns path to module
const pkgPrefix = "pkg/"
const stdPrefix = "std/"
var m = addFileExt(modulename, NimExt)
if m.startsWith(pkgPrefix):
result = findFile(conf, m.substr(pkgPrefix.len), suppressStdlib = true)
Expand Down
6 changes: 3 additions & 3 deletions tools/kochdocs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,19 @@ proc buildDoc(nimArgs, destPath: string) =
destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc
for d in items(doc0):
commands[i] = nim & " doc0 $# --git.url:$# -o:$# --index:on $#" %
commands[i] = nim & " doc0 $# --git.url:$# -o:$# --index:on --docroot $#" %
[nimArgs, gitUrl,
destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc
for d in items(doc):
let extra = if isJsOnly(d): "--backend:js" else: ""
var nimArgs2 = nimArgs
if d.isRelativeTo("compiler"): doAssert false
commands[i] = nim & " doc $# $# --git.url:$# --outdir:$# --index:on $#" %
commands[i] = nim & " doc $# $# --git.url:$# --outdir:$# --index:on --docroot $#" %
[extra, nimArgs2, gitUrl, destPath, d]
i.inc
for d in items(withoutIndex):
commands[i] = nim & " doc $# --git.url:$# -o:$# $#" %
commands[i] = nim & " doc $# --git.url:$# -o:$# --docroot $#" %
[nimArgs, gitUrl,
destPath / changeFileExt(splitFile(d).name, "html"), d]
i.inc
Expand Down

0 comments on commit c453916

Please sign in to comment.