docgen: mangling using _. instead of @@ to avoid issue (#14454)
This commit is contained in:
parent
2a4a43b05f
commit
38cb277653
4 changed files with 33 additions and 21 deletions
|
|
@ -27,6 +27,9 @@ const
|
||||||
nimdocOutCss* = "nimdoc.out.css"
|
nimdocOutCss* = "nimdoc.out.css"
|
||||||
# `out` to make it easier to use with gitignore in user's repos
|
# `out` to make it easier to use with gitignore in user's repos
|
||||||
htmldocsDirname* = "htmldocs"
|
htmldocsDirname* = "htmldocs"
|
||||||
|
dotdotMangle* = "_._" ## refs #13223
|
||||||
|
# if this changes, make sure it's consistent with `esc` and `escapeLink`
|
||||||
|
# lots of other obvious options won't work, see #14454; `_` could work too
|
||||||
|
|
||||||
proc interp*(path: string, nimr: string): string =
|
proc interp*(path: string, nimr: string): string =
|
||||||
result = path % ["nimr", nimr]
|
result = path % ["nimr", nimr]
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,8 @@
|
||||||
import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
|
import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
|
||||||
algorithm, parseutils
|
algorithm, parseutils
|
||||||
|
|
||||||
|
import "$lib/../compiler/nimpaths"
|
||||||
|
|
||||||
const
|
const
|
||||||
HtmlExt = "html"
|
HtmlExt = "html"
|
||||||
IndexExt* = ".idx"
|
IndexExt* = ".idx"
|
||||||
|
|
@ -78,8 +80,6 @@ type
|
||||||
testCmd: string
|
testCmd: string
|
||||||
status: int
|
status: int
|
||||||
|
|
||||||
const dotdotMangle* = "@@" ## refs #13223
|
|
||||||
|
|
||||||
proc prettyLink*(file: string): string =
|
proc prettyLink*(file: string): string =
|
||||||
changeFileExt(file, "").replace(dotdotMangle, "..")
|
changeFileExt(file, "").replace(dotdotMangle, "..")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
#[
|
#[
|
||||||
todo: move findNimStdLibCompileTime, findNimStdLib here
|
todo: move findNimStdLibCompileTime, findNimStdLib here
|
||||||
xxx: consider moving this to $nim/compiler/relpaths.nim to get relocatable paths
|
xxx: consider moving this to $nim/compiler/relpaths.nim to get relocatable paths
|
||||||
|
|
||||||
|
## note: $lib vs $nim
|
||||||
|
note: these can resolve to 3 different paths if running via `nim c --lib:lib foo`,
|
||||||
|
eg if compiler was installed via nimble (or is in nim path), and nim is external
|
||||||
|
(ie not in `$lib/../bin/` dir)
|
||||||
|
|
||||||
|
import "$lib/../compiler/nimpaths" # <- most robust if you want to favor --lib:lib
|
||||||
|
import "$nim/compiler/nimpaths"
|
||||||
|
import compiler/nimpaths
|
||||||
]#
|
]#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ from std/sequtils import toSeq,mapIt
|
||||||
from std/algorithm import sorted
|
from std/algorithm import sorted
|
||||||
import stdtest/[specialpaths, unittest_light]
|
import stdtest/[specialpaths, unittest_light]
|
||||||
|
|
||||||
import "$nim/compiler/nimpaths"
|
import "$lib/../compiler/nimpaths"
|
||||||
|
|
||||||
const
|
const
|
||||||
nim = getCurrentCompilerExe()
|
nim = getCurrentCompilerExe()
|
||||||
|
|
@ -101,21 +101,21 @@ else: # don't run twice the same test
|
||||||
of 0,5:
|
of 0,5:
|
||||||
let htmlFile = htmldocsDir/"mmain.html"
|
let htmlFile = htmldocsDir/"mmain.html"
|
||||||
check htmlFile in outp # sanity check for `hintSuccessX`
|
check htmlFile in outp # sanity check for `hintSuccessX`
|
||||||
assertEquals ret, """
|
assertEquals ret, fmt"""
|
||||||
@@/imp.html
|
{dotdotMangle}/imp.html
|
||||||
@@/imp.idx
|
{dotdotMangle}/imp.idx
|
||||||
dochack.js
|
{docHackJsFname}
|
||||||
imp.html
|
imp.html
|
||||||
imp.idx
|
imp.idx
|
||||||
imp2.html
|
imp2.html
|
||||||
imp2.idx
|
imp2.idx
|
||||||
mmain.html
|
mmain.html
|
||||||
mmain.idx
|
mmain.idx
|
||||||
nimdoc.out.css
|
{nimdocOutCss}
|
||||||
theindex.html""", context
|
{theindexFname}""", context
|
||||||
of 1: assertEquals ret, """
|
of 1: assertEquals ret, fmt"""
|
||||||
dochack.js
|
{docHackJsFname}
|
||||||
nimdoc.out.css
|
{nimdocOutCss}
|
||||||
tests/nimdoc/imp.html
|
tests/nimdoc/imp.html
|
||||||
tests/nimdoc/imp.idx
|
tests/nimdoc/imp.idx
|
||||||
tests/nimdoc/sub/imp.html
|
tests/nimdoc/sub/imp.html
|
||||||
|
|
@ -124,20 +124,20 @@ tests/nimdoc/sub/imp2.html
|
||||||
tests/nimdoc/sub/imp2.idx
|
tests/nimdoc/sub/imp2.idx
|
||||||
tests/nimdoc/sub/mmain.html
|
tests/nimdoc/sub/mmain.html
|
||||||
tests/nimdoc/sub/mmain.idx
|
tests/nimdoc/sub/mmain.idx
|
||||||
theindex.html"""
|
{theindexFname}"""
|
||||||
of 2, 3: assertEquals ret, """
|
of 2, 3: assertEquals ret, fmt"""
|
||||||
dochack.js
|
{docHackJsFname}
|
||||||
mmain.html
|
mmain.html
|
||||||
mmain.idx
|
mmain.idx
|
||||||
nimdoc.out.css""", context
|
{nimdocOutCss}""", context
|
||||||
of 4: assertEquals ret, """
|
of 4: assertEquals ret, fmt"""
|
||||||
dochack.js
|
{docHackJsFname}
|
||||||
nimdoc.out.css
|
{nimdocOutCss}
|
||||||
sub/mmain.html
|
sub/mmain.html
|
||||||
sub/mmain.idx""", context
|
sub/mmain.idx""", context
|
||||||
of 6: assertEquals ret, """
|
of 6: assertEquals ret, fmt"""
|
||||||
mmain.html
|
mmain.html
|
||||||
nimdoc.out.css""", context
|
{nimdocOutCss}""", context
|
||||||
else: doAssert false
|
else: doAssert false
|
||||||
|
|
||||||
block: # mstatic_assert
|
block: # mstatic_assert
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue