Skip to content

Commit 1b54be7

Browse files
timotheecourAraq
authored andcommitted
fixes #12998 nim doc regression (#13117)
1 parent 5ef0494 commit 1b54be7

File tree

13 files changed

+28
-16
lines changed

13 files changed

+28
-16
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ megatest.nim
8989

9090
# ignore debug dirs generated by dsymutil on OSX
9191
*.dSYM
92+
93+
nimdoc.out.css

compiler/docgen.nim

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import
1717
packages/docutils/rst, packages/docutils/rstgen,
1818
json, xmltree, cgi, trees, types,
1919
typesrenderer, astalgo, lineinfos, intsets,
20-
pathutils, trees
20+
pathutils, trees, nimconf
2121

2222
const
2323
exportSection = skField
@@ -43,6 +43,7 @@ type
4343
destFile*: AbsoluteFile
4444
thisDir*: AbsoluteDir
4545
examples: string
46+
wroteCss*: bool
4647

4748
PDoc* = ref TDocumentor ## Alias to type less.
4849

@@ -1069,10 +1070,16 @@ proc writeOutput*(d: PDoc, useWarning = false) =
10691070
template outfile: untyped = d.destFile
10701071
#let outfile = getOutFile2(d.conf, shortenDir(d.conf, filename), outExt, "htmldocs")
10711072
createDir(outfile.splitFile.dir)
1073+
d.conf.outFile = outfile.extractFilename.RelativeFile
10721074
if not writeRope(content, outfile):
10731075
rawMessage(d.conf, if useWarning: warnCannotOpenFile else: errCannotOpenFile,
10741076
outfile.string)
1075-
d.conf.outFile = outfile.extractFilename.RelativeFile
1077+
elif not d.wroteCss:
1078+
let cssSource = $d.conf.getPrefixDir() / "doc" / "nimdoc.css"
1079+
let cssDest = $d.conf.outDir / "nimdoc.out.css"
1080+
# renamed to make it easier to use with gitignore in user's repos
1081+
copyFile(cssSource, cssDest)
1082+
d.wroteCss = true
10761083

10771084
proc writeOutputJson*(d: PDoc, useWarning = false) =
10781085
runAllExamples(d)

compiler/installer.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,4 @@ licenses: "bin/nim,MIT;lib/*,MIT;"
139139

140140
[nimble]
141141
pkgName: "compiler"
142-
pkgFiles: "compiler/*;doc/basicopt.txt;doc/advopt.txt"
142+
pkgFiles: "compiler/*;doc/basicopt.txt;doc/advopt.txt;doc/nimdoc.css"

compiler/main.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ proc mainCommand*(graph: ModuleGraph) =
305305

