456 val node_name = resources.file_node(Path.explode(thy_file), theory = theory) |
456 val node_name = resources.file_node(Path.explode(thy_file), theory = theory) |
457 theory_link(deps, session, node_name, body) |
457 theory_link(deps, session, node_name, body) |
458 case _ => None |
458 case _ => None |
459 } |
459 } |
460 |
460 |
461 val read_theories = |
461 sealed case class Theory( |
462 Par_List.map[Document.Node.Name, Option[(Document.Node.Name, Command)]]( |
462 name: Document.Node.Name, |
463 name => Build_Job.read_theory(db_context, resources, session, name.theory).map((name, _)), |
463 command: Command, |
464 base.session_theories) |
464 files_html: List[(Path, XML.Tree)], |
465 |
465 html: XML.Tree) |
466 for ((thy_name, thy_command) <- read_theories.flatten) |
466 |
|
467 def read_theory(name: Document.Node.Name): Option[Theory] = |
|
468 { |
|
469 progress.expose_interrupt() |
|
470 |
|
471 for (command <- Build_Job.read_theory(db_context, resources, session, name.theory)) |
|
472 yield { |
|
473 val snapshot = Document.State.init.snippet(command) |
|
474 |
|
475 val files_html = |
|
476 for { |
|
477 (src_path, xml) <- snapshot.xml_markup_blobs(elements = elements.html) |
|
478 if xml.nonEmpty |
|
479 } |
|
480 yield { |
|
481 progress.expose_interrupt() |
|
482 (src_path, html_context.source(make_html(elements, entity_link, xml))) |
|
483 } |
|
484 |
|
485 val html = |
|
486 html_context.source( |
|
487 make_html(elements, entity_link, snapshot.xml_markup(elements = elements.html))) |
|
488 |
|
489 Theory(name, command, files_html, html) |
|
490 } |
|
491 } |
|
492 |
|
493 for (thy <- Par_List.map(read_theory, base.session_theories).flatten) |
467 yield { |
494 yield { |
468 progress.expose_interrupt() |
495 if (verbose) progress.echo("Presenting theory " + thy.name) |
469 if (verbose) progress.echo("Presenting theory " + thy_name) |
|
470 |
|
471 val snapshot = Document.State.init.snippet(thy_command) |
|
472 |
496 |
473 val files = |
497 val files = |
474 for { |
498 for { (src_path, file_html) <- thy.files_html } |
475 (src_path, xml) <- snapshot.xml_markup_blobs(elements = elements.html) |
|
476 if xml.nonEmpty |
|
477 } |
|
478 yield { |
499 yield { |
479 progress.expose_interrupt() |
|
480 if (verbose) progress.echo("Presenting file " + src_path) |
500 if (verbose) progress.echo("Presenting file " + src_path) |
481 |
501 |
482 val file_name = (files_path + src_path.squash.html).implode |
502 val file_name = (files_path + src_path.squash.html).implode |
483 |
503 |
484 seen_files.find(p => p._1 == src_path || p._2 == file_name) match { |
504 seen_files.find(p => p._1 == src_path || p._2 == file_name) match { |
485 case None => seen_files ::= (src_path, file_name, thy_name) |
505 case None => seen_files ::= (src_path, file_name, thy.name) |
486 case Some((_, _, thy_name1)) => |
506 case Some((_, _, thy_name1)) => |
487 error("Incoherent use of file name " + src_path + " as " + quote(file_name) + |
507 error("Incoherent use of file name " + src_path + " as " + quote(file_name) + |
488 " in theory " + thy_name1 + " vs. " + thy_name) |
508 " in theory " + thy_name1 + " vs. " + thy.name) |
489 } |
509 } |
490 |
510 |
491 val file_path = session_dir + Path.explode(file_name) |
511 val file_path = session_dir + Path.explode(file_name) |
492 html_context.init_fonts(file_path.dir) |
512 html_context.init_fonts(file_path.dir) |
493 |
513 |
494 val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short) |
514 val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short) |
495 HTML.write_document(file_path.dir, file_path.file_name, |
515 HTML.write_document(file_path.dir, file_path.file_name, |
496 List(HTML.title(file_title)), |
516 List(HTML.title(file_title)), List(html_context.head(file_title), file_html)) |
497 List(html_context.head(file_title), |
|
498 html_context.source(make_html(elements, entity_link, xml)))) |
|
499 |
517 |
500 List(HTML.link(file_name, HTML.text(file_title))) |
518 List(HTML.link(file_name, HTML.text(file_title))) |
501 } |
519 } |
502 |
520 |
503 val thy_title = "Theory " + thy_name.theory_base_name |
521 val thy_title = "Theory " + thy.name.theory_base_name |
504 val thy_body = make_html(elements, entity_link, snapshot.xml_markup(elements = elements.html)) |
522 |
505 HTML.write_document(session_dir, html_name(thy_name), |
523 HTML.write_document(session_dir, html_name(thy.name), |
506 List(HTML.title(thy_title)), |
524 List(HTML.title(thy_title)), List(html_context.head(thy_title), thy.html)) |
507 List(html_context.head(thy_title), html_context.source(thy_body))) |
525 |
508 |
526 List(HTML.link(html_name(thy.name), |
509 List(HTML.link(html_name(thy_name), |
527 HTML.text(thy.name.theory_base_name) ::: |
510 HTML.text(thy_name.theory_base_name) ::: |
|
511 (if (files.isEmpty) Nil else List(HTML.itemize(files))))) |
528 (if (files.isEmpty) Nil else List(HTML.itemize(files))))) |
512 } |
529 } |
513 } |
530 } |
514 |
531 |
515 val title = "Session " + session |
532 val title = "Session " + session |