Skip to content

Commit

Permalink
docgen: fix #14448 show @@ as .. in href text (#14451)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored May 26, 2020
1 parent acadda8 commit 5575892
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions compiler/docgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ proc presentationPath*(conf: ConfigRef, file: AbsoluteFile, isTitle = false): Re
if isTitle:
result = result.string.nativeToUnix.RelativeFile
else:
result = result.string.replace("..", "@@").RelativeFile ## refs #13223
result = result.string.replace("..", dotdotMangle).RelativeFile
doAssert not result.isEmpty
doAssert not isAbsolute(result.string)

Expand Down Expand Up @@ -926,7 +926,7 @@ proc traceDeps(d: PDoc, it: PNode) =
if d.section[k] != nil: d.section[k].add(", ")
dispA(d.conf, d.section[k],
"<a class=\"reference external\" href=\"$2\">$1</a>",
"$1", [rope esc(d.target, changeFileExt(external, "")),
"$1", [rope esc(d.target, external.prettyLink),
rope changeFileExt(external, "html")])

proc exportSym(d: PDoc; s: PSym) =
Expand All @@ -936,7 +936,7 @@ proc exportSym(d: PDoc; s: PSym) =
if d.section[k] != nil: d.section[k].add(", ")
dispA(d.conf, d.section[k],
"<a class=\"reference external\" href=\"$2\">$1</a>",
"$1", [rope esc(d.target, changeFileExt(external, "")),
"$1", [rope esc(d.target, external.prettyLink),
rope changeFileExt(external, "html")])
elif s.kind != skModule and s.owner != nil:
let module = originatingModule(s)
Expand Down
7 changes: 6 additions & 1 deletion lib/packages/docutils/rstgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ type
testCmd: string
status: int

const dotdotMangle* = "@@" ## refs #13223

proc prettyLink*(file: string): string =
changeFileExt(file, "").replace(dotdotMangle, "..")

proc init(p: var CodeBlockParams) =
## Default initialisation of CodeBlockParams to sane values.
p.startLine = 1
Expand Down Expand Up @@ -574,7 +579,7 @@ proc generateModuleJumps(modules: seq[string]): string =

var chunks: seq[string] = @[]
for name in modules:
chunks.add("<a href=\"" & name & ".html\">" & name & "</a>")
chunks.add("<a href=\"$1.html\">$2</a>" % [name, name.prettyLink])

result.add(chunks.join(", ") & ".<br/>")

Expand Down

0 comments on commit 5575892

Please sign in to comment.