diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-01-16 05:19:58 -0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-01-16 14:19:58 +0100 |
commit | 1b54be77799bd89de7b82746324833291a5f9d0c (patch) | |
tree | 3e65f343c26cb4da0874b58225027e2b76883a91 | |
parent | 5ef049467727cd2a0cce0c217e6223366842fb6c (diff) | |
download | Nim-1b54be77799bd89de7b82746324833291a5f9d0c.tar.gz |
fixes #12998 nim doc regression (#13117)
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | compiler/docgen.nim | 11 | ||||
-rw-r--r-- | compiler/installer.ini | 2 | ||||
-rw-r--r-- | compiler/main.nim | 1 | ||||
-rw-r--r-- | compiler/options.nim | 3 | ||||
-rw-r--r-- | config/nimdoc.cfg | 2 | ||||
-rw-r--r-- | koch.nim | 4 | ||||
-rw-r--r-- | nimdoc/test_out_index_dot_html/expected/index.html | 2 | ||||
-rw-r--r-- | nimdoc/test_out_index_dot_html/expected/theindex.html | 2 | ||||
-rw-r--r-- | nimdoc/testproject/expected/subdir/subdir_b/utils.html | 2 | ||||
-rw-r--r-- | nimdoc/testproject/expected/testproject.html | 2 | ||||
-rw-r--r-- | nimdoc/testproject/expected/theindex.html | 2 | ||||
-rw-r--r-- | tools/kochdocs.nim | 9 |
13 files changed, 28 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore index a9b65bb02..895e3637c 100644 --- a/.gitignore +++ b/.gitignore @@ -89,3 +89,5 @@ megatest.nim # ignore debug dirs generated by dsymutil on OSX *.dSYM + +nimdoc.out.css diff --git a/compiler/docgen.nim b/compiler/docgen.nim index a09f54c16..505488e27 100644 --- a/compiler/docgen.nim +++ b/compiler/docgen.nim @@ -17,7 +17,7 @@ import packages/docutils/rst, packages/docutils/rstgen, json, xmltree, cgi, trees, types, typesrenderer, astalgo, lineinfos, intsets, - pathutils, trees + pathutils, trees, nimconf const exportSection = skField @@ -43,6 +43,7 @@ type destFile*: AbsoluteFile thisDir*: AbsoluteDir examples: string + wroteCss*: bool PDoc* = ref TDocumentor ## Alias to type less. @@ -1069,10 +1070,16 @@ proc writeOutput*(d: PDoc, useWarning = false) = template outfile: untyped = d.destFile #let outfile = getOutFile2(d.conf, shortenDir(d.conf, filename), outExt, "htmldocs") createDir(outfile.splitFile.dir) + d.conf.outFile = outfile.extractFilename.RelativeFile if not writeRope(content, outfile): rawMessage(d.conf, if useWarning: warnCannotOpenFile else: errCannotOpenFile, outfile.string) - d.conf.outFile = outfile.extractFilename.RelativeFile + elif not d.wroteCss: + let cssSource = $d.conf.getPrefixDir() / "doc" / "nimdoc.css" + let cssDest = $d.conf.outDir / "nimdoc.out.css" + # renamed to make it easier to use with gitignore in user's repos + copyFile(cssSource, cssDest) + d.wroteCss = true proc writeOutputJson*(d: PDoc, useWarning = false) = runAllExamples(d) diff --git a/compiler/installer.ini b/compiler/installer.ini index fed077fdb..f8676ab08 100644 --- a/compiler/installer.ini +++ b/compiler/installer.ini @@ -139,4 +139,4 @@ licenses: "bin/nim,MIT;lib/*,MIT;" [nimble] pkgName: "compiler" -pkgFiles: "compiler/*;doc/basicopt.txt;doc/advopt.txt" +pkgFiles: "compiler/*;doc/basicopt.txt;doc/advopt.txt;doc/nimdoc.css" diff --git a/compiler/main.nim b/compiler/main.nim index 3cafe1f2c..4e444bff7 100644 --- a/compiler/main.nim +++ b/compiler/main.nim @@ -305,6 +305,7 @@ proc mainCommand*(graph: ModuleGraph) = var dumpdata = %[ (key: "version", val: %VersionAsString), + (key: "prefixdir", val: %conf.getPrefixDir().string), (key: "project_path", val: %conf.projectFull.string), (key: "defined_symbols", val: definedSymbols), (key: "lib_paths", val: %libpaths), diff --git a/compiler/options.nim b/compiler/options.nim index 9c17ea1e6..3866f4b7f 100644 --- a/compiler/options.nim +++ b/compiler/options.nim @@ -509,6 +509,9 @@ proc getPrefixDir*(conf: ConfigRef): AbsoluteDir = ## ## This is overridden by some tools (namely nimsuggest) via the ``conf.prefixDir`` ## field. + ## This should resolve to root of nim sources, whether running nim from a local + ## clone or using installed nim, so that these exist: `result/doc/advopt.txt` + ## and `result/lib/system.nim` if not conf.prefixDir.isEmpty: result = conf.prefixDir else: result = AbsoluteDir splitPath(getAppDir()).head diff --git a/config/nimdoc.cfg b/config/nimdoc.cfg index e3282ee7f..0ecb75c36 100644 --- a/config/nimdoc.cfg +++ b/config/nimdoc.cfg @@ -237,7 +237,7 @@ doc.file = """<?xml version="1.0" encoding="utf-8" ?> <!-- CSS --> <title>$title</title> -<link rel="stylesheet" type="text/css" href="nimdoc.css"> +<link rel="stylesheet" type="text/css" href="/nimdoc.out.css"> <script type="text/javascript" src="dochack.js"></script> diff --git a/koch.nim b/koch.nim index a0a7dd903..7d7e252bf 100644 --- a/koch.nim +++ b/koch.nim @@ -24,7 +24,7 @@ when defined(i386) and defined(windows) and defined(vcc): {.link: "icons/koch-i386-windows-vcc.res".} import - os, strutils, parseopt, osproc, streams + os, strutils, parseopt, osproc import tools / kochdocs @@ -45,6 +45,7 @@ Options: --help, -h shows this help and quits --latest bundle the installers with a bleeding edge Nimble --stable bundle the installers with a stable Nimble (default) + --nim:path use specified path for nim binary Possible Commands: boot [options] bootstraps with given command line options distrohelper [bindir] helper for distro packagers @@ -605,6 +606,7 @@ when isMainModule: case normalize(op.key) of "latest": latest = true of "stable": latest = false + of "nim": nimExe = op.val.absolutePath # absolute so still works with changeDir else: showHelp() of cmdArgument: case normalize(op.key) diff --git a/nimdoc/test_out_index_dot_html/expected/index.html b/nimdoc/test_out_index_dot_html/expected/index.html index caf38a86d..d9ad0d625 100644 --- a/nimdoc/test_out_index_dot_html/expected/index.html +++ b/nimdoc/test_out_index_dot_html/expected/index.html @@ -18,7 +18,7 @@ <!-- CSS --> <title>foo</title> -<link rel="stylesheet" type="text/css" href="nimdoc.css"> +<link rel="stylesheet" type="text/css" href="/nimdoc.out.css"> <script type="text/javascript" src="dochack.js"></script> diff --git a/nimdoc/test_out_index_dot_html/expected/theindex.html b/nimdoc/test_out_index_dot_html/expected/theindex.html index e0b0c067d..49e37bddf 100644 --- a/nimdoc/test_out_index_dot_html/expected/theindex.html +++ b/nimdoc/test_out_index_dot_html/expected/theindex.html @@ -18,7 +18,7 @@ <!-- CSS --> <title>Index</title> -<link rel="stylesheet" type="text/css" href="nimdoc.css"> +<link rel="stylesheet" type="text/css" href="/nimdoc.out.css"> <script type="text/javascript" src="dochack.js"></script> diff --git a/nimdoc/testproject/expected/subdir/subdir_b/utils.html b/nimdoc/testproject/expected/subdir/subdir_b/utils.html index 8d646e6a1..30a172226 100644 --- a/nimdoc/testproject/expected/subdir/subdir_b/utils.html +++ b/nimdoc/testproject/expected/subdir/subdir_b/utils.html @@ -18,7 +18,7 @@ <!-- CSS --> <title>utils</title> -<link rel="stylesheet" type="text/css" href="nimdoc.css"> +<link rel="stylesheet" type="text/css" href="/nimdoc.out.css"> <script type="text/javascript" src="dochack.js"></script> diff --git a/nimdoc/testproject/expected/testproject.html b/nimdoc/testproject/expected/testproject.html index 123ddce59..b641bad6e 100644 --- a/nimdoc/testproject/expected/testproject.html +++ b/nimdoc/testproject/expected/testproject.html @@ -18,7 +18,7 @@ <!-- CSS --> <title>testproject</title> -<link rel="stylesheet" type="text/css" href="nimdoc.css"> +<link rel="stylesheet" type="text/css" href="/nimdoc.out.css"> <script type="text/javascript" src="dochack.js"></script> diff --git a/nimdoc/testproject/expected/theindex.html b/nimdoc/testproject/expected/theindex.html index e0282e355..912ba98c2 100644 --- a/nimdoc/testproject/expected/theindex.html +++ b/nimdoc/testproject/expected/theindex.html @@ -18,7 +18,7 @@ <!-- CSS --> <title>Index</title> -<link rel="stylesheet" type="text/css" href="nimdoc.css"> +<link rel="stylesheet" type="text/css" href="/nimdoc.out.css"> <script type="text/javascript" src="dochack.js"></script> diff --git a/tools/kochdocs.nim b/tools/kochdocs.nim index 4adfef71e..f99567cd0 100644 --- a/tools/kochdocs.nim +++ b/tools/kochdocs.nim @@ -11,12 +11,15 @@ const webUploadOutput = "web/upload" docHackDir = "tools/dochack" +var nimExe*: string + proc exe*(f: string): string = result = addFileExt(f, ExeExt) when defined(windows): result = result.replace('/','\\') proc findNim*(): string = + if nimExe.len > 0: return nimExe var nim = "nim".exe result = "bin" / nim if existsFile(result): return @@ -366,14 +369,11 @@ proc buildJS() = proc buildDocs*(args: string) = const docHackJs = "dochack.js" - css = "nimdoc.css" let a = nimArgs & " " & args docHackJsSource = docHackDir / docHackJs docHackJsDest = docHtmlOutput / docHackJs - cssSource = "doc" / css - cssDest = docHtmlOutput / css buildJS() # This call generates docHackJsSource let docup = webUploadOutput / NimVersion createDir(docup) @@ -387,6 +387,3 @@ proc buildDocs*(args: string) = buildDoc(nimArgs, docHtmlOutput) copyFile(docHackJsSource, docHackJsDest) copyFile(docHackJsSource, docup / docHackJs) - - copyFile(cssSource, cssDest) - copyFile(cssSource, docup / css) |