nim doc: fixes cross-link generation when --out is used
This commit is contained in:
parent
2d8adb8e03
commit
f14f554435
2 changed files with 10 additions and 5 deletions
|
|
@ -94,13 +94,18 @@ proc parseRst(text, filename: string,
|
||||||
docgenFindFile, compilerMsgHandler)
|
docgenFindFile, compilerMsgHandler)
|
||||||
|
|
||||||
proc getOutFile2(conf: ConfigRef; filename: RelativeFile,
|
proc getOutFile2(conf: ConfigRef; filename: RelativeFile,
|
||||||
ext: string, dir: RelativeDir): AbsoluteFile =
|
ext: string, dir: RelativeDir; guessTarget: bool): AbsoluteFile =
|
||||||
if optWholeProject in conf.globalOptions:
|
if optWholeProject in conf.globalOptions:
|
||||||
# This is correct, for 'nim doc --project' we interpret the '--out' option as an
|
# This is correct, for 'nim doc --project' we interpret the '--out' option as an
|
||||||
# absolute directory, not as a filename!
|
# absolute directory, not as a filename!
|
||||||
let d = if conf.outFile.isEmpty: conf.projectPath / dir else: AbsoluteDir(conf.outFile)
|
let d = if conf.outFile.isEmpty: conf.projectPath / dir else: AbsoluteDir(conf.outFile)
|
||||||
createDir(d)
|
createDir(d)
|
||||||
result = d / changeFileExt(filename, ext)
|
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:
|
else:
|
||||||
result = getOutFile(conf, filename, ext)
|
result = getOutFile(conf, filename, ext)
|
||||||
|
|
||||||
|
|
@ -138,7 +143,7 @@ proc newDocumentor*(filename: AbsoluteFile; cache: IdentCache; conf: ConfigRef):
|
||||||
warnUser, "only 'rst2html' supports the ':test:' attribute")
|
warnUser, "only 'rst2html' supports the ':test:' attribute")
|
||||||
result.emitted = initIntSet()
|
result.emitted = initIntSet()
|
||||||
result.destFile = getOutFile2(conf, relativeTo(filename, conf.projectPath),
|
result.destFile = getOutFile2(conf, relativeTo(filename, conf.projectPath),
|
||||||
HtmlExt, RelativeDir"htmldocs")
|
HtmlExt, RelativeDir"htmldocs", false)
|
||||||
result.thisDir = result.destFile.splitFile.dir
|
result.thisDir = result.destFile.splitFile.dir
|
||||||
|
|
||||||
proc dispA(conf: ConfigRef; dest: var Rope, xml, tex: string, args: openArray[Rope]) =
|
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 full = AbsoluteFile toFullPath(d.conf, FileIndex s.owner.position)
|
||||||
let tmp = getOutFile2(d.conf, full.relativeTo(d.conf.projectPath),
|
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, '/')
|
let external = tmp.relativeTo(d.thisDir, '/')
|
||||||
result.addf "<a href=\"$1#$2\"><span class=\"Identifier\">$3</span></a>",
|
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):
|
elif it.kind == nkSym and belongsToPackage(d.conf, it.sym):
|
||||||
let full = AbsoluteFile toFullPath(d.conf, FileIndex it.sym.position)
|
let full = AbsoluteFile toFullPath(d.conf, FileIndex it.sym.position)
|
||||||
let tmp = getOutFile2(d.conf, full.relativeTo(d.conf.projectPath), HtmlExt,
|
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
|
let external = relativeTo(tmp, d.thisDir, '/').string
|
||||||
if d.section[k] != nil: add(d.section[k], ", ")
|
if d.section[k] != nil: add(d.section[k], ", ")
|
||||||
dispA(d.conf, d.section[k],
|
dispA(d.conf, d.section[k],
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ proc canon(x: string; result: var string; state: var int) =
|
||||||
# f/..
|
# f/..
|
||||||
while d > (state and 1) and result[d-1] != DirSep:
|
while d > (state and 1) and result[d-1] != DirSep:
|
||||||
dec d
|
dec d
|
||||||
setLen(result, d-1)
|
if d > 0: setLen(result, d-1)
|
||||||
elif isDot(x, b):
|
elif isDot(x, b):
|
||||||
discard "discard the dot"
|
discard "discard the dot"
|
||||||
elif b[1] > b[0]:
|
elif b[1] > b[0]:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue