Skip to content

Commit 451c476

Browse files
ClyybberAraq
authored andcommitted
Fix docs for subdirs too (#13180)
* Fix doc subdirs * Extract to helper proc, and fix on windows
1 parent f51613e commit 451c476

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

compiler/docgen.nim

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,6 +1009,9 @@ proc genSection(d: PDoc, kind: TSymKind) =
10091009
"sectionid", "sectionTitle", "sectionTitleID", "content"], [
10101010
ord(kind).rope, title, rope(ord(kind) + 50), d.toc[kind]])
10111011

1012+
proc cssHref(outDir: AbsoluteDir, destFile: AbsoluteFile): Rope =
1013+
rope($relativeTo(outDir / RelativeFile"nimdoc.out.css", destFile.splitFile().dir, '/'))
1014+
10121015
proc genOutFile(d: PDoc): Rope =
10131016
var
10141017
code, content: Rope
@@ -1042,12 +1045,11 @@ proc genOutFile(d: PDoc): Rope =
10421045
rope(getClockStr()), code, d.modDeprecationMsg])
10431046
if optCompileOnly notin d.conf.globalOptions:
10441047
# XXX what is this hack doing here? 'optCompileOnly' means raw output!?
1045-
code = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.file"), ["title",
1046-
"tableofcontents", "moduledesc", "date", "time",
1048+
code = ropeFormatNamedVars(d.conf, getConfigVar(d.conf, "doc.file"), [
1049+
"nimdoccss", "title", "tableofcontents", "moduledesc", "date", "time",
10471050
"content", "author", "version", "analytics", "deprecationMsg"],
1048-
[title.rope, toc, d.modDesc, rope(getDateStr()),
1049-
rope(getClockStr()), content, d.meta[metaAuthor].rope,
1050-
d.meta[metaVersion].rope, d.analytics.rope, d.modDeprecationMsg])
1051+
[cssHref(d.conf.outDir, d.destFile), title.rope, toc, d.modDesc, rope(getDateStr()), rope(getClockStr()),
1052+
content, d.meta[metaAuthor].rope, d.meta[metaVersion].rope, d.analytics.rope, d.modDeprecationMsg])
10511053
else:
10521054
code = content
10531055
result = code
@@ -1183,15 +1185,17 @@ proc commandTags*(cache: IdentCache, conf: ConfigRef) =
11831185
proc commandBuildIndex*(cache: IdentCache, conf: ConfigRef) =
11841186
var content = mergeIndexes(conf.projectFull.string).rope
11851187

1186-
let code = ropeFormatNamedVars(conf, getConfigVar(conf, "doc.file"), ["title",
1187-
"tableofcontents", "moduledesc", "date", "time",
1188-
"content", "author", "version", "analytics"],
1189-
["Index".rope, nil, nil, rope(getDateStr()),
1190-
rope(getClockStr()), content, nil, nil, nil])
1191-
# no analytics because context is not available
11921188
var outFile = RelativeFile"theindex"
11931189
if conf.outFile != RelativeFile"":
11941190
outFile = conf.outFile
11951191
let filename = getOutFile(conf, outFile, HtmlExt)
1192+
1193+
let code = ropeFormatNamedVars(conf, getConfigVar(conf, "doc.file"), [
1194+
"nimdoccss", "title", "tableofcontents", "moduledesc", "date", "time",
1195+
"content", "author", "version", "analytics"],
1196+
[cssHref(conf.outDir, filename), rope"Index", nil, nil, rope(getDateStr()),
1197+
rope(getClockStr()), content, nil, nil, nil])
1198+
# no analytics because context is not available
1199+
11961200
if not writeRope(code, filename):
11971201
rawMessage(conf, errCannotOpenFile, filename.string)

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.out.css">
240+
<link rel="stylesheet" type="text/css" href="$nimdoccss">
241241

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

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.out.css">
21+
<link rel="stylesheet" type="text/css" href="../../nimdoc.out.css">
2222

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

0 commit comments

Comments
 (0)