equal
deleted
inserted
replaced
11 |
11 |
12 |
12 |
13 object Doc { |
13 object Doc { |
14 /* entries */ |
14 /* entries */ |
15 |
15 |
16 case class Section(title: String, important: Boolean, entries: List[Entry]) |
16 case class Section(title: String, important: Boolean, entries: List[Entry]) { |
|
17 def print_title: String = title + if_proper(important, "!") |
|
18 } |
17 case class Entry(name: String, path: Path, title: String = "") { |
19 case class Entry(name: String, path: Path, title: String = "") { |
18 def view(): Unit = Doc.view(path) |
20 def view(): Unit = Doc.view(path) |
19 override def toString: String = // GUI label |
21 override def toString: String = // GUI label |
20 if (title.nonEmpty) { |
22 if (title.nonEmpty) { |
21 val style = GUI.Style_HTML |
23 val style = GUI.Style_HTML |
55 |
57 |
56 def section(title: String, important: Boolean, entries: List[Entry]): Contents = |
58 def section(title: String, important: Boolean, entries: List[Entry]): Contents = |
57 apply(List(Section(title, important, entries))) |
59 apply(List(Section(title, important, entries))) |
58 } |
60 } |
59 class Contents private(val sections: List[Section]) { |
61 class Contents private(val sections: List[Section]) { |
|
62 override def toString: String = |
|
63 sections.map(_.print_title).mkString("Doc.Contents(", ", ", ")") |
|
64 |
60 def ++ (other: Contents): Contents = new Contents(sections ::: other.sections) |
65 def ++ (other: Contents): Contents = new Contents(sections ::: other.sections) |
61 def entries(name: String => Boolean = _ => true, pdf: Boolean = false): List[Entry] = |
66 def entries(name: String => Boolean = _ => true, pdf: Boolean = false): List[Entry] = |
62 sections.flatMap(s => s.entries.filter(e => name(e.name) && (!pdf || e.path.is_pdf))) |
67 sections.flatMap(s => s.entries.filter(e => name(e.name) && (!pdf || e.path.is_pdf))) |
63 } |
68 } |
64 |
69 |