306306
var dumpdata = %[
307307
(key: "version", val: %VersionAsString),
308+
(key: "prefixdir", val: %conf.getPrefixDir().string),
308309
(key: "project_path", val: %conf.projectFull.string),
309310
(key: "defined_symbols", val: definedSymbols),
310311
(key: "lib_paths", val: %libpaths),

compiler/options.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ proc getPrefixDir*(conf: ConfigRef): AbsoluteDir =
509509
##
510510
## This is overridden by some tools (namely nimsuggest) via the ``conf.prefixDir``
511511
## field.
512+
## This should resolve to root of nim sources, whether running nim from a local
513+
## clone or using installed nim, so that these exist: `result/doc/advopt.txt`
514+
## and `result/lib/system.nim`
512515
if not conf.prefixDir.isEmpty: result = conf.prefixDir
513516
else: result = AbsoluteDir splitPath(getAppDir()).head
514517

config/nimdoc.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ doc.file = """<?xml version="1.0" encoding="utf-8" ?>
237237

238238
<!-- CSS -->
239239
<title>$title</title>
240-
<link rel="stylesheet" type="text/css" href="nimdoc.css">
240+
<link rel="stylesheet" type="text/css" href="/nimdoc.out.css">
241241

242242
<script type="text/javascript" src="dochack.js"></script>
243243

koch.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ when defined(i386) and defined(windows) and defined(vcc):
2424
{.link: "icons/koch-i386-windows-vcc.res".}
2525

2626
import
27-
os, strutils, parseopt, osproc, streams
27+
os, strutils, parseopt, osproc
2828

2929
import tools / kochdocs
3030

@@ -45,6 +45,7 @@ Options:
4545
--help, -h shows this help and quits
4646
--latest bundle the installers with a bleeding edge Nimble
4747
--stable bundle the installers with a stable Nimble (default)
48+
--nim:path use specified path for nim binary
4849
Possible Commands:
4950
boot [options] bootstraps with given command line options
5051
distrohelper [bindir] helper for distro packagers
@@ -605,6 +606,7 @@ when isMainModule:
605606
case normalize(op.key)
606607
of "latest": latest = true
607608
of "stable": latest = false
609+
of "nim": nimExe = op.val.absolutePath # absolute so still works with changeDir
608610
else: showHelp()
609611
of cmdArgument:
610612
case normalize(op.key)

nimdoc/test_out_index_dot_html/expected/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- CSS -->
2020
<title>foo</title>
21-
<link rel="stylesheet" type="text/css" href="nimdoc.css">
21+
<link rel="stylesheet" type="text/css" href="/nimdoc.out.css">
2222

2323
<script type="text/javascript" src="dochack.js"></script>
2424

nimdoc/test_out_index_dot_html/expected/theindex.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- CSS -->
2020
<title>Index</title>
21-
<link rel="stylesheet" type="text/css" href="nimdoc.css">
21+
<link rel="stylesheet" type="text/css" href="/nimdoc.out.css">
2222

2323
<script type="text/javascript" src="dochack.js"></script>
2424

nimdoc/testproject/expected/subdir/subdir_b/utils.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- CSS -->
2020
<title>utils</title>
21-
<link rel="stylesheet" type="text/css" href="nimdoc.css">
21+
<link rel="stylesheet" type="text/css" href="/nimdoc.out.css">
2222

2323
<script type="text/javascript" src="dochack.js"></script>
2424

nimdoc/testproject/expected/testproject.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- CSS -->
2020
<title>testproject</title>
21-
<link rel="stylesheet" type="text/css" href="nimdoc.css">
21+
<link rel="stylesheet" type="text/css" href="/nimdoc.out.css">
2222

2323
<script type="text/javascript" src="dochack.js"></script>
2424

nimdoc/testproject/expected/theindex.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
<!-- CSS -->
2020
<title>Index</title>
21-
<link rel="stylesheet" type="text/css" href="nimdoc.css">
21+
<link rel="stylesheet" type="text/css" href="/nimdoc.out.css">
2222

2323
<script type="text/javascript" src="dochack.js"></script>
2424

tools/kochdocs.nim

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ const
1111
webUploadOutput = "web/upload"
1212
docHackDir = "tools/dochack"
1313

14+
var nimExe*: string
15+
1416
proc exe*(f: string): string =
1517
result = addFileExt(f, ExeExt)
1618
when defined(windows):
1719
result = result.replace('/','\\')
1820

1921
proc findNim*(): string =
22+
if nimExe.len > 0: return nimExe
2023
var nim = "nim".exe
2124
result = "bin" / nim
2225
if existsFile(result): return
@@ -366,14 +369,11 @@ proc buildJS() =
366369
proc buildDocs*(args: string) =
367370
const
368371
docHackJs = "dochack.js"
369-
css = "nimdoc.css"
370372
let
371373
a = nimArgs & " " & args
372374
docHackJsSource = docHackDir / docHackJs
373375
docHackJsDest = docHtmlOutput / docHackJs
374376

375-
cssSource = "doc" / css
376-
cssDest = docHtmlOutput / css
377377
buildJS() # This call generates docHackJsSource
378378
let docup = webUploadOutput / NimVersion
379379
createDir(docup)
@@ -387,6 +387,3 @@ proc buildDocs*(args: string) =
387387
buildDoc(nimArgs, docHtmlOutput)
388388
copyFile(docHackJsSource, docHackJsDest)
389389
copyFile(docHackJsSource, docup / docHackJs)
390-
391-
copyFile(cssSource, cssDest)
392-
copyFile(cssSource, docup / css)

0 commit comments

Comments
 (0)