blob: da9bacebd735d581e23e8f7f1fc3c7dae1be2899 (
plain) (
blame)
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
|
package book
import acyclic.file
import java.io.InputStream
import java.nio.file.{Paths, Files}
object Main {
def write(txt: String, dest: String) = {
Paths.get(dest).toFile.getParentFile.mkdirs()
Files.deleteIfExists(Paths.get(dest))
Files.write(Paths.get(dest), txt.getBytes)
}
def copy(src: InputStream, dest: String) = {
Paths.get(dest).toFile.getParentFile.mkdirs()
Files.deleteIfExists(Paths.get(dest))
Files.copy(src, Paths.get(dest))
}
def main(args: Array[String]): Unit = {
println("Writing Book")
write(Book.site, "output/index.html")
for(res <- Book.autoResources ++ Book.manualResources) {
copy(getClass.getResourceAsStream("/" + res), "output/" + res)
}
val allNames = {
def rec(n: Tree[String]): Seq[String] = {
n.value +: n.children.flatMap(rec)
}
rec(sect.structure).toSet
}
val dupes = allNames.groupBy(x => x)
.values
.filter(_.size > 1)
.map(_.head)
.toSet
assert(dupes.size == 0, s"Duplicate names: $dupes")
val dangling = sect.usedRefs -- allNames
assert(dangling.size == 0, s"Dangling Refs: $dangling")
println("Writing Done")
// can be used to verify that no links are broken
// lnk.usedLinks
}
}
|