src/Pure/Thy/presentation.scala
changeset 75898 122648e3effb
parent 75897 989847d1ebab
child 75899 d50c2129e73a
equal deleted inserted replaced
75897:989847d1ebab 75898:122648e3effb
   576       Library.separate(HTML.break ::: HTML.nl,
   576       Library.separate(HTML.break ::: HTML.nl,
   577         (deps_link :: readme_links ::: document_links).
   577         (deps_link :: readme_links ::: document_links).
   578           map(link => HTML.text("View ") ::: List(link))).flatten
   578           map(link => HTML.text("View ") ::: List(link))).flatten
   579     }
   579     }
   580 
   580 
   581     sealed case class Seen_File(
       
   582       src_path: Path,
       
   583       thy_name: Document.Node.Name,
       
   584       thy_session: String
       
   585     ) {
       
   586       val files_path: Path = html_context.files_path(thy_name, src_path)
       
   587 
       
   588       def check(src_path1: Path, thy_name1: Document.Node.Name, thy_session1: String): Boolean = {
       
   589         val files_path1 = html_context.files_path(thy_name1, src_path1)
       
   590         (src_path == src_path1 || files_path == files_path1) && thy_session == thy_session1
       
   591       }
       
   592     }
       
   593     var seen_files = List.empty[Seen_File]
       
   594 
       
   595     def present_theory(name: Document.Node.Name): Option[XML.Body] = {
   581     def present_theory(name: Document.Node.Name): Option[XML.Body] = {
   596       progress.expose_interrupt()
   582       progress.expose_interrupt()
   597 
   583 
   598       Build_Job.read_theory(session_context.theory(name.theory)).flatMap { command =>
   584       Build_Job.read_theory(session_context.theory(name.theory)).flatMap { command =>
   599         if (verbose) progress.echo("Presenting theory " + name)
   585         if (verbose) progress.echo("Presenting theory " + name)
   622         val thy_session = html_context.theory_session(name)
   608         val thy_session = html_context.theory_session(name)
   623         val thy_dir = Isabelle_System.make_directory(html_context.theory_dir(name))
   609         val thy_dir = Isabelle_System.make_directory(html_context.theory_dir(name))
   624         val files =
   610         val files =
   625           for { (src_path, file_html) <- files_html }
   611           for { (src_path, file_html) <- files_html }
   626             yield {
   612             yield {
   627               seen_files.find(_.check(src_path, name, thy_session)) match {
       
   628                 case None => seen_files ::= Seen_File(src_path, name, thy_session)
       
   629                 case Some(seen_file) =>
       
   630                   error("Incoherent use of file name " + src_path + " as " + files_path(src_path) +
       
   631                     " in theory " + seen_file.thy_name + " vs. " + name)
       
   632               }
       
   633 
       
   634               val file_path = html_context.files_path(name, src_path)
   613               val file_path = html_context.files_path(name, src_path)
   635               val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short)
   614               val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short)
   636               HTML.write_document(file_path.dir, file_path.file_name,
   615               HTML.write_document(file_path.dir, file_path.file_name,
   637                 List(HTML.title(file_title)), List(html_context.head(file_title), file_html),
   616                 List(HTML.title(file_title)), List(html_context.head(file_title), file_html),
   638                 base = Some(html_context.root_dir))
   617                 base = Some(html_context.root_dir))