author | wenzelm |
Mon, 17 May 2021 16:15:25 +0200 | |
changeset 73718 | ecb31c3bf980 |
parent 73529 | cf1a1e92bf34 |
child 74670 | b2604cd4d131 |
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 |
|
51402 | 10 |
import scala.collection.immutable.SortedMap |
11 |
||
12 |
||
72652 | 13 |
object Presentation |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
14 |
{ |
72957 | 15 |
/** HTML documents **/ |
16 |
||
73718 | 17 |
/* HTML context */ |
18 |
||
72962 | 19 |
val fonts_path = Path.explode("fonts") |
20 |
||
72957 | 21 |
sealed case class HTML_Document(title: String, content: String) |
22 |
||
72959 | 23 |
def html_context(fonts_url: String => String = HTML.fonts_url()): HTML_Context = |
24 |
new HTML_Context(fonts_url) |
|
25 |
||
26 |
final class HTML_Context private[Presentation](fonts_url: String => String) |
|
27 |
{ |
|
73340 | 28 |
def init_fonts(dir: Path): Unit = |
72962 | 29 |
{ |
30 |
val fonts_dir = Isabelle_System.make_directory(dir + fonts_path) |
|
31 |
for (entry <- Isabelle_Fonts.fonts(hidden = true)) |
|
73317 | 32 |
Isabelle_System.copy_file(entry.path, fonts_dir) |
72962 | 33 |
} |
34 |
||
35 |
def head(title: String, rest: XML.Body = Nil): XML.Tree = |
|
36 |
HTML.div("head", HTML.chapter(title) :: rest) |
|
37 |
||
38 |
def source(body: XML.Body): XML.Tree = HTML.pre("source", body) |
|
39 |
||
40 |
def contents(heading: String, items: List[XML.Body], css_class: String = "contents") |
|
41 |
: List[XML.Elem] = |
|
42 |
{ |
|
43 |
if (items.isEmpty) Nil |
|
44 |
else List(HTML.div(css_class, List(HTML.section(heading), HTML.itemize(items)))) |
|
45 |
} |
|
46 |
||
72959 | 47 |
def output_document(title: String, body: XML.Body): String = |
48 |
HTML.output_document( |
|
49 |
List( |
|
50 |
HTML.style(HTML.fonts_css(fonts_url) + "\n\n" + File.read(HTML.isabelle_css)), |
|
51 |
HTML.title(title)), |
|
52 |
List(HTML.source(body)), css = "", structural = false) |
|
53 |
||
54 |
def html_document(title: String, body: XML.Body): HTML_Document = |
|
55 |
HTML_Document(title, output_document(title, body)) |
|
56 |
} |
|
57 |
||
72957 | 58 |
|
73055 | 59 |
/* presentation elements */ |
60 |
||
61 |
sealed case class Elements( |
|
62 |
html: Markup.Elements = Markup.Elements.empty, |
|
73056 | 63 |
entity: Markup.Elements = Markup.Elements.empty, |
73055 | 64 |
language: Markup.Elements = Markup.Elements.empty) |
72957 | 65 |
|
73055 | 66 |
val elements1: Elements = |
67 |
Elements( |
|
68 |
html = |
|
69 |
Rendering.foreground_elements ++ Rendering.text_color_elements + |
|
73056 | 70 |
Markup.NUMERAL + Markup.COMMENT + Markup.ENTITY + Markup.LANGUAGE, |
71 |
entity = Markup.Elements(Markup.THEORY)) |
|
73036 | 72 |
|
73055 | 73 |
val elements2: Elements = |
74 |
Elements( |
|
75 |
html = elements1.html ++ Rendering.markdown_elements, |
|
73056 | 76 |
language = Markup.Elements(Markup.Language.DOCUMENT)) |
73055 | 77 |
|
78 |
||
73718 | 79 |
/* HTML output */ |
73036 | 80 |
|
72957 | 81 |
private val div_elements = |
82 |
Set(HTML.div.name, HTML.pre.name, HTML.par.name, HTML.list.name, HTML.enum.name, |
|
83 |
HTML.descr.name) |
|
84 |
||
73056 | 85 |
def make_html( |
86 |
elements: Elements, |
|
87 |
entity_link: (Properties.T, XML.Body) => Option[XML.Tree], |
|
88 |
xml: XML.Body): XML.Body = |
|
73054 | 89 |
{ |
90 |
def html_div(html: XML.Body): Boolean = |
|
91 |
html exists { |
|
92 |
case XML.Elem(markup, body) => div_elements.contains(markup.name) || html_div(body) |
|
93 |
case XML.Text(_) => false |
|
94 |
} |
|
72957 | 95 |
|
73055 | 96 |
def html_class(c: String, html: XML.Body): XML.Body = |
97 |
if (c == "") html |
|
98 |
else if (html_div(html)) List(HTML.div(c, html)) |
|
99 |
else List(HTML.span(c, html)) |
|
72957 | 100 |
|
73054 | 101 |
def html_body(xml_body: XML.Body): XML.Body = |
73055 | 102 |
xml_body flatMap { |
73059
523806d71dea
proper treatment of XML.Wrapped_Elem, e.g. Markup.class_parameter;
wenzelm
parents:
73057
diff
changeset
|
103 |
case XML.Wrapped_Elem(markup, _, body) => html_body(List(XML.Elem(markup, body))) |
73056 | 104 |
case XML.Elem(Markup(Markup.ENTITY, props @ Markup.Kind(kind)), body) => |
105 |
val body1 = html_body(body) |
|
106 |
if (elements.entity(kind)) { |
|
107 |
entity_link(props, body1) match { |
|
108 |
case Some(link) => List(link) |
|
109 |
case None => body1 |
|
110 |
} |
|
111 |
} |
|
112 |
else body1 |
|
73055 | 113 |
case XML.Elem(Markup(Markup.LANGUAGE, Markup.Name(name)), body) => |
114 |
html_class(if (elements.language(name)) name else "", html_body(body)) |
|
115 |
case XML.Elem(Markup(Markup.MARKDOWN_PARAGRAPH, _), body) => |
|
116 |
List(HTML.par(html_body(body))) |
|
117 |
case XML.Elem(Markup(Markup.MARKDOWN_ITEM, _), body) => |
|
118 |
List(HTML.item(html_body(body))) |
|
119 |
case XML.Elem(Markup(Markup.Markdown_Bullet.name, _), _) => Nil |
|
73054 | 120 |
case XML.Elem(Markup.Markdown_List(kind), body) => |
73055 | 121 |
if (kind == Markup.ENUMERATE) List(HTML.enum(html_body(body))) |
122 |
else List(HTML.list(html_body(body))) |
|
73054 | 123 |
case XML.Elem(markup, body) => |
124 |
val name = markup.name |
|
125 |
val html = |
|
126 |
markup.properties match { |
|
127 |
case Markup.Kind(kind) if kind == Markup.COMMAND || kind == Markup.KEYWORD => |
|
73055 | 128 |
html_class(kind, html_body(body)) |
73054 | 129 |
case _ => |
130 |
html_body(body) |
|
131 |
} |
|
132 |
Rendering.foreground.get(name) orElse Rendering.text_color.get(name) match { |
|
133 |
case Some(c) => html_class(c.toString, html) |
|
134 |
case None => html_class(name, html) |
|
72957 | 135 |
} |
73054 | 136 |
case XML.Text(text) => |
73055 | 137 |
HTML.text(Symbol.decode(text)) |
73054 | 138 |
} |
139 |
||
140 |
html_body(xml) |
|
141 |
} |
|
72957 | 142 |
|
143 |
||
144 |
/* PIDE HTML document */ |
|
145 |
||
146 |
def html_document( |
|
147 |
resources: Resources, |
|
148 |
snapshot: Document.Snapshot, |
|
72962 | 149 |
html_context: HTML_Context, |
73055 | 150 |
elements: Elements, |
72959 | 151 |
plain_text: Boolean = false): HTML_Document = |
72957 | 152 |
{ |
73120
c3589f2dff31
more informative errors: simplify diagnosis of spurious failures reported by users;
wenzelm
parents:
73059
diff
changeset
|
153 |
require(!snapshot.is_outdated, "document snapshot outdated") |
72957 | 154 |
|
155 |
val name = snapshot.node_name |
|
156 |
if (plain_text) { |
|
72962 | 157 |
val title = "File " + Symbol.cartouche_decoded(name.path.file_name) |
72959 | 158 |
val body = HTML.text(snapshot.node.source) |
72962 | 159 |
html_context.html_document(title, body) |
72957 | 160 |
} |
161 |
else { |
|
72962 | 162 |
resources.html_document(snapshot) getOrElse { |
163 |
val title = |
|
164 |
if (name.is_theory) "Theory " + quote(name.theory_base_name) |
|
165 |
else "File " + Symbol.cartouche_decoded(name.path.file_name) |
|
73056 | 166 |
val body = make_html(elements, (_, _) => None, snapshot.xml_markup(elements = elements.html)) |
72962 | 167 |
html_context.html_document(title, body) |
72957 | 168 |
} |
169 |
} |
|
170 |
} |
|
171 |
||
172 |
||
173 |
||
73718 | 174 |
/** HTML presentation **/ |
72649 | 175 |
|
72648 | 176 |
/* presentation context */ |
177 |
||
178 |
object Context |
|
179 |
{ |
|
180 |
val none: Context = new Context { def enabled: Boolean = false } |
|
181 |
val standard: Context = new Context { def enabled: Boolean = true } |
|
182 |
||
183 |
def dir(path: Path): Context = |
|
184 |
new Context { |
|
185 |
def enabled: Boolean = true |
|
186 |
override def dir(store: Sessions.Store): Path = path |
|
187 |
} |
|
188 |
||
189 |
def make(s: String): Context = |
|
190 |
if (s == ":") standard else dir(Path.explode(s)) |
|
191 |
} |
|
192 |
||
193 |
abstract class Context private |
|
194 |
{ |
|
195 |
def enabled: Boolean |
|
196 |
def enabled(info: Sessions.Info): Boolean = enabled || info.browser_info |
|
197 |
def dir(store: Sessions.Store): Path = store.presentation_dir |
|
198 |
def dir(store: Sessions.Store, info: Sessions.Info): Path = |
|
72670 | 199 |
dir(store) + Path.explode(info.chapter_session) |
72648 | 200 |
} |
201 |
||
202 |
||
72955
942bf91545fa
clarified comments: file-system access is always unsynchronized;
wenzelm
parents:
72882
diff
changeset
|
203 |
/* maintain chapter index */ |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
204 |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
205 |
private val sessions_path = Path.basic(".sessions") |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
206 |
|
51402 | 207 |
private def read_sessions(dir: Path): List[(String, String)] = |
208 |
{ |
|
51416 | 209 |
val path = dir + sessions_path |
210 |
if (path.is_file) { |
|
211 |
import XML.Decode._ |
|
65344
b99283eed13c
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65089
diff
changeset
|
212 |
list(pair(string, string))(Symbol.decode_yxml(File.read(path))) |
51416 | 213 |
} |
214 |
else Nil |
|
51402 | 215 |
} |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
216 |
|
73340 | 217 |
private def write_sessions(dir: Path, sessions: List[(String, String)]): Unit = |
51402 | 218 |
{ |
219 |
import XML.Encode._ |
|
220 |
File.write(dir + sessions_path, YXML.string_of_body(list(pair(string, string))(sessions))) |
|
221 |
} |
|
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
222 |
|
73340 | 223 |
def update_chapter_index( |
224 |
browser_info: Path, chapter: String, new_sessions: List[(String, String)]): Unit = |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
225 |
{ |
72376 | 226 |
val dir = Isabelle_System.make_directory(browser_info + Path.basic(chapter)) |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
227 |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
228 |
val sessions0 = |
51406
950b897f95bb
proper path -- I/O was hidden due to permissiveness;
wenzelm
parents:
51402
diff
changeset
|
229 |
try { read_sessions(dir) } |
51987 | 230 |
catch { case _: XML.Error => Nil } |
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
231 |
|
51402 | 232 |
val sessions = (SortedMap.empty[String, String] ++ sessions0 ++ new_sessions).toList |
65988 | 233 |
write_sessions(dir, sessions) |
51402 | 234 |
|
65988 | 235 |
val title = "Isabelle/" + chapter + " sessions" |
236 |
HTML.write_document(dir, "index.html", |
|
73523
2cd23d587db9
further clarification of Isabelle distribution identification -- avoid odd patching of sources;
wenzelm
parents:
73474
diff
changeset
|
237 |
List(HTML.title(title + Isabelle_System.isabelle_heading())), |
65988 | 238 |
HTML.chapter(title) :: |
239 |
(if (sessions.isEmpty) Nil |
|
240 |
else |
|
65992 | 241 |
List(HTML.div("sessions", |
242 |
List(HTML.description( |
|
65988 | 243 |
sessions.map({ case (name, description) => |
69318 | 244 |
val descr = Symbol.trim_blank_lines(description) |
65989 | 245 |
(List(HTML.link(name + "/index.html", HTML.text(name))), |
69318 | 246 |
if (descr == "") Nil |
247 |
else HTML.break ::: List(HTML.pre(HTML.text(descr)))) }))))))) |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
248 |
} |
61372 | 249 |
|
73340 | 250 |
def make_global_index(browser_info: Path): Unit = |
61372 | 251 |
{ |
252 |
if (!(browser_info + Path.explode("index.html")).is_file) { |
|
72375 | 253 |
Isabelle_System.make_directory(browser_info) |
73317 | 254 |
Isabelle_System.copy_file(Path.explode("~~/lib/logo/isabelle.gif"), |
61372 | 255 |
browser_info + Path.explode("isabelle.gif")) |
73528
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
256 |
val title = "The " + XML.text(Isabelle_System.isabelle_name()) + " Library" |
61372 | 257 |
File.write(browser_info + Path.explode("index.html"), |
73529 | 258 |
HTML.header + |
259 |
""" |
|
73528
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
260 |
<head> |
73529 | 261 |
""" + HTML.head_meta + """ |
73528
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
262 |
<title>""" + title + """</title> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
263 |
</head> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
264 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
265 |
<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
|
266 |
<center> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
267 |
<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
|
268 |
<tr> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
269 |
<td width="20%" valign="middle" align="center"><a href="http://isabelle.in.tum.de/"><img align="bottom" src="isabelle.gif" width="100" height="86" alt="[Isabelle]" border="0" /></a></td> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
270 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
271 |
<td width="80%" valign="middle" align="center"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
272 |
<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
|
273 |
<tr> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
274 |
<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
|
275 |
</tr> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
276 |
</table> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
277 |
</td> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
278 |
</tr> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
279 |
</table> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
280 |
</center> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
281 |
<hr /> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
282 |
<ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
283 |
<li>Higher-Order Logic</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
284 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
285 |
<li style="list-style: none"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
286 |
<ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
287 |
<li><a href="HOL/index.html">HOL (Higher-Order Logic)</a> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
288 |
is a version of classical higher-order logic resembling |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
289 |
that of the <a href="http://www.cl.cam.ac.uk/Research/HVG/HOL/">HOL System</a>. |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
290 |
</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
291 |
</ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
292 |
</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
293 |
</ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
294 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
295 |
<ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
296 |
<li>First-Order Logic</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
297 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
298 |
<li style="list-style: none"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
299 |
<ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
300 |
<li><a href="FOL/index.html">FOL (Many-sorted First-Order Logic)</a> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
301 |
provides basic classical and intuitionistic first-order logic. It is |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
302 |
polymorphic. |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
303 |
</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
304 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
305 |
<li><a href="ZF/index.html">ZF (Set Theory)</a> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
306 |
offers a formulation of Zermelo-Fraenkel set theory on top of FOL. |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
307 |
</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
308 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
309 |
<li><a href="CCL/index.html">CCL (Classical Computational Logic)</a></li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
310 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
311 |
<li><a href="LCF/index.html">LCF (Logic of Computable Functions)</a></li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
312 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
313 |
<li><a href="FOLP/index.html">FOLP (FOL with Proof Terms)</a></li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
314 |
</ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
315 |
</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
316 |
</ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
317 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
318 |
<ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
319 |
<li>Miscellaneous</li> |
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 |
<li style="list-style: none"> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
322 |
<ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
323 |
<li><a href="Sequents/index.html">Sequents (first-order, modal and linear logics)</a></li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
324 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
325 |
<li><a href="CTT/index.html">CTT (Constructive Type Theory)</a> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
326 |
is an extensional version of Martin-Löf's Type Theory.</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
327 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
328 |
<li><a href="Cube/index.html">Cube (The Lambda Cube)</a></li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
329 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
330 |
<li><a href="Pure/index.html">The Pure logical framework</a></li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
331 |
|
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
332 |
<li><a href="Doc/index.html">Sources of Documentation</a></li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
333 |
</ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
334 |
</li> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
335 |
</ul> |
c337c798f64c
clarified HTML template (see also 04cb7e02ca38): avoid odd patching of sources;
wenzelm
parents:
73523
diff
changeset
|
336 |
</body> |
73529 | 337 |
""" + HTML.footer) |
61372 | 338 |
} |
339 |
} |
|
340 |
||
341 |
||
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
342 |
/* present session */ |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
343 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
344 |
val session_graph_path = Path.explode("session_graph.pdf") |
72959 | 345 |
val readme_path = Path.explode("README.html") |
346 |
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
|
347 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
348 |
def html_name(name: Document.Node.Name): String = name.theory_base_name + ".html" |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
349 |
|
73042 | 350 |
def theory_link(deps: Sessions.Deps, session0: String, |
73057 | 351 |
name: Document.Node.Name, body: XML.Body): Option[XML.Tree] = |
73042 | 352 |
{ |
353 |
val session1 = deps(session0).theory_qualifier(name) |
|
73057 | 354 |
val info0 = deps.sessions_structure.get(session0) |
355 |
val info1 = deps.sessions_structure.get(session1) |
|
356 |
if (info0.isDefined && info1.isDefined) { |
|
357 |
Some(HTML.link(info0.get.relative_path(info1.get) + html_name(name), body)) |
|
358 |
} |
|
359 |
else None |
|
73042 | 360 |
} |
361 |
||
72648 | 362 |
def session_html( |
72962 | 363 |
resources: Resources, |
72648 | 364 |
session: String, |
365 |
deps: Sessions.Deps, |
|
72683 | 366 |
db_context: Sessions.Database_Context, |
72992 | 367 |
progress: Progress = new Progress, |
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
368 |
verbose: Boolean = false, |
72962 | 369 |
html_context: HTML_Context, |
73055 | 370 |
elements: Elements, |
73340 | 371 |
presentation: Context): Unit = |
61372 | 372 |
{ |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
373 |
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
|
374 |
val options = info.options |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
375 |
val base = deps(session) |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
376 |
|
72683 | 377 |
val session_dir = presentation.dir(db_context.store, info) |
72962 | 378 |
|
379 |
html_context.init_fonts(session_dir) |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
380 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
381 |
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
|
382 |
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
|
383 |
|
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
384 |
val documents = |
72683 | 385 |
for { |
386 |
doc <- info.document_variants |
|
73718 | 387 |
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
|
388 |
} yield { |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
389 |
if (verbose) progress.echo("Presenting document " + session + "/" + doc.name) |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
390 |
Bytes.write(session_dir + doc.path.pdf, document.pdf) |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
391 |
doc |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
392 |
} |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
393 |
|
73041 | 394 |
val view_links = |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
395 |
{ |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
396 |
val deps_link = |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
397 |
HTML.link(session_graph_path, HTML.text("theory dependencies")) |
61372 | 398 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
399 |
val readme_links = |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
400 |
if ((info.dir + readme_path).is_file) { |
73317 | 401 |
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
|
402 |
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
|
403 |
} |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
404 |
else Nil |
62971
087e36ce0593
back to exact copy of non-text file (amending dcc8e1d34b18);
wenzelm
parents:
62631
diff
changeset
|
405 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
406 |
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
|
407 |
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
|
408 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
409 |
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
|
410 |
(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
|
411 |
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
|
412 |
} |
62971
087e36ce0593
back to exact copy of non-text file (amending dcc8e1d34b18);
wenzelm
parents:
62631
diff
changeset
|
413 |
|
72989 | 414 |
val theories: List[XML.Body] = |
72962 | 415 |
{ |
416 |
var seen_files = List.empty[(Path, String, Document.Node.Name)] |
|
73056 | 417 |
|
418 |
def entity_link(props: Properties.T, body: XML.Body): Option[XML.Tree] = |
|
419 |
(props, props, props) match { |
|
73057 | 420 |
case (Markup.Kind(Markup.THEORY), Markup.Name(theory), Position.Def_File(thy_file)) => |
421 |
val node_name = resources.file_node(Path.explode(thy_file), theory = theory) |
|
422 |
theory_link(deps, session, node_name, body) |
|
73056 | 423 |
case _ => None |
424 |
} |
|
425 |
||
73215 | 426 |
sealed case class Theory( |
427 |
name: Document.Node.Name, |
|
428 |
command: Command, |
|
429 |
files_html: List[(Path, XML.Tree)], |
|
430 |
html: XML.Tree) |
|
431 |
||
432 |
def read_theory(name: Document.Node.Name): Option[Theory] = |
|
433 |
{ |
|
434 |
progress.expose_interrupt() |
|
73216 | 435 |
if (verbose) progress.echo("Presenting theory " + name) |
73215 | 436 |
|
437 |
for (command <- Build_Job.read_theory(db_context, resources, session, name.theory)) |
|
438 |
yield { |
|
439 |
val snapshot = Document.State.init.snippet(command) |
|
73214 | 440 |
|
73215 | 441 |
val files_html = |
442 |
for { |
|
443 |
(src_path, xml) <- snapshot.xml_markup_blobs(elements = elements.html) |
|
444 |
if xml.nonEmpty |
|
445 |
} |
|
446 |
yield { |
|
447 |
progress.expose_interrupt() |
|
73216 | 448 |
if (verbose) progress.echo("Presenting file " + src_path) |
449 |
||
73215 | 450 |
(src_path, html_context.source(make_html(elements, entity_link, xml))) |
451 |
} |
|
452 |
||
453 |
val html = |
|
454 |
html_context.source( |
|
455 |
make_html(elements, entity_link, snapshot.xml_markup(elements = elements.html))) |
|
456 |
||
457 |
Theory(name, command, files_html, html) |
|
458 |
} |
|
459 |
} |
|
460 |
||
461 |
for (thy <- Par_List.map(read_theory, base.session_theories).flatten) |
|
72669 | 462 |
yield { |
72989 | 463 |
val files = |
73215 | 464 |
for { (src_path, file_html) <- thy.files_html } |
73043 | 465 |
yield { |
72989 | 466 |
val file_name = (files_path + src_path.squash.html).implode |
467 |
||
468 |
seen_files.find(p => p._1 == src_path || p._2 == file_name) match { |
|
73215 | 469 |
case None => seen_files ::= (src_path, file_name, thy.name) |
72989 | 470 |
case Some((_, _, thy_name1)) => |
471 |
error("Incoherent use of file name " + src_path + " as " + quote(file_name) + |
|
73215 | 472 |
" in theory " + thy_name1 + " vs. " + thy.name) |
72989 | 473 |
} |
72669 | 474 |
|
72989 | 475 |
val file_path = session_dir + Path.explode(file_name) |
476 |
html_context.init_fonts(file_path.dir) |
|
477 |
||
478 |
val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short) |
|
479 |
HTML.write_document(file_path.dir, file_path.file_name, |
|
73215 | 480 |
List(HTML.title(file_title)), List(html_context.head(file_title), file_html)) |
72989 | 481 |
|
482 |
List(HTML.link(file_name, HTML.text(file_title))) |
|
73043 | 483 |
} |
72989 | 484 |
|
73215 | 485 |
val thy_title = "Theory " + thy.name.theory_base_name |
72989 | 486 |
|
73215 | 487 |
HTML.write_document(session_dir, html_name(thy.name), |
488 |
List(HTML.title(thy_title)), List(html_context.head(thy_title), thy.html)) |
|
489 |
||
490 |
List(HTML.link(html_name(thy.name), |
|
491 |
HTML.text(thy.name.theory_base_name) ::: |
|
72989 | 492 |
(if (files.isEmpty) Nil else List(HTML.itemize(files))))) |
72669 | 493 |
} |
72989 | 494 |
} |
61500 | 495 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
496 |
val title = "Session " + session |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
497 |
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
|
498 |
List(HTML.title(title + Isabelle_System.isabelle_heading())), |
73041 | 499 |
html_context.head(title, List(HTML.par(view_links))) :: |
72989 | 500 |
html_context.contents("Theories", theories)) |
61372 | 501 |
} |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
502 |
} |