How do you customize the html css output created by the nim rst2html command?
I was able to edit the compiler's config file (~/.choosenim/toolchains/nim-0.19.0/config/nimdoc.cfg) to customize the css and I saw the changes in the css output.
However, now I'm trying to do it with my own config file without touching the compiler config.
I put a myprojectnimdoc.cfg file next to my project's nimble file but this doesn't do anything. Here is the command I'm running:
nim rst2html --out:docs/main.html docs/main.rst
Here is the contents of the myprojectnimdoc.cfg file:
<style type="text/css" >
body {
background-color: green;
}
</style>
Unrelated to OP's question, but related to nimdoc:
I never got the JavaScript based search to work, even after copying dochack.js from Nim docs site. I see that's the case with the glob docs too.
I am looking for a solution to that.
I had opened an issue regarding dochack.js for the Nim docs website. That is now resolved, but this is a different issue.
I finally got the search working for my repo here. I have the solution portable in the form of a docs NimScript task.
from ospaths import `/`, splitPath
from strutils import `%`
switch("nep1", "on")
let
root = thisDir()
(_, pkgName) = root.splitPath()
srcFile = root / "src" / (pkgName & ".nim")
task docs, "Deploy doc html + search index to public/ directory":
let
deployDir = root / "public"
deployHtmlFile = deployDir / "index.html"
deployIdxFile = deployDir / (pkgName & ".idx")
deployJsFile = deployDir / "dochack.js"
genDocCmd = "nim doc --index:on -o:$1 $2" % [deployHtmlFile, srcFile]
sedCmd = "sed -i 's|" & pkgName & r"\.html|index.html|' " & deployIdxFile
genTheIndexCmd = "nim buildIndex -o:$1/theindex.html $1" % [deployDir]
docHackJsSource = "http://nim-lang.github.io/Nim/dochack.js" # devel docs dochack.js
mkDir(deployDir)
exec(genDocCmd)
exec(sedCmd) # Hack: replace pkgName.html with index.html in the .idx file
exec(genTheIndexCmd) # Generate theindex.html only after fixing the .idx file
if not fileExists(deployJsFile):
withDir deployDir:
exec("curl -LO " & docHackJsSource)