forked from Vindaar/ggplotnim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathggplotnim.nimble
80 lines (68 loc) · 2.63 KB
/
ggplotnim.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Package
version = "0.3.1"
author = "Sebastian Schmidt"
description = "A port of ggplot2 for Nim"
license = "MIT"
srcDir = "src"
# Dependencies
requires "nim >= 1.0.0"
requires "https://github.com/Vindaar/seqmath >= 0.1.7"
requires "ginger >= 0.2.1"
requires "persvector >= 1.0.0"
requires "shell >= 0.2.2" # to run tCompareRecipes test
requires "arraymancer"
task testCI, "Run standard tests w/o cairo dependency":
# This runs all tests suitable for a CI environment, which does not provide
# cairo. Most tests are independent of cairo anyways
exec "nim c -d:noCairo -r tests/testDf.nim"
exec "nim c -d:noCairo -r tests/tests.nim"
exec "nim c -d:noCairo -r tests/test_issue2.nim"
exec "nim c -d:noCairo -r tests/test_issue20.nim"
exec "nim c -d:noCairo -r tests/test_issue28.nim"
task test, "Run standard tests":
exec "nim c -r tests/testDf.nim"
exec "nim c -r tests/tests.nim"
exec "nim c -r tests/test_issue2.nim"
exec "nim c -r tests/test_issue20.nim"
exec "nim c -r tests/test_issue28.nim"
task fulltest, "Run all tests, including recipe comparison (requires ntangle)":
exec "nim c -r tests/testDf.nim"
exec "nim c -r tests/tests.nim"
exec "nim c -r tests/test_issue2.nim"
exec "nim c -r tests/test_issue20.nim"
exec "nim c -r tests/test_issue28.nim"
exec "nim c -r tests/tCompareRecipes.nim"
import ospaths, strutils, strformat
const
pkgName = "ggplotnim"
orgFile = "docs" / (pkgName & ".org")
rstFile = "docs" / (pkgName & ".rst")
rstFileAuto = "docs" / (pkgName & "_autogen.rst")
proc basename(f: string): string =
let (dir, name, ext) = f.splitFile
result = name
proc removePrefix(f, prefix: string): string =
result = f
result.removePrefix(prefix)
# doc generation inspired by `strfmt`
task docs, "Generate HTML docs using the Org file":
# https://github.com/jgm/pandoc/issues/4749
exec "pandoc " & orgFile & " -o " & rstFile
var files: seq[string]
template walk(path: string, outf: untyped): untyped {.dirty.} =
for filePath in listFiles(path):
if filePath.endsWith(".nim"):
let outfile = outf
exec &"nim doc {outfile} {filePath}"
files.add outfile.removePrefix("-o:")
walk("src", "-o:index.html")
walk("src" / pkgName, &"-o:{filePath.basename}.html")
mvFile rstFile, rstFileAuto
for f in files:
let fname = f.basename & ".html"
mvFile fname, "docs/" & $fname
task recipes, "Generate and run all recipes":
exec "ntangle recipes.org"
exec "nim c -r recipes/runRecipes.nim"
task recipesPlots, "Generate the PNGs from all recipes":
exec """for f in media/recipes/r*.pdf; do inkscape $f --export-png="${f/.pdf/.png}"; done"""