src/Pure/Thy/presentation.scala
changeset 74712 bcca7e3bcd0d
parent 74711 eb89b3a37826
child 74713 0d8b5612a0a6
equal deleted inserted replaced
74711:eb89b3a37826 74712:bcca7e3bcd0d
    24 
    24 
    25   final class HTML_Context private[Presentation]
    25   final class HTML_Context private[Presentation]
    26   {
    26   {
    27     val term_cache: Term.Cache = Term.Cache.make()
    27     val term_cache: Term.Cache = Term.Cache.make()
    28 
    28 
       
    29     private val already_presented = Synchronized(Set.empty[String])
       
    30     def register_presented(nodes: List[Document.Node.Name]): List[Document.Node.Name] =
       
    31       already_presented.change_result(presented =>
       
    32         (nodes.filterNot(name => presented.contains(name.theory)),
       
    33           presented ++ nodes.iterator.map(_.theory)))
       
    34 
    29     private val theory_cache = Synchronized(Map.empty[String, Export_Theory.Theory])
    35     private val theory_cache = Synchronized(Map.empty[String, Export_Theory.Theory])
    30 
       
    31     def cached_theories: Set[String] = theory_cache.value.keySet
       
    32 
       
    33     def cache_theory(thy_name: String, make_thy: => Export_Theory.Theory): Export_Theory.Theory =
    36     def cache_theory(thy_name: String, make_thy: => Export_Theory.Theory): Export_Theory.Theory =
    34     {
    37     {
    35       theory_cache.change_result(thys =>
    38       theory_cache.change_result(thys =>
    36       {
    39       {
    37         thys.get(thy_name) match {
    40         thys.get(thy_name) match {
   427       Library.separate(HTML.break ::: HTML.nl,
   430       Library.separate(HTML.break ::: HTML.nl,
   428         (deps_link :: readme_links ::: document_links).
   431         (deps_link :: readme_links ::: document_links).
   429           map(link => HTML.text("View ") ::: List(link))).flatten
   432           map(link => HTML.text("View ") ::: List(link))).flatten
   430     }
   433     }
   431 
   434 
   432     val cached_theories: Set[String] = html_context.cached_theories
       
   433     val all_used_theories = hierarchy.flatMap(a => deps(a).used_theories.map(_._1))
   435     val all_used_theories = hierarchy.flatMap(a => deps(a).used_theories.map(_._1))
   434     val present_theories = all_used_theories.filterNot(name => cached_theories.contains(name.theory))
   436     val present_theories = html_context.register_presented(all_used_theories)
   435 
   437 
   436     val theory_exports: Map[String, Export_Theory.Theory] =
   438     val theory_exports: Map[String, Export_Theory.Theory] =
   437       (for (node <- all_used_theories.iterator) yield {
   439       (for (node <- all_used_theories.iterator) yield {
   438         val thy_name = node.theory
   440         val thy_name = node.theory
   439         val theory =
   441         val theory =
   535         html: XML.Tree)
   537         html: XML.Tree)
   536 
   538 
   537       def read_theory(name: Document.Node.Name): Option[Theory] =
   539       def read_theory(name: Document.Node.Name): Option[Theory] =
   538       {
   540       {
   539         progress.expose_interrupt()
   541         progress.expose_interrupt()
   540         if (verbose) progress.echo("Presenting theory " + name)
   542 
   541 
   543         for (command <- Build_Job.read_theory(db_context, resources, hierarchy, name.theory))
   542         for (command <- Build_Job.read_theory(db_context, resources, session, name.theory))
       
   543         yield {
   544         yield {
       
   545           if (verbose) progress.echo("Presenting theory " + name)
   544           val snapshot = Document.State.init.snippet(command)
   546           val snapshot = Document.State.init.snippet(command)
   545 
   547 
   546           val files_html =
   548           val files_html =
   547             for {
   549             for {
   548               (src_path, xml) <- snapshot.xml_markup_blobs(elements = elements.html)
   550               (src_path, xml) <- snapshot.xml_markup_blobs(elements = elements.html)