src/Pure/Tools/doc.scala
changeset 83383 e7e1ffa36821
parent 82762 e8194d555625
child 83387 65d22b27471a
equal deleted inserted replaced
83382:67c848a77c7e 83383:e7e1ffa36821
    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