/
build.sbt
79 lines (66 loc) · 2.23 KB
/
build.sbt
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
// task to create documentation PDF
lazy val makePDF = taskKey[File]("Build PDF version of documentation")
lazy val pdfFileName = settingKey[String]("Name of the PDF file generated")
pdfFileName := s"RasterFrames-Users-Manual-${version.value}.pdf"
makePDF := {
import scala.sys.process._
// Get the python source directory configured in the root project.
val base = (Compile / paradox / sourceDirectories).value.find(_.toString.contains("python")).head
// Hard coded lacking any simple way of determining order.
val files = Seq(
"index.md",
"description.md",
"concepts.md",
"getting-started.md",
"raster-io.md",
"raster-catalogs.md",
"raster-read.md",
"raster-write.md",
"vector-data.md",
"raster-processing.md",
"local-algebra.md",
"nodata-handling.md",
"aggregation.md",
"time-series.md",
"machine-learning.md",
"unsupervised-learning.md",
"supervised-learning.md",
"numpy-pandas.md",
"languages.md",
"reference.md"
).map(base ** _).flatMap(_.get)
val log = streams.value.log
log.info("Section ordering:")
files.foreach(f => log.info(" - " + f.getName))
val work = target.value / "makePDF"
work.mkdirs()
val prepro = files.zipWithIndex.map { case (f, i) ⇒
val dest = work / f"$i%02d-${f.getName}%s"
// Filter cross links and add a newline
(Seq("sed", "-e", """s/@ref://g;s/@@.*//g""", f.toString) #> dest).!
// Add newline at the end of the file so as to make pandoc happy
("echo" #>> dest).!
("echo \\pagebreak" #>> dest).!
dest
}
val output = target.value / pdfFileName.value
val header = (Compile / sourceDirectory).value / "latex" / "header.latex"
val args = "pandoc" ::
"--from=markdown+pipe_tables" ::
"--to=pdf" ::
"-t" :: "latex" ::
"-s" ::
"--toc" ::
"-V" :: "title:RasterFrames Users' Manual" ::
"-V" :: "author:Astraea, Inc." ::
"-V" :: "geometry:margin=0.75in" ::
"-V" :: "papersize:letter" ::
"--include-in-header" :: header.toString ::
"-o" :: output.toString ::
prepro.map(_.toString).toList
log.info(s"Running: ${args.mkString(" ")}")
Process(args, base).!
log.info("Wrote: " + output)
output
}
makePDF := makePDF.dependsOn(Compile / paradox).value