mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-17 18:17:11 +00:00
nim doc: fixes cross-link generation when --out is used
This commit is contained in:
@@ -94,13 +94,18 @@ proc parseRst(text, filename: string,
|
||||
docgenFindFile, compilerMsgHandler)
|
||||
|
||||
proc getOutFile2(conf: ConfigRef; filename: RelativeFile,
|
||||
ext: string, dir: RelativeDir): AbsoluteFile =
|
||||
ext: string, dir: RelativeDir; guessTarget: bool): AbsoluteFile =
|
||||
if optWholeProject in conf.globalOptions:
|
||||
# This is correct, for 'nim doc --project' we interpret the '--out' option as an
|
||||
# absolute directory, not as a filename!
|
||||
let d = if conf.outFile.isEmpty: conf.projectPath / dir else: AbsoluteDir(conf.outFile)
|
||||
createDir(d)
|
||||
result = d / changeFileExt(filename, ext)
|
||||
elif guessTarget:
|
||||
let d = if not conf.outFile.isEmpty: splitFile(conf.outFile).dir
|
||||
else: conf.projectPath
|
||||
createDir(d)
|
||||
result = d / changeFileExt(filename, ext)
|
||||
else:
|
||||
result = getOutFile(conf, filename, ext)
|
||||
|
||||
@@ -138,7 +143,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef):
|
||||
warnUser, "only 'rst2html' supports the ':test:' attribute")
|
||||
result.emitted = initIntSet()
|
||||
result.destFile = getOutFile2(conf, relativeTo(filename, conf.projectPath),
|
||||
HtmlExt, RelativeDir"htmldocs")
|
||||
HtmlExt, RelativeDir"htmldocs", false)
|
||||
result.thisDir = result.destFile.splitFile.dir
|
||||
|
||||
proc dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
||||
@@ -288,7 +293,7 @@ proc nodeToHighlightedHtml(d: PDoc; n: PNode; result: var Rope; renderFlags: TRe
|
||||
|
||||
let full = AbsoluteFile toFullPath(d.conf, FileIndex s.owner.position)
|
||||
let tmp = getOutFile2(d.conf, full.relativeTo(d.conf.projectPath),
|
||||
HtmlExt, RelativeDir"htmldocs")
|
||||
HtmlExt, RelativeDir"htmldocs", sfMainModule notin s.owner.flags)
|
||||
|
||||
let external = tmp.relativeTo(d.thisDir, '/')
|
||||
result.addf "<a href=\"$1#$2\"><span class=\"Identifier\">$3</span></a>",
|
||||
@@ -673,7 +678,7 @@ proc traceDeps(d: PDoc, it: PNode) =
|
||||
elif it.kind == nkSym and belongsToPackage(d.conf, it.sym):
|
||||
let full = AbsoluteFile toFullPath(d.conf, FileIndex it.sym.position)
|
||||
let tmp = getOutFile2(d.conf, full.relativeTo(d.conf.projectPath), HtmlExt,
|
||||
RelativeDir"htmldocs")
|
||||
RelativeDir"htmldocs", sfMainModule notin it.sym.flags)
|
||||
let external = relativeTo(tmp, d.thisDir, '/').string
|
||||
if d.section[k] != nil: add(d.section[k], ", ")
|
||||
dispA(d.conf, d.section[k],
|
||||
|
||||
@@ -111,7 +111,7 @@ proc canon(x: string; result: var string; state: var int) =
|
||||
# f/..
|
||||
while d > (state and 1) and result[d-1] != DirSep:
|
||||
dec d
|
||||
setLen(result, d-1)
|
||||
if d > 0: setLen(result, d-1)
|
||||
elif isDot(x, b):
|
||||
discard "discard the dot"
|
||||
elif b[1] > b[0]:
|
||||
|
||||
Reference in New Issue
Block a user