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