fixes bootstrapping for any machine that has a Nim already installed [backport:1.4] (#15660)

(cherry picked from commit 9a059657ca)
This commit is contained in:
Andreas Rumpf
2020-10-20 21:07:24 +02:00
committed by narimiran
parent 11ef97d57f
commit eb04535b53
3 changed files with 24 additions and 18 deletions

View File

@@ -27,8 +27,7 @@
import strutils, os, hashes, strtabs, rstast, rst, highlite, tables, sequtils,
algorithm, parseutils
import "$lib/../compiler/nimpaths"
import "$lib/../compiler/pathutils"
import ../../std/private/since
const
@@ -58,8 +57,8 @@ type
options*: RstParseOptions
findFile*: FindFileHandler
msgHandler*: MsgHandler
outDir*: AbsoluteDir ## output directory, initialized by docgen.nim
destFile*: AbsoluteFile ## output (HTML) file, initialized by docgen.nim
outDir*: string ## output directory, initialized by docgen.nim
destFile*: string ## output (HTML) file, initialized by docgen.nim
filename*: string ## source Nim or Rst file
meta*: array[MetaEnum, string]
currentSection: string ## \
@@ -84,7 +83,7 @@ type
status: int
proc prettyLink*(file: string): string =
changeFileExt(file, "").replace(dotdotMangle, "..")
changeFileExt(file, "").replace("_._", "..")
proc init(p: var CodeBlockParams) =
## Default initialisation of CodeBlockParams to sane values.
@@ -759,13 +758,13 @@ proc renderHeadline(d: PDoc, n: PRstNode, result: var string) =
# Generate index entry using spaces to indicate TOC level for the output HTML.
assert n.level >= 0
let
htmlFileRelPath = if d.outDir.isEmpty():
htmlFileRelPath = if d.outDir.len == 0:
# /foo/bar/zoo.nim -> zoo.html
changeFileExt(extractFilename(d.filename), HtmlExt)
else: # d is initialized in docgen.nim
# outDir = /foo -\
# destFile = /foo/bar/zoo.html -|-> bar/zoo.html
d.destFile.relativeTo(d.outDir, '/').string
d.destFile.relativePath(d.outDir, '/')
setIndexTerm(d, htmlFileRelPath, refname, tmp.stripTocHtml,
spaces(max(0, n.level)) & tmp)