mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
Implements definition lists Markdown extension adopted in a few implementations including: * [Pandoc]( https://pandoc.org/MANUAL.html#definition-lists) * [kramdown]( https://kramdown.gettalong.org/quickref.html#definition-lists) * [PHP extra Markdown]( https://michelf.ca/projects/php-markdown/extra/#def-list) Also affected files have been migrated. RST definition lists are turned off for Markdown: this solves the problem of broken formatting mentioned in https://github.com/nim-lang/Nim/pull/20292.
55 lines
2.1 KiB
Nim
55 lines
2.1 KiB
Nim
##[
|
|
Represents absolute paths, but using a symbolic variables (eg $nimr) which can be
|
|
resolved at runtime; this avoids hardcoding at compile time absolute paths so
|
|
that the project root can be relocated.
|
|
|
|
xxx factor pending https://github.com/timotheecour/Nim/issues/616, see also
|
|
$nim/testament/lib/stdtest/specialpaths.nim
|
|
specialpaths is simpler because it doesn't need variables to be relocatable at
|
|
runtime (eg for use in testament)
|
|
|
|
interpolation variables:
|
|
: $nimr: such that `$nimr/lib/system.nim` exists (avoids confusion with $nim binary)
|
|
in compiler, it's obtainable via getPrefixDir(); for other tools (eg koch),
|
|
this could be getCurrentDir() or getAppFilename().parentDir.parentDir,
|
|
depending on use case
|
|
|
|
Unstable API
|
|
]##
|
|
|
|
import os, strutils
|
|
|
|
when defined(nimPreviewSlimSystem):
|
|
import std/assertions
|
|
|
|
|
|
const
|
|
docCss* = "$nimr/doc/nimdoc.css"
|
|
docCls* = "$nimr/doc/nimdoc.cls"
|
|
docHackNim* = "$nimr/tools/dochack/dochack.nim"
|
|
docHackJs* = docHackNim.changeFileExt("js")
|
|
docHackJsFname* = docHackJs.lastPathPart
|
|
theindexFname* = "theindex.html"
|
|
nimdocOutCss* = "nimdoc.out.css"
|
|
nimdocOutCls* = "nimdoc.cls"
|
|
# `out` to make it easier to use with gitignore in user's repos
|
|
htmldocsDirname* = "htmldocs"
|
|
dotdotMangle* = "_._" ## refs #13223
|
|
# if this changes, make sure it's consistent with `esc` and `escapeLink`
|
|
# lots of other obvious options won't work, see #14454; `_` could work too
|
|
|
|
proc interp*(path: string, nimr: string): string =
|
|
result = path % ["nimr", nimr]
|
|
doAssert '$' notin result, $(path, nimr, result) # avoids un-interpolated variables in output
|
|
|
|
proc getDocHacksJs*(nimr: string, nim = getCurrentCompilerExe(), forceRebuild = false): string =
|
|
## return absolute path to dochack.js, rebuilding if it doesn't exist or if
|
|
## `forceRebuild`.
|
|
let docHackJs2 = docHackJs.interp(nimr = nimr)
|
|
if forceRebuild or not docHackJs2.fileExists:
|
|
let cmd = "$nim js -d:release $file" % ["nim", nim.quoteShell, "file", docHackNim.interp(nimr = nimr).quoteShell]
|
|
echo "getDocHacksJs: cmd: " & cmd
|
|
doAssert execShellCmd(cmd) == 0, $(cmd)
|
|
doAssert docHackJs2.fileExists
|
|
result = docHackJs2
|