Skip to content

Instantly share code, notes, and snippets.

@dustinlacewell
Created February 18, 2016 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustinlacewell/c13f1a6998abac8c37e1 to your computer and use it in GitHub Desktop.
Save dustinlacewell/c13f1a6998abac8c37e1 to your computer and use it in GitHub Desktop.
import strutils
import sequtils
import ospaths
let
root_path = thisDir()
source_path = root_path / "dadren"
docs_path = root_path / "docs"
build_path = root_path / "gh_pages"
task docs, "build the dadren documentation":
rmDir(build_path)
mkDir(build_path)
withDir(build_path):
for file in listFiles(source_path):
let (dir, name, ext) = splitFile(file)
if ext == ".nim":
let cmd = "nim --index:on -p=$1 doc2 $2".format(root_path, file)
try: exec(cmd)
except: discard
for file in listFiles(docs_path):
let (dir, name, ext) = splitFile(file)
if ext == ".rst":
let cmd = "nim rst2html $1".format(file)
try: exec(cmd)
except: discard
for file in listFiles(docs_path):
let (dir, name, ext) = splitFile(file)
if ext == ".html":
let
filename = name & ext
htmlfile = name & ".html"
fullpath = joinPath(build_path, htmlfile)
echo "File:"
echo(file)
echo "Build path:"
echo(build_path)
echo "Htmlfile:"
echo(htmlfile)
echo "Full path:"
echo(fullpath)
echo("moving $1 to $2".format(file, fullpath))
mvFile(file, fullpath)
File:
/home/dlacewell/nim/dadren/docs/overview.html
Build path:
/home/dlacewell/nim/dadren/docs/overview.rst
Htmlfile:
overview.html
Full path:
/home/dlacewell/nim/dadren/docs/overview.rst/overview.html
moving /home/dlacewell/nim/dadren/docs/overview.html to /home/dlacewell/nim/dadren/docs/overview.rst/overview.html
stack trace: (most recent call last)
lib/system/nimscript.nim(253)
lib/system/nimscript.nim(228) docsTask
lib/system/nimscript.nim(131) cd
lib/system/nimscript.nim(131, 19) Error: unhandled exception: Not a directory Not a directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment