equal
deleted
inserted
replaced
25 def html_context(fonts_url: String => String = HTML.fonts_url()): HTML_Context = |
25 def html_context(fonts_url: String => String = HTML.fonts_url()): HTML_Context = |
26 new HTML_Context(fonts_url) |
26 new HTML_Context(fonts_url) |
27 |
27 |
28 final class HTML_Context private[Presentation](fonts_url: String => String) |
28 final class HTML_Context private[Presentation](fonts_url: String => String) |
29 { |
29 { |
|
30 private val theory_cache = Synchronized(Map.empty[String, Export_Theory.Theory]) |
|
31 |
|
32 def cache_theory(thy_name: String, make_thy: => Export_Theory.Theory): Export_Theory.Theory = |
|
33 { |
|
34 theory_cache.change_result(thys => |
|
35 { |
|
36 thys.get(thy_name) match { |
|
37 case Some(thy) => (thy, thys) |
|
38 case None => |
|
39 val thy = make_thy |
|
40 (thy, thys + (thy_name -> thy)) |
|
41 } |
|
42 }) |
|
43 } |
|
44 |
30 def init_fonts(dir: Path): Unit = |
45 def init_fonts(dir: Path): Unit = |
31 { |
46 { |
32 val fonts_dir = Isabelle_System.make_directory(dir + fonts_path) |
47 val fonts_dir = Isabelle_System.make_directory(dir + fonts_path) |
33 for (entry <- Isabelle_Fonts.fonts(hidden = true)) |
48 for (entry <- Isabelle_Fonts.fonts(hidden = true)) |
34 Isabelle_System.copy_file(entry.path, fonts_dir) |
49 Isabelle_System.copy_file(entry.path, fonts_dir) |
326 """ + HTML.footer) |
341 """ + HTML.footer) |
327 } |
342 } |
328 } |
343 } |
329 |
344 |
330 |
345 |
331 /* theory cache */ |
|
332 |
|
333 object Theory_Cache |
|
334 { |
|
335 def apply(): Theory_Cache = new Theory_Cache() |
|
336 } |
|
337 |
|
338 class Theory_Cache private() |
|
339 { |
|
340 private val cache = Synchronized(Map.empty[String, Export_Theory.Theory]) |
|
341 |
|
342 def apply(thy_name: String, make_thy: => Export_Theory.Theory): Export_Theory.Theory = |
|
343 { |
|
344 cache.change_result(thys => |
|
345 { |
|
346 thys.get(thy_name) match { |
|
347 case Some(thy) => (thy, thys) |
|
348 case None => |
|
349 val thy = make_thy |
|
350 (thy, thys + (thy_name -> thy)) |
|
351 } |
|
352 }) |
|
353 } |
|
354 } |
|
355 |
|
356 |
|
357 /* present session */ |
346 /* present session */ |
358 |
347 |
359 val session_graph_path = Path.explode("session_graph.pdf") |
348 val session_graph_path = Path.explode("session_graph.pdf") |
360 val readme_path = Path.explode("README.html") |
349 val readme_path = Path.explode("README.html") |
361 val files_path = Path.explode("files") |
350 val files_path = Path.explode("files") |
400 db_context: Sessions.Database_Context, |
389 db_context: Sessions.Database_Context, |
401 progress: Progress = new Progress, |
390 progress: Progress = new Progress, |
402 verbose: Boolean = false, |
391 verbose: Boolean = false, |
403 html_context: HTML_Context, |
392 html_context: HTML_Context, |
404 elements: Elements, |
393 elements: Elements, |
405 presentation: Context, |
394 presentation: Context): Unit = |
406 theory_cache: Theory_Cache = Theory_Cache()): Unit = |
|
407 { |
395 { |
408 val info = deps.sessions_structure(session) |
396 val info = deps.sessions_structure(session) |
409 val options = info.options |
397 val options = info.options |
410 val base = deps(session) |
398 val base = deps(session) |
411 |
399 |
447 } |
435 } |
448 |
436 |
449 def read_theory(thy_name: String): Export_Theory.Theory = |
437 def read_theory(thy_name: String): Export_Theory.Theory = |
450 if (thy_name == Thy_Header.PURE) Export_Theory.no_theory |
438 if (thy_name == Thy_Header.PURE) Export_Theory.no_theory |
451 else { |
439 else { |
452 theory_cache(thy_name, |
440 html_context.cache_theory(thy_name, |
453 { |
441 { |
454 val qualifier = deps(session).theory_qualifier(thy_name) |
442 val qualifier = deps(session).theory_qualifier(thy_name) |
455 val provider = Export.Provider.database_context(db_context, List(qualifier), thy_name) |
443 val provider = Export.Provider.database_context(db_context, List(qualifier), thy_name) |
456 if (Export_Theory.read_theory_parents(provider, thy_name).isDefined) { |
444 if (Export_Theory.read_theory_parents(provider, thy_name).isDefined) { |
457 Export_Theory.read_theory(provider, qualifier, thy_name) |
445 Export_Theory.read_theory(provider, qualifier, thy_name) |