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