author | wenzelm |
Sat, 06 Nov 2021 18:16:54 +0100 | |
changeset 74716 | 056de3681cb9 |
parent 74715 | 129fb11b357f |
child 74717 | baed95c97505 |
permissions | -rw-r--r-- |
73718 | 1 |
/* Title: Pure/Thy/presentation.scala |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
3 |
|
73718 | 4 |
HTML presentation of PIDE document content. |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
6 |
|
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
8 |
|
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
9 |
|
74677 | 10 |
import scala.annotation.tailrec |
51402 | 11 |
import scala.collection.immutable.SortedMap |
74677 | 12 |
import scala.collection.mutable |
51402 | 13 |
|
14 |
||
72652 | 15 |
object Presentation |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
16 |
{ |
72957 | 17 |
/** HTML documents **/ |
18 |
||
73718 | 19 |
/* HTML context */ |
20 |
||
72957 | 21 |
sealed case class HTML_Document(title: String, content: String) |
22 |
||
74709 | 23 |
def html_context(): HTML_Context = new HTML_Context |
72959 | 24 |
|
74709 | 25 |
final class HTML_Context private[Presentation] |
72959 | 26 |
{ |
74706 | 27 |
val term_cache: Term.Cache = Term.Cache.make() |
28 |
||
74712 | 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))) |
|
74697 | 34 |
|
74712 | 35 |
private val theory_cache = Synchronized(Map.empty[String, Export_Theory.Theory]) |
74697 | 36 |
def cache_theory(thy_name: String, make_thy: => Export_Theory.Theory): Export_Theory.Theory = |
37 |
{ |
|
38 |
theory_cache.change_result(thys => |
|
39 |
{ |
|
40 |
thys.get(thy_name) match { |
|
41 |
case Some(thy) => (thy, thys) |
|
42 |
case None => |
|
43 |
val thy = make_thy |
|
44 |
(thy, thys + (thy_name -> thy)) |
|
45 |
} |
|
46 |
}) |
|
47 |
} |
|
48 |
||
72962 | 49 |
def head(title: String, rest: XML.Body = Nil): XML.Tree = |
50 |
HTML.div("head", HTML.chapter(title) :: rest) |
|
51 |
||
52 |
def source(body: XML.Body): XML.Tree = HTML.pre("source", body) |
|
53 |
||
74713 | 54 |
def physical_ref(range: Text.Range): String = |
55 |
"offset_" + range.start + ".." + range.stop |
|
74677 | 56 |
|
72962 | 57 |
def contents(heading: String, items: List[XML.Body], css_class: String = "contents") |
58 |
: List[XML.Elem] = |
|
59 |
{ |
|
60 |
if (items.isEmpty) Nil |
|
61 |
else List(HTML.div(css_class, List(HTML.section(heading), HTML.itemize(items)))) |
|
62 |
} |
|
63 |
||
74709 | 64 |
def html_document(title: String, body: XML.Body, fonts_css: String): HTML_Document = |
65 |
{ |
|
66 |
val content = |
|
67 |
HTML.output_document( |
|
68 |
List( |
|
69 |
HTML.style(fonts_css + "\n\n" + File.read(HTML.isabelle_css)), |
|
70 |
HTML.title(title)), |
|
71 |
List(HTML.source(body)), css = "", structural = false) |
|
72 |
HTML_Document(title, content) |
|
73 |
} |
|
72959 | 74 |
} |
75 |
||
72957 | 76 |
|
73055 | 77 |
/* presentation elements */ |
78 |
||
79 |
sealed case class Elements( |
|
80 |
html: Markup.Elements = Markup.Elements.empty, |
|
73056 | 81 |
entity: Markup.Elements = Markup.Elements.empty, |
73055 | 82 |
language: Markup.Elements = Markup.Elements.empty) |
72957 | 83 |
|
73055 | 84 |
val elements1: Elements = |
85 |
Elements( |
|
74677 | 86 |
html = Rendering.foreground_elements ++ Rendering.text_color_elements + |
73056 | 87 |
Markup.NUMERAL + Markup.COMMENT + Markup.ENTITY + Markup.LANGUAGE, |
74715
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
88 |
entity = Markup.Elements(Markup.THEORY, Markup.FREE)) |
73036 | 89 |
|
73055 | 90 |
val elements2: Elements = |
91 |
Elements( |
|
92 |
html = elements1.html ++ Rendering.markdown_elements, |
|
73056 | 93 |
language = Markup.Elements(Markup.Language.DOCUMENT)) |
73055 | 94 |
|
74678 | 95 |
|
96 |
/* formal entities */ |
|
74677 | 97 |
|
98 |
type Entity = Export_Theory.Entity[Export_Theory.No_Content] |
|
99 |
||
100 |
case class Entity_Context(node: Document.Node.Name) |
|
101 |
{ |
|
102 |
val seen_ranges: mutable.Set[Symbol.Range] = mutable.Set.empty |
|
103 |
} |
|
73055 | 104 |
|
74678 | 105 |
|
73718 | 106 |
/* HTML output */ |
73036 | 107 |
|
72957 | 108 |
private val div_elements = |
109 |
Set(HTML.div.name, HTML.pre.name, HTML.par.name, HTML.list.name, HTML.enum.name, |
|
110 |
HTML.descr.name) |
|
111 |
||
73056 | 112 |
def make_html( |
74677 | 113 |
name: Document.Node.Name, |
73056 | 114 |
elements: Elements, |
74677 | 115 |
entity_anchor: (Entity_Context, Symbol.Range, XML.Body) => Option[XML.Tree], |
116 |
entity_link: (Entity_Context, Properties.T, XML.Body) => Option[XML.Tree], |
|
73056 | 117 |
xml: XML.Body): XML.Body = |
73054 | 118 |
{ |
74677 | 119 |
val context = Entity_Context(name) |
120 |
||
73054 | 121 |
def html_div(html: XML.Body): Boolean = |
122 |
html exists { |
|
123 |
case XML.Elem(markup, body) => div_elements.contains(markup.name) || html_div(body) |
|
124 |
case XML.Text(_) => false |
|
125 |
} |
|
72957 | 126 |
|
73055 | 127 |
def html_class(c: String, html: XML.Body): XML.Body = |
128 |
if (c == "") html |
|
129 |
else if (html_div(html)) List(HTML.div(c, html)) |
|
130 |
else List(HTML.span(c, html)) |
|
72957 | 131 |
|
74677 | 132 |
def html_body(xml_body: XML.Body, end_offset: Symbol.Offset): (XML.Body, Symbol.Offset) = |
133 |
xml_body.foldRight((List.empty[XML.Tree], end_offset)) { case (tree, (res, end_offset1)) => |
|
134 |
val (res1, offset) = html_body_single(tree, end_offset1) |
|
135 |
(res1 ++ res, offset) |
|
136 |
} |
|
137 |
||
138 |
@tailrec |
|
139 |
def html_body_single(xml_tree: XML.Tree, end_offset: Symbol.Offset): (XML.Body, Symbol.Offset) = |
|
140 |
xml_tree match { |
|
141 |
case XML.Wrapped_Elem(markup, _, body) => html_body_single(XML.Elem(markup, body), end_offset) |
|
73056 | 142 |
case XML.Elem(Markup(Markup.ENTITY, props @ Markup.Kind(kind)), body) => |
74677 | 143 |
val (body1, offset) = html_body(body, end_offset) |
73056 | 144 |
if (elements.entity(kind)) { |
74677 | 145 |
entity_link(context, props, body1) match { |
146 |
case Some(link) => (List(link), offset) |
|
147 |
case None => (body1, offset) |
|
73056 | 148 |
} |
149 |
} |
|
74677 | 150 |
else (body1, offset) |
73055 | 151 |
case XML.Elem(Markup(Markup.LANGUAGE, Markup.Name(name)), body) => |
74677 | 152 |
val (body1, offset) = html_body(body, end_offset) |
153 |
(html_class(if (elements.language(name)) name else "", body1), offset) |
|
73055 | 154 |
case XML.Elem(Markup(Markup.MARKDOWN_PARAGRAPH, _), body) => |
74677 | 155 |
val (body1, offset) = html_body(body, end_offset) |
156 |
(List(HTML.par(body1)), offset) |
|
73055 | 157 |
case XML.Elem(Markup(Markup.MARKDOWN_ITEM, _), body) => |
74677 | 158 |
val (body1, offset) = html_body(body, end_offset) |
159 |
(List(HTML.item(body1)), offset) |
|
160 |
case XML.Elem(Markup(Markup.Markdown_Bullet.name, _), text) => |
|
74683
c8327efc7af1
clarified signature: more direct XML.symbol_length;
wenzelm
parents:
74682
diff
changeset
|
161 |
(Nil, end_offset - XML.symbol_length(text)) |
73054 | 162 |
case XML.Elem(Markup.Markdown_List(kind), body) => |
74677 | 163 |
val (body1, offset) = html_body(body, end_offset) |
164 |
if (kind == Markup.ENUMERATE) (List(HTML.enum(body1)), offset) |
|
165 |
else (List(HTML.list(body1)), offset) |
|
73054 | 166 |
case XML.Elem(markup, body) => |
167 |
val name = markup.name |
|
74677 | 168 |
val (body1, offset) = html_body(body, end_offset) |
73054 | 169 |
val html = |
170 |
markup.properties match { |
|
171 |
case Markup.Kind(kind) if kind == Markup.COMMAND || kind == Markup.KEYWORD => |
|
74677 | 172 |
html_class(kind, body1) |
73054 | 173 |
case _ => |
74677 | 174 |
body1 |
73054 | 175 |
} |
176 |
Rendering.foreground.get(name) orElse Rendering.text_color.get(name) match { |
|
74677 | 177 |
case Some(c) => (html_class(c.toString, html), offset) |
178 |
case None => (html_class(name, html), offset) |
|
72957 | 179 |
} |
73054 | 180 |
case XML.Text(text) => |
74682
ce4adcc85f6c
more direct Symbol.length: Symbol.decode is redundant, symbol counts are invariant under it;
wenzelm
parents:
74679
diff
changeset
|
181 |
val offset = end_offset - Symbol.length(text) |
ce4adcc85f6c
more direct Symbol.length: Symbol.decode is redundant, symbol counts are invariant under it;
wenzelm
parents:
74679
diff
changeset
|
182 |
val body = HTML.text(Symbol.decode(text)) |
74677 | 183 |
entity_anchor(context, Text.Range(offset, end_offset), body) match { |
184 |
case Some(body1) => (List(body1), offset) |
|
185 |
case None => (body, offset) |
|
186 |
} |
|
73054 | 187 |
} |
188 |
||
74683
c8327efc7af1
clarified signature: more direct XML.symbol_length;
wenzelm
parents:
74682
diff
changeset
|
189 |
html_body(xml, XML.symbol_length(xml) + 1)._1 |
73054 | 190 |
} |
72957 | 191 |
|
192 |
||
193 |
/* PIDE HTML document */ |
|
194 |
||
195 |
def html_document( |
|
196 |
resources: Resources, |
|
197 |
snapshot: Document.Snapshot, |
|
72962 | 198 |
html_context: HTML_Context, |
73055 | 199 |
elements: Elements, |
74709 | 200 |
plain_text: Boolean = false, |
201 |
fonts_css: String = HTML.fonts_css()): HTML_Document = |
|
72957 | 202 |
{ |
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73059
diff
changeset
|
203 |
require(!snapshot.is_outdated, "document snapshot outdated") |
72957 | 204 |
|
205 |
val name = snapshot.node_name |
|
206 |
if (plain_text) { |
|
72962 | 207 |
val title = "File " + Symbol.cartouche_decoded(name.path.file_name) |
72959 | 208 |
val body = HTML.text(snapshot.node.source) |
74709 | 209 |
html_context.html_document(title, body, fonts_css) |
72957 | 210 |
} |
211 |
else { |
|
72962 | 212 |
resources.html_document(snapshot) getOrElse { |
213 |
val title = |
|
214 |
if (name.is_theory) "Theory " + quote(name.theory_base_name) |
|
215 |
else "File " + Symbol.cartouche_decoded(name.path.file_name) |
|
74677 | 216 |
val xml = snapshot.xml_markup(elements = elements.html) |
217 |
val body = make_html(name, elements, (_, _, _) => None, (_, _, _) => None, xml) |
|
74709 | 218 |
html_context.html_document(title, body, fonts_css) |
72957 | 219 |
} |
220 |
} |
|
221 |
} |
|
222 |
||
223 |
||
224 |
||
73718 | 225 |
/** HTML presentation **/ |
72649 | 226 |
|
72648 | 227 |
/* presentation context */ |
228 |
||
229 |
object Context |
|
230 |
{ |
|
231 |
val none: Context = new Context { def enabled: Boolean = false } |
|
232 |
val standard: Context = new Context { def enabled: Boolean = true } |
|
233 |
||
234 |
def dir(path: Path): Context = |
|
235 |
new Context { |
|
236 |
def enabled: Boolean = true |
|
237 |
override def dir(store: Sessions.Store): Path = path |
|
238 |
} |
|
239 |
||
240 |
def make(s: String): Context = |
|
241 |
if (s == ":") standard else dir(Path.explode(s)) |
|
242 |
} |
|
243 |
||
244 |
abstract class Context private |
|
245 |
{ |
|
246 |
def enabled: Boolean |
|
247 |
def enabled(info: Sessions.Info): Boolean = enabled || info.browser_info |
|
248 |
def dir(store: Sessions.Store): Path = store.presentation_dir |
|
249 |
def dir(store: Sessions.Store, info: Sessions.Info): Path = |
|
72670 | 250 |
dir(store) + Path.explode(info.chapter_session) |
72648 | 251 |
} |
252 |
||
253 |
||
72955
942bf91545fa
clarified comments: file-system access is always unsynchronized;
wenzelm
parents:
72882
diff
changeset
|
254 |
/* maintain chapter index */ |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
255 |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
256 |
private val sessions_path = Path.basic(".sessions") |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
257 |
|
51402 | 258 |
private def read_sessions(dir: Path): List[(String, String)] = |
259 |
{ |
|
51416 | 260 |
val path = dir + sessions_path |
261 |
if (path.is_file) { |
|
262 |
import XML.Decode._ |
|
65344
b99283eed13c
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65089
diff
changeset
|
263 |
list(pair(string, string))(Symbol.decode_yxml(File.read(path))) |
51416 | 264 |
} |
265 |
else Nil |
|
51402 | 266 |
} |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
267 |
|
74709 | 268 |
def update_chapter( |
74699 | 269 |
presentation_dir: Path, chapter: String, new_sessions: List[(String, String)]): Unit = |
51402 | 270 |
{ |
74699 | 271 |
val dir = Isabelle_System.make_directory(presentation_dir + Path.basic(chapter)) |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
272 |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
273 |
val sessions0 = |
51406
950b897f95bb
proper path -- I/O was hidden due to permissiveness;
wenzelm
parents:
51402
diff
changeset
|
274 |
try { read_sessions(dir) } |
51987 | 275 |
catch { case _: XML.Error => Nil } |
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
276 |
|
51402 | 277 |
val sessions = (SortedMap.empty[String, String] ++ sessions0 ++ new_sessions).toList |
74699 | 278 |
File.write(dir + sessions_path, |
279 |
{ |
|
280 |
import XML.Encode._ |
|
281 |
YXML.string_of_body(list(pair(string, string))(sessions)) |
|
282 |
}) |
|
51402 | 283 |
|
65988 | 284 |
val title = "Isabelle/" + chapter + " sessions" |
285 |
HTML.write_document(dir, "index.html", |
|
73523
2cd23d587db9
further clarification of Isabelle distribution identification -- avoid odd patching of sources;
wenzelm
parents:
73474
diff
changeset
|
286 |
List(HTML.title(title + Isabelle_System.isabelle_heading())), |
65988 | 287 |
HTML.chapter(title) :: |
288 |
(if (sessions.isEmpty) Nil |
|
289 |
else |
|
65992 | 290 |
List(HTML.div("sessions", |
291 |
List(HTML.description( |
|
65988 | 292 |
sessions.map({ case (name, description) => |
69318 | 293 |
val descr = Symbol.trim_blank_lines(description) |
65989 | 294 |
(List(HTML.link(name + "/index.html", HTML.text(name))), |
69318 | 295 |
if (descr == "") Nil |
74709 | 296 |
else HTML.break ::: List(HTML.pre(HTML.text(descr)))) })))))), |
297 |
base = Some(presentation_dir)) |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
298 |
} |
61372 | 299 |
|
74709 | 300 |
def update_root(presentation_dir: Path): Unit = |
61372 | 301 |
{ |
74700
decf8b66e2fb
more thorough update_global_index: overwrite old content;
wenzelm
parents:
74699
diff
changeset
|
302 |
Isabelle_System.make_directory(presentation_dir) |
74709 | 303 |
HTML.init_fonts(presentation_dir) |
74700
decf8b66e2fb
more thorough update_global_index: overwrite old content;
wenzelm
parents:
74699
diff
changeset
|
304 |
Isabelle_System.copy_file(Path.explode("~~/lib/logo/isabelle.gif"), |
decf8b66e2fb
more thorough update_global_index: overwrite old content;
wenzelm
parents:
74699
diff
changeset
|
305 |
presentation_dir + Path.explode("isabelle.gif")) |
decf8b66e2fb
more thorough update_global_index: overwrite old content;
wenzelm
parents:
74699
diff
changeset
|
306 |
val title = "The " + XML.text(Isabelle_System.isabelle_name()) + " Library" |
decf8b66e2fb
more thorough update_global_index: overwrite old content;
wenzelm
parents:
74699
diff
changeset
|
307 |
File.write(presentation_dir + Path.explode("index.html"), |
decf8b66e2fb
more thorough update_global_index: overwrite old content;
wenzelm
parents:
74699
diff
changeset
|
308 |
HTML.header + |
73529 | 309 |
""" |
73528
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
310 |
<head> |
73529 | 311 |
""" + HTML.head_meta + """ |
73528
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
312 |
<title>""" + title + """</title> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
313 |
</head> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
314 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
315 |
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#000099" alink="#404040"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
316 |
<center> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
317 |
<table width="100%" border="0" cellspacing="10" cellpadding="0"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
318 |
<tr> |
74676 | 319 |
<td width="20%" valign="middle" align="center"><a href="https://isabelle.in.tum.de/"><img align="bottom" src="isabelle.gif" width="100" height="86" alt="[Isabelle]" border="0" /></a></td> |
73528
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
320 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
321 |
<td width="80%" valign="middle" align="center"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
322 |
<table width="90%" border="0" cellspacing="0" cellpadding="20"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
323 |
<tr> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
324 |
<td valign="middle" align="center" bgcolor="#AACCCC"><font face="Helvetica,Arial" size="+2">""" + title + """</font></td> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
325 |
</tr> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
326 |
</table> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
327 |
</td> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
328 |
</tr> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
329 |
</table> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
330 |
</center> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
331 |
<hr /> |
74670
b2604cd4d131
recover library_index_content.template from c337c798f64c: required for website/build/main;
wenzelm
parents:
73718
diff
changeset
|
332 |
""" + File.read(Path.explode("~~/lib/html/library_index_content.template")) + |
b2604cd4d131
recover library_index_content.template from c337c798f64c: required for website/build/main;
wenzelm
parents:
73718
diff
changeset
|
333 |
""" |
73528
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
334 |
</body> |
73529 | 335 |
""" + HTML.footer) |
61372 | 336 |
} |
337 |
||
338 |
||
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
339 |
/* present session */ |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
340 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
341 |
val session_graph_path = Path.explode("session_graph.pdf") |
72959 | 342 |
val readme_path = Path.explode("README.html") |
343 |
val files_path = Path.explode("files") |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
344 |
|
74677 | 345 |
def html_name(name: Document.Node.Name): String = Path.explode(name.theory_base_name).html.implode |
346 |
def html_path(path: Path): String = (files_path + path.squash.html).implode |
|
347 |
||
348 |
def session_relative(deps: Sessions.Deps, session0: String, session1: String): Option[String] = |
|
349 |
{ |
|
350 |
for { |
|
351 |
info0 <- deps.sessions_structure.get(session0) |
|
352 |
info1 <- deps.sessions_structure.get(session1) |
|
353 |
} yield info0.relative_path(info1) |
|
354 |
} |
|
355 |
||
356 |
def node_relative( |
|
357 |
deps: Sessions.Deps, |
|
358 |
session0: String, |
|
359 |
node_name: Document.Node.Name): Option[String] = |
|
360 |
{ |
|
361 |
val session1 = deps(session0).theory_qualifier(node_name) |
|
362 |
session_relative(deps, session0, session1) |
|
363 |
} |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
364 |
|
73042 | 365 |
def theory_link(deps: Sessions.Deps, session0: String, |
74677 | 366 |
name: Document.Node.Name, body: XML.Body, anchor: Option[String] = None): Option[XML.Tree] = |
73042 | 367 |
{ |
368 |
val session1 = deps(session0).theory_qualifier(name) |
|
73057 | 369 |
val info0 = deps.sessions_structure.get(session0) |
370 |
val info1 = deps.sessions_structure.get(session1) |
|
74677 | 371 |
val fragment = if (anchor.isDefined) "#" + anchor.get else "" |
73057 | 372 |
if (info0.isDefined && info1.isDefined) { |
74677 | 373 |
Some(HTML.link(info0.get.relative_path(info1.get) + html_name(name) + fragment, body)) |
73057 | 374 |
} |
375 |
else None |
|
73042 | 376 |
} |
377 |
||
72648 | 378 |
def session_html( |
72962 | 379 |
resources: Resources, |
72648 | 380 |
session: String, |
381 |
deps: Sessions.Deps, |
|
72683 | 382 |
db_context: Sessions.Database_Context, |
72992 | 383 |
progress: Progress = new Progress, |
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
384 |
verbose: Boolean = false, |
72962 | 385 |
html_context: HTML_Context, |
74715
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
386 |
session_elements: Elements, |
74697 | 387 |
presentation: Context): Unit = |
61372 | 388 |
{ |
74703
9d7f95c43584
observer proper session hierarchy (according to build_graph): thus exported artifacts are always valid;
wenzelm
parents:
74702
diff
changeset
|
389 |
val hierarchy = deps.sessions_structure.hierarchy(session) |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
390 |
val info = deps.sessions_structure(session) |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
391 |
val options = info.options |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
392 |
val base = deps(session) |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
393 |
|
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
394 |
def make_session_dir(name: String): Path = |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
395 |
Isabelle_System.make_directory( |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
396 |
presentation.dir(db_context.store, deps.sessions_structure(name))) |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
397 |
|
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
398 |
val session_dir = make_session_dir(session) |
74709 | 399 |
val presentation_dir = presentation.dir(db_context.store) |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
400 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
401 |
Bytes.write(session_dir + session_graph_path, |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
402 |
graphview.Graph_File.make_pdf(options, base.session_graph_display)) |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
403 |
|
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
404 |
val documents = |
72683 | 405 |
for { |
406 |
doc <- info.document_variants |
|
73718 | 407 |
document <- db_context.input_database(session)(Document_Build.read_document(_, _, doc.name)) |
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
408 |
} yield { |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
409 |
if (verbose) progress.echo("Presenting document " + session + "/" + doc.name) |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
410 |
Bytes.write(session_dir + doc.path.pdf, document.pdf) |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
411 |
doc |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
412 |
} |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
413 |
|
73041 | 414 |
val view_links = |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
415 |
{ |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
416 |
val deps_link = |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
417 |
HTML.link(session_graph_path, HTML.text("theory dependencies")) |
61372 | 418 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
419 |
val readme_links = |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
420 |
if ((info.dir + readme_path).is_file) { |
73317 | 421 |
Isabelle_System.copy_file(info.dir + readme_path, session_dir + readme_path) |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
422 |
List(HTML.link(readme_path, HTML.text("README"))) |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
423 |
} |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
424 |
else Nil |
62971
087e36ce0593
back to exact copy of non-text file (amending dcc8e1d34b18);
wenzelm
parents:
62631
diff
changeset
|
425 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
426 |
val document_links = |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
427 |
documents.map(doc => HTML.link(doc.path.pdf, HTML.text(doc.name))) |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
428 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
429 |
Library.separate(HTML.break ::: HTML.nl, |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
430 |
(deps_link :: readme_links ::: document_links). |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
431 |
map(link => HTML.text("View ") ::: List(link))).flatten |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
432 |
} |
62971
087e36ce0593
back to exact copy of non-text file (amending dcc8e1d34b18);
wenzelm
parents:
62631
diff
changeset
|
433 |
|
74711
eb89b3a37826
proper used_theories for session build hierarchy, not known_theories from imported sessions;
wenzelm
parents:
74710
diff
changeset
|
434 |
val all_used_theories = hierarchy.flatMap(a => deps(a).used_theories.map(_._1)) |
74712 | 435 |
val present_theories = html_context.register_presented(all_used_theories) |
74711
eb89b3a37826
proper used_theories for session build hierarchy, not known_theories from imported sessions;
wenzelm
parents:
74710
diff
changeset
|
436 |
|
74707 | 437 |
val theory_exports: Map[String, Export_Theory.Theory] = |
74711
eb89b3a37826
proper used_theories for session build hierarchy, not known_theories from imported sessions;
wenzelm
parents:
74710
diff
changeset
|
438 |
(for (node <- all_used_theories.iterator) yield { |
eb89b3a37826
proper used_theories for session build hierarchy, not known_theories from imported sessions;
wenzelm
parents:
74710
diff
changeset
|
439 |
val thy_name = node.theory |
74702 | 440 |
val theory = |
441 |
if (thy_name == Thy_Header.PURE) Export_Theory.no_theory |
|
442 |
else { |
|
443 |
html_context.cache_theory(thy_name, |
|
444 |
{ |
|
74706 | 445 |
val provider = Export.Provider.database_context(db_context, hierarchy, thy_name) |
74716
056de3681cb9
back to non-strict Export_Theory.read_theory (without warning): theories could have been skipped due to "condition";
wenzelm
parents:
74715
diff
changeset
|
446 |
if (Export_Theory.read_theory_parents(provider, thy_name).isDefined) { |
056de3681cb9
back to non-strict Export_Theory.read_theory (without warning): theories could have been skipped due to "condition";
wenzelm
parents:
74715
diff
changeset
|
447 |
Export_Theory.read_theory( |
056de3681cb9
back to non-strict Export_Theory.read_theory (without warning): theories could have been skipped due to "condition";
wenzelm
parents:
74715
diff
changeset
|
448 |
provider, session, thy_name, cache = html_context.term_cache) |
056de3681cb9
back to non-strict Export_Theory.read_theory (without warning): theories could have been skipped due to "condition";
wenzelm
parents:
74715
diff
changeset
|
449 |
} |
056de3681cb9
back to non-strict Export_Theory.read_theory (without warning): theories could have been skipped due to "condition";
wenzelm
parents:
74715
diff
changeset
|
450 |
else Export_Theory.no_theory |
74702 | 451 |
}) |
452 |
} |
|
453 |
thy_name -> theory |
|
454 |
}).toMap |
|
74677 | 455 |
|
72989 | 456 |
val theories: List[XML.Body] = |
72962 | 457 |
{ |
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
458 |
sealed case class Seen_File( |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
459 |
src_path: Path, file_name: String, thy_session: String, thy_name: Document.Node.Name) |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
460 |
{ |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
461 |
def check(src_path1: Path, file_name1: String, thy_session1: String): Boolean = |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
462 |
(src_path == src_path1 || file_name == file_name1) && thy_session == thy_session1 |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
463 |
} |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
464 |
var seen_files = List.empty[Seen_File] |
73056 | 465 |
|
74678 | 466 |
def node_file(node: Document.Node.Name): String = |
74677 | 467 |
if (node.node.endsWith(".thy")) html_name(node) else html_path(Path.explode(node.node)) |
468 |
||
74678 | 469 |
def entity_anchor( |
470 |
context: Entity_Context, range: Symbol.Range, body: XML.Body): Option[XML.Elem] = |
|
74677 | 471 |
{ |
472 |
body match { |
|
473 |
case List(XML.Elem(Markup("span", List("id" -> _)), _)) => None |
|
474 |
case _ => |
|
475 |
Some { |
|
74704 | 476 |
val entities = |
74707 | 477 |
theory_exports.get(context.node.theory).flatMap(_.entity_by_range.get(range)) |
74704 | 478 |
.getOrElse(Nil) |
74678 | 479 |
val body1 = |
480 |
if (context.seen_ranges.contains(range)) { |
|
74713 | 481 |
HTML.entity_def(HTML.span(HTML.id(html_context.physical_ref(range)), body)) |
74678 | 482 |
} |
483 |
else HTML.span(body) |
|
74705
909afe2361b1
prefer "NAME|KIND" format, as already used in Isabelle/MMT and Isabelle/Dedukti;
wenzelm
parents:
74704
diff
changeset
|
484 |
entities.map(_.kname).foldLeft(body1) { |
74704 | 485 |
case (elem, id) => HTML.entity_def(HTML.span(HTML.id(id), List(elem))) |
74677 | 486 |
} |
487 |
} |
|
488 |
} |
|
489 |
} |
|
490 |
||
74713 | 491 |
def logical_ref(thy_name: String, kind: String, name: String): Option[String] = |
74694
2d9d92116fac
clarified Theory_Cache: prefer immutable data with Synchronized variable;
wenzelm
parents:
74693
diff
changeset
|
492 |
for { |
74707 | 493 |
thy <- theory_exports.get(thy_name) |
74708 | 494 |
entity <- thy.entity_by_kind_name.get((kind, name)) |
74705
909afe2361b1
prefer "NAME|KIND" format, as already used in Isabelle/MMT and Isabelle/Dedukti;
wenzelm
parents:
74704
diff
changeset
|
495 |
} yield entity.kname |
74677 | 496 |
|
74713 | 497 |
def physical_ref( |
498 |
context: Entity_Context, thy_name: String, props: Properties.T): Option[String] = |
|
74678 | 499 |
{ |
74714 | 500 |
for { |
501 |
range <- Position.Def_Range.unapply(props) |
|
502 |
if thy_name == context.node.theory |
|
503 |
} yield { |
|
504 |
context.seen_ranges += range |
|
505 |
html_context.physical_ref(range) |
|
74694
2d9d92116fac
clarified Theory_Cache: prefer immutable data with Synchronized variable;
wenzelm
parents:
74693
diff
changeset
|
506 |
} |
74677 | 507 |
} |
508 |
||
74678 | 509 |
def entity_link( |
510 |
context: Entity_Context, props: Properties.T, body: XML.Body): Option[XML.Elem] = |
|
74677 | 511 |
{ |
74694
2d9d92116fac
clarified Theory_Cache: prefer immutable data with Synchronized variable;
wenzelm
parents:
74693
diff
changeset
|
512 |
(props, props, props, props, props) match { |
2d9d92116fac
clarified Theory_Cache: prefer immutable data with Synchronized variable;
wenzelm
parents:
74693
diff
changeset
|
513 |
case (Markup.Kind(Markup.THEORY), Markup.Name(theory), Position.Def_File(thy_file), _, _) => |
73057 | 514 |
val node_name = resources.file_node(Path.explode(thy_file), theory = theory) |
74678 | 515 |
node_relative(deps, session, node_name).map(html_dir => |
516 |
HTML.link(html_dir + html_name(node_name), body)) |
|
74677 | 517 |
case (Markup.Ref(_), Position.Def_File(thy_file), Position.Def_Theory(def_theory), |
74694
2d9d92116fac
clarified Theory_Cache: prefer immutable data with Synchronized variable;
wenzelm
parents:
74693
diff
changeset
|
518 |
Markup.Kind(kind), Markup.Name(name)) => |
2d9d92116fac
clarified Theory_Cache: prefer immutable data with Synchronized variable;
wenzelm
parents:
74693
diff
changeset
|
519 |
val thy_name = if (def_theory.nonEmpty) def_theory else context.node.theory |
2d9d92116fac
clarified Theory_Cache: prefer immutable data with Synchronized variable;
wenzelm
parents:
74693
diff
changeset
|
520 |
val node_name = resources.file_node(Path.explode(thy_file), theory = thy_name) |
74677 | 521 |
for { |
522 |
html_dir <- node_relative(deps, session, node_name) |
|
523 |
html_file = node_file(node_name) |
|
74713 | 524 |
html_ref <- |
525 |
logical_ref(thy_name, kind, name) orElse physical_ref(context, thy_name, props) |
|
74677 | 526 |
} yield { |
74679 | 527 |
HTML.entity_ref(HTML.link(html_dir + html_file + "#" + html_ref, body)) |
74677 | 528 |
} |
73056 | 529 |
case _ => None |
530 |
} |
|
74677 | 531 |
} |
73056 | 532 |
|
73215 | 533 |
sealed case class Theory( |
534 |
name: Document.Node.Name, |
|
535 |
command: Command, |
|
536 |
files_html: List[(Path, XML.Tree)], |
|
537 |
html: XML.Tree) |
|
538 |
||
539 |
def read_theory(name: Document.Node.Name): Option[Theory] = |
|
540 |
{ |
|
541 |
progress.expose_interrupt() |
|
542 |
||
74712 | 543 |
for (command <- Build_Job.read_theory(db_context, resources, hierarchy, name.theory)) |
73215 | 544 |
yield { |
74712 | 545 |
if (verbose) progress.echo("Presenting theory " + name) |
73215 | 546 |
val snapshot = Document.State.init.snippet(command) |
73214 | 547 |
|
74715
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
548 |
val thy_elements = |
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
549 |
session_elements.copy(entity = |
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
550 |
theory_exports(name.theory).entity_kinds.foldLeft(session_elements.entity)(_ + _)) |
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
551 |
|
73215 | 552 |
val files_html = |
553 |
for { |
|
74715
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
554 |
(src_path, xml) <- snapshot.xml_markup_blobs(elements = thy_elements.html) |
73215 | 555 |
if xml.nonEmpty |
556 |
} |
|
557 |
yield { |
|
558 |
progress.expose_interrupt() |
|
73216 | 559 |
if (verbose) progress.echo("Presenting file " + src_path) |
560 |
||
74677 | 561 |
(src_path, html_context.source( |
74715
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
562 |
make_html(name, thy_elements, entity_anchor, entity_link, xml))) |
73215 | 563 |
} |
564 |
||
565 |
val html = |
|
566 |
html_context.source( |
|
74715
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
567 |
make_html(name, thy_elements, entity_anchor, entity_link, |
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
568 |
snapshot.xml_markup(elements = thy_elements.html))) |
73215 | 569 |
|
570 |
Theory(name, command, files_html, html) |
|
571 |
} |
|
572 |
} |
|
573 |
||
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
574 |
(for (thy <- Par_List.map(read_theory, present_theories).flatten) yield { |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
575 |
val thy_session = base.theory_qualifier(thy.name) |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
576 |
val thy_dir = make_session_dir(thy_session) |
72989 | 577 |
val files = |
73215 | 578 |
for { (src_path, file_html) <- thy.files_html } |
73043 | 579 |
yield { |
74677 | 580 |
val file_name = html_path(src_path) |
72989 | 581 |
|
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
582 |
seen_files.find(_.check(src_path, file_name, thy_session)) match { |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
583 |
case None => seen_files ::= Seen_File(src_path, file_name, thy_session, thy.name) |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
584 |
case Some(seen_file) => |
72989 | 585 |
error("Incoherent use of file name " + src_path + " as " + quote(file_name) + |
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
586 |
" in theory " + seen_file.thy_name + " vs. " + thy.name) |
72989 | 587 |
} |
72669 | 588 |
|
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
589 |
val file_path = thy_dir + Path.explode(file_name) |
72989 | 590 |
val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short) |
591 |
HTML.write_document(file_path.dir, file_path.file_name, |
|
74709 | 592 |
List(HTML.title(file_title)), List(html_context.head(file_title), file_html), |
593 |
base = Some(presentation_dir)) |
|
72989 | 594 |
|
595 |
List(HTML.link(file_name, HTML.text(file_title))) |
|
73043 | 596 |
} |
72989 | 597 |
|
73215 | 598 |
val thy_title = "Theory " + thy.name.theory_base_name |
72989 | 599 |
|
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
600 |
HTML.write_document(thy_dir, html_name(thy.name), |
74709 | 601 |
List(HTML.title(thy_title)), List(html_context.head(thy_title), thy.html), |
602 |
base = Some(presentation_dir)) |
|
73215 | 603 |
|
74710
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
604 |
if (thy_session == session) { |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
605 |
Some( |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
606 |
List(HTML.link(html_name(thy.name), |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
607 |
HTML.text(thy.name.theory_base_name) ::: |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
608 |
(if (files.isEmpty) Nil else List(HTML.itemize(files)))))) |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
609 |
} |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
610 |
else None |
2057c02d7795
present theories from imported sessions as required;
wenzelm
parents:
74709
diff
changeset
|
611 |
}).flatten |
72989 | 612 |
} |
61500 | 613 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
614 |
val title = "Session " + session |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
615 |
HTML.write_document(session_dir, "index.html", |
73523
2cd23d587db9
further clarification of Isabelle distribution identification -- avoid odd patching of sources;
wenzelm
parents:
73474
diff
changeset
|
616 |
List(HTML.title(title + Isabelle_System.isabelle_heading())), |
73041 | 617 |
html_context.head(title, List(HTML.par(view_links))) :: |
74709 | 618 |
html_context.contents("Theories", theories), |
619 |
base = Some(presentation_dir)) |
|
61372 | 620 |
} |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
621 |
} |