author | wenzelm |
Thu, 30 Jan 2025 22:29:45 +0100 | |
changeset 82023 | 9601f5582f33 |
parent 81566 | f207acb03ccb |
child 82054 | cddcc84309a5 |
permissions | -rw-r--r-- |
79502 | 1 |
/* Title: Pure/Build/browser_info.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 |
|
75949
b09dab301d72
tuned comments, following "isabelle build" usage;
wenzelm
parents:
75947
diff
changeset
|
4 |
HTML/PDF presentation of PIDE document information. |
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 |
||
75941 | 15 |
object Browser_Info { |
75945 | 16 |
/* browser_info store configuration */ |
75943 | 17 |
|
18 |
object Config { |
|
19 |
val none: Config = new Config { def enabled: Boolean = false } |
|
20 |
val standard: Config = new Config { def enabled: Boolean = true } |
|
21 |
||
22 |
def dir(path: Path): Config = |
|
23 |
new Config { |
|
24 |
def enabled: Boolean = true |
|
78178 | 25 |
override def presentation_dir(store: Store): Path = path |
75943 | 26 |
} |
72957 | 27 |
|
75943 | 28 |
def make(s: String): Config = |
29 |
if (s == ":") standard else dir(Path.explode(s)) |
|
30 |
} |
|
31 |
||
32 |
abstract class Config private { |
|
33 |
def enabled: Boolean |
|
34 |
def enabled(info: Sessions.Info): Boolean = enabled || info.browser_info |
|
78178 | 35 |
def presentation_dir(store: Store): Path = store.presentation_dir |
75943 | 36 |
} |
37 |
||
38 |
||
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
39 |
/* meta info within the file-system */ |
75961 | 40 |
|
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
41 |
object Meta_Info { |
75961 | 42 |
/* directory */ |
43 |
||
44 |
val PATH: Path = Path.explode(".browser_info") |
|
45 |
||
46 |
def check_directory(dir: Path): Unit = { |
|
47 |
if (dir.is_dir && !(dir + PATH).is_dir && File.read_dir(dir).nonEmpty) { |
|
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
48 |
error("Existing content in " + dir.expand + " lacks " + PATH + " meta info.\n" + |
75961 | 49 |
"To avoid potential disaster, it has not been changed automatically.\n" + |
50 |
"If this is the intended directory, please move/remove/empty it manually.") |
|
51 |
} |
|
52 |
} |
|
53 |
||
82023
9601f5582f33
more robust wrt. Par_List.map in Browser_Info.build(), see also 2fff9ce6b460 and 787a203a20b6;
wenzelm
parents:
81566
diff
changeset
|
54 |
def init_directory(dir: Path, permissive: Boolean = false): Path = { |
9601f5582f33
more robust wrt. Par_List.map in Browser_Info.build(), see also 2fff9ce6b460 and 787a203a20b6;
wenzelm
parents:
81566
diff
changeset
|
55 |
if (!permissive) check_directory(dir) |
75961 | 56 |
Isabelle_System.make_directory(dir + PATH) |
57 |
dir |
|
58 |
} |
|
59 |
||
75982
2fff9ce6b460
more aggressive clean_directory(session_dir), while rm_tree is guarded by check_directory, i.e. it is presumably "owned" by Browser_Info.build_session();
wenzelm
parents:
75981
diff
changeset
|
60 |
def clean_directory(dir: Path): Path = { |
2fff9ce6b460
more aggressive clean_directory(session_dir), while rm_tree is guarded by check_directory, i.e. it is presumably "owned" by Browser_Info.build_session();
wenzelm
parents:
75981
diff
changeset
|
61 |
check_directory(dir) |
2fff9ce6b460
more aggressive clean_directory(session_dir), while rm_tree is guarded by check_directory, i.e. it is presumably "owned" by Browser_Info.build_session();
wenzelm
parents:
75981
diff
changeset
|
62 |
Isabelle_System.rm_tree(dir) // guarded by check_directory! |
2fff9ce6b460
more aggressive clean_directory(session_dir), while rm_tree is guarded by check_directory, i.e. it is presumably "owned" by Browser_Info.build_session();
wenzelm
parents:
75981
diff
changeset
|
63 |
Isabelle_System.new_directory(dir + PATH) |
2fff9ce6b460
more aggressive clean_directory(session_dir), while rm_tree is guarded by check_directory, i.e. it is presumably "owned" by Browser_Info.build_session();
wenzelm
parents:
75981
diff
changeset
|
64 |
} |
2fff9ce6b460
more aggressive clean_directory(session_dir), while rm_tree is guarded by check_directory, i.e. it is presumably "owned" by Browser_Info.build_session();
wenzelm
parents:
75981
diff
changeset
|
65 |
|
75961 | 66 |
|
67 |
/* content */ |
|
68 |
||
69 |
def make_path(dir: Path, name: String): Path = |
|
70 |
dir + PATH + Path.basic(name) |
|
71 |
||
72 |
def value(dir: Path, name: String): String = { |
|
73 |
val path = make_path(dir, name) |
|
74 |
if (path.is_file) File.read(path) else "" |
|
75 |
} |
|
76 |
||
77 |
def change(dir: Path, name: String)(f: String => String): Unit = { |
|
78 |
val path = make_path(dir, name) |
|
79 |
val x = value(dir, name) |
|
80 |
val y = |
|
81 |
try { f(x) } |
|
82 |
catch { case ERROR(msg) => error("Failed to change " + path.expand + ":\n" + msg)} |
|
83 |
if (x != y) File.write(path, y) |
|
84 |
} |
|
85 |
||
86 |
||
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
87 |
/* build_uuid */ |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
88 |
|
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
89 |
val BUILD_UUID = "build_uuid" |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
90 |
|
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
91 |
def check_build_uuid(dir: Path, uuid: String): Boolean = { |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
92 |
val uuid0 = value(dir, BUILD_UUID) |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
93 |
uuid0.nonEmpty && uuid.nonEmpty && uuid0 == uuid |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
94 |
} |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
95 |
|
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
96 |
def set_build_uuid(dir: Path, uuid: String): Unit = |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
97 |
change(dir, BUILD_UUID)(_ => uuid) |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
98 |
|
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
99 |
|
75961 | 100 |
/* index */ |
101 |
||
102 |
val INDEX = "index.json" |
|
103 |
||
104 |
object Item { |
|
105 |
def parse(json: JSON.T): Item = { |
|
106 |
def err(): Nothing = |
|
107 |
error("Bad JSON object for item:\n" + JSON.Format.pretty_print(json)) |
|
108 |
val obj = JSON.Object.unapply(json) getOrElse err() |
|
109 |
||
110 |
val name = JSON.string(obj, "name") getOrElse err() |
|
111 |
val description = JSON.string(obj, "description") getOrElse "" |
|
112 |
Item(name, description = Symbol.trim_blank_lines(description)) |
|
113 |
} |
|
114 |
} |
|
115 |
||
116 |
sealed case class Item(name: String, description: String = "") { |
|
75994 | 117 |
override def toString: String = name |
118 |
||
75961 | 119 |
def json: JSON.T = JSON.Object("name" -> name, "description" -> description) |
120 |
} |
|
121 |
||
122 |
object Index { |
|
123 |
def parse(s: JSON.S, kind: String): Index = { |
|
124 |
if (s.isEmpty) Index(kind, Nil) |
|
125 |
else { |
|
126 |
def err(): Nothing = error("Bad JSON object " + kind + " index:\n" + s) |
|
127 |
||
128 |
val json = JSON.parse(s) |
|
129 |
val obj = JSON.Object.unapply(json) getOrElse err() |
|
130 |
||
131 |
val kind1 = JSON.string(obj, "kind") getOrElse err() |
|
132 |
val items = JSON.list(obj, "items", x => Some(Item.parse(x))) getOrElse err() |
|
133 |
if (kind == kind1) Index(kind, items) |
|
134 |
else error("Expected index kind " + quote(kind) + " but found " + quote(kind1)) |
|
135 |
} |
|
136 |
} |
|
137 |
} |
|
138 |
||
139 |
sealed case class Index(kind: String, items: List[Item]) { |
|
75991 | 140 |
def is_empty: Boolean = items.isEmpty |
141 |
||
75999
b831a0bdd751
clarified signature of Sessions.Session: chapter_defs: vs. known_chapters (in declaration order) vs. chapters (covered by visible sessions);
wenzelm
parents:
75994
diff
changeset
|
142 |
def + (item: Item): Index = |
b831a0bdd751
clarified signature of Sessions.Session: chapter_defs: vs. known_chapters (in declaration order) vs. chapters (covered by visible sessions);
wenzelm
parents:
75994
diff
changeset
|
143 |
Index(kind, (item :: items.filterNot(_.name == item.name)).sortBy(_.name)) |
75961 | 144 |
|
145 |
def json: JSON.T = JSON.Object("kind" -> kind, "items" -> items.map(_.json)) |
|
146 |
def print_json: JSON.S = JSON.Format.pretty_print(json) |
|
147 |
} |
|
148 |
} |
|
149 |
||
150 |
||
75945 | 151 |
/* presentation elements */ |
152 |
||
153 |
sealed case class Elements( |
|
154 |
html: Markup.Elements = Markup.Elements.empty, |
|
155 |
entity: Markup.Elements = Markup.Elements.empty, |
|
156 |
language: Markup.Elements = Markup.Elements.empty) |
|
157 |
||
75979 | 158 |
val default_elements: Elements = |
75945 | 159 |
Elements( |
160 |
html = Rendering.foreground_elements ++ Rendering.text_color_elements + |
|
81566 | 161 |
Markup.TCLASS + Markup.TCONST + Markup.CONST + |
76009
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
162 |
Markup.NUMERAL + Markup.COMMENT + Markup.ENTITY + Markup.LANGUAGE + |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
163 |
Markup.PATH + Markup.URL, |
75945 | 164 |
entity = Markup.Elements(Markup.THEORY, Markup.TYPE_NAME, Markup.CONSTANT, Markup.FACT, |
165 |
Markup.CLASS, Markup.LOCALE, Markup.FREE)) |
|
166 |
||
75979 | 167 |
val extra_elements: Elements = |
75945 | 168 |
Elements( |
75979 | 169 |
html = default_elements.html ++ Rendering.markdown_elements, |
75945 | 170 |
language = Markup.Elements(Markup.Language.DOCUMENT)) |
171 |
||
172 |
||
75943 | 173 |
|
75949
b09dab301d72
tuned comments, following "isabelle build" usage;
wenzelm
parents:
75947
diff
changeset
|
174 |
/** HTML/PDF presentation context **/ |
73718 | 175 |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
176 |
def context( |
75884
3d8b37b1d798
clarified signature: avoid object-oriented HTML_Context;
wenzelm
parents:
75792
diff
changeset
|
177 |
sessions_structure: Sessions.Structure, |
75979 | 178 |
elements: Elements = default_elements, |
75884
3d8b37b1d798
clarified signature: avoid object-oriented HTML_Context;
wenzelm
parents:
75792
diff
changeset
|
179 |
root_dir: Path = Path.current, |
75907 | 180 |
document_info: Document_Info = Document_Info.empty |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
181 |
): Context = new Context(sessions_structure, elements, root_dir, document_info) |
72957 | 182 |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
183 |
class Context private[Browser_Info]( |
75884
3d8b37b1d798
clarified signature: avoid object-oriented HTML_Context;
wenzelm
parents:
75792
diff
changeset
|
184 |
sessions_structure: Sessions.Structure, |
75897 | 185 |
val elements: Elements, |
75884
3d8b37b1d798
clarified signature: avoid object-oriented HTML_Context;
wenzelm
parents:
75792
diff
changeset
|
186 |
val root_dir: Path, |
75907 | 187 |
val document_info: Document_Info |
75884
3d8b37b1d798
clarified signature: avoid object-oriented HTML_Context;
wenzelm
parents:
75792
diff
changeset
|
188 |
) { |
74818
3064e165c660
clarified HTML_Context.theory_exports: prefer value-oriented parallelism;
wenzelm
parents:
74816
diff
changeset
|
189 |
/* directory structure and resources */ |
74770
32c2587cda4f
clarified HTML_Context: more explicit directory structure;
wenzelm
parents:
74769
diff
changeset
|
190 |
|
75907 | 191 |
def theory_by_name(session: String, theory: String): Option[Document_Info.Theory] = |
192 |
document_info.theory_by_name(session, theory) |
|
75894 | 193 |
|
75907 | 194 |
def theory_by_file(session: String, file: String): Option[Document_Info.Theory] = |
195 |
document_info.theory_by_file(session, file) |
|
75897 | 196 |
|
75980 | 197 |
def session_chapter(session: String): String = |
198 |
sessions_structure(session).chapter |
|
199 |
||
75981 | 200 |
def chapter_dir(session: String): Path = |
201 |
root_dir + Path.basic(session_chapter(session)) |
|
74770
32c2587cda4f
clarified HTML_Context: more explicit directory structure;
wenzelm
parents:
74769
diff
changeset
|
202 |
|
75981 | 203 |
def session_dir(session: String): Path = |
204 |
chapter_dir(session) + Path.basic(session) |
|
75961 | 205 |
|
75946 | 206 |
def theory_dir(theory: Document_Info.Theory): Path = |
207 |
session_dir(theory.dynamic_session) |
|
208 |
||
75907 | 209 |
def theory_html(theory: Document_Info.Theory): Path = |
75917
20b918404aa3
evade clash with index.html (allow "Index.thy" even on case-insensitive file-systems);
wenzelm
parents:
75916
diff
changeset
|
210 |
{ |
75926
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
211 |
def check(name: String): Option[Path] = { |
75977
59aa034220bf
more robust: ensure that chapter/session/theory do not contain special notation (like "/" or "..");
wenzelm
parents:
75971
diff
changeset
|
212 |
val path = Path.basic(name).html |
75926
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
213 |
if (Path.eq_case_insensitive(path, Path.index_html)) None |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
214 |
else Some(path) |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
215 |
} |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
216 |
check(theory.print_short) orElse check(theory.name) getOrElse |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
217 |
error("Illegal global theory name " + quote(theory.name) + |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
218 |
" (conflict with " + Path.index_html + ")") |
75917
20b918404aa3
evade clash with index.html (allow "Index.thy" even on case-insensitive file-systems);
wenzelm
parents:
75916
diff
changeset
|
219 |
} |
75900 | 220 |
|
75915
95d7459e5bc0
clarified directory layout (again): mimic original directory layout, notably ISABELLE_HOME;
wenzelm
parents:
75914
diff
changeset
|
221 |
def file_html(file: String): Path = |
95d7459e5bc0
clarified directory layout (again): mimic original directory layout, notably ISABELLE_HOME;
wenzelm
parents:
75914
diff
changeset
|
222 |
Path.explode(file).squash.html |
75900 | 223 |
|
75914
4da80799352f
more robust treatment of Document.Node.Name, following stored data;
wenzelm
parents:
75913
diff
changeset
|
224 |
def smart_html(theory: Document_Info.Theory, file: String): Path = |
75915
95d7459e5bc0
clarified directory layout (again): mimic original directory layout, notably ISABELLE_HOME;
wenzelm
parents:
75914
diff
changeset
|
225 |
if (File.is_thy(file)) theory_html(theory) else file_html(file) |
74770
32c2587cda4f
clarified HTML_Context: more explicit directory structure;
wenzelm
parents:
74769
diff
changeset
|
226 |
|
32c2587cda4f
clarified HTML_Context: more explicit directory structure;
wenzelm
parents:
74769
diff
changeset
|
227 |
|
74769 | 228 |
/* HTML content */ |
229 |
||
72962 | 230 |
def head(title: String, rest: XML.Body = Nil): XML.Tree = |
231 |
HTML.div("head", HTML.chapter(title) :: rest) |
|
232 |
||
233 |
def source(body: XML.Body): XML.Tree = HTML.pre("source", body) |
|
234 |
||
75393 | 235 |
def contents( |
236 |
heading: String, |
|
237 |
items: List[XML.Body], |
|
238 |
css_class: String = "contents" |
|
239 |
) : List[XML.Elem] = { |
|
72962 | 240 |
if (items.isEmpty) Nil |
241 |
else List(HTML.div(css_class, List(HTML.section(heading), HTML.itemize(items)))) |
|
242 |
} |
|
243 |
||
75944 | 244 |
|
245 |
/* preview PIDE document */ |
|
246 |
||
75969 | 247 |
lazy val isabelle_css: String = File.read(HTML.isabelle_css) |
74768 | 248 |
|
75393 | 249 |
def html_document(title: String, body: XML.Body, fonts_css: String): HTML_Document = { |
74709 | 250 |
val content = |
251 |
HTML.output_document( |
|
252 |
List( |
|
74768 | 253 |
HTML.style(fonts_css + "\n\n" + isabelle_css), |
74709 | 254 |
HTML.title(title)), |
255 |
List(HTML.source(body)), css = "", structural = false) |
|
256 |
HTML_Document(title, content) |
|
257 |
} |
|
75944 | 258 |
|
259 |
def preview_document( |
|
260 |
snapshot: Document.Snapshot, |
|
261 |
plain_text: Boolean = false, |
|
262 |
fonts_css: String = HTML.fonts_css() |
|
263 |
): HTML_Document = { |
|
264 |
require(!snapshot.is_outdated, "document snapshot outdated") |
|
265 |
||
266 |
val name = snapshot.node_name |
|
267 |
if (plain_text) { |
|
76829
f2a8ba0b8c96
more robust: avoid detour via somewhat fragile Node.Name.path;
wenzelm
parents:
76656
diff
changeset
|
268 |
val title = "File " + Symbol.cartouche_decoded(name.file_name) |
76933 | 269 |
val body = HTML.text(snapshot.node.source) |
75944 | 270 |
html_document(title, body, fonts_css) |
271 |
} |
|
272 |
else { |
|
273 |
Resources.html_document(snapshot) getOrElse { |
|
274 |
val title = |
|
275 |
if (name.is_theory) "Theory " + quote(name.theory_base_name) |
|
76829
f2a8ba0b8c96
more robust: avoid detour via somewhat fragile Node.Name.path;
wenzelm
parents:
76656
diff
changeset
|
276 |
else "File " + Symbol.cartouche_decoded(name.file_name) |
75944 | 277 |
val xml = snapshot.xml_markup(elements = elements.html) |
278 |
val body = Node_Context.empty.make_html(elements, xml) |
|
279 |
html_document(title, body, fonts_css) |
|
280 |
} |
|
281 |
} |
|
282 |
} |
|
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
283 |
|
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
284 |
|
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
285 |
/* maintain presentation structure */ |
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
286 |
|
75980 | 287 |
def update_chapter(session_name: String, session_description: String): Unit = synchronized { |
82023
9601f5582f33
more robust wrt. Par_List.map in Browser_Info.build(), see also 2fff9ce6b460 and 787a203a20b6;
wenzelm
parents:
81566
diff
changeset
|
288 |
val dir = Meta_Info.init_directory(chapter_dir(session_name), permissive = true) |
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
289 |
Meta_Info.change(dir, Meta_Info.INDEX) { text => |
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
290 |
val index0 = Meta_Info.Index.parse(text, "chapter") |
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
291 |
val item = Meta_Info.Item(session_name, description = session_description) |
75961 | 292 |
val index = index0 + item |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
293 |
|
75961 | 294 |
if (index != index0) { |
75981 | 295 |
val title = "Isabelle/" + session_chapter(session_name) + " sessions" |
75961 | 296 |
HTML.write_document(dir, "index.html", |
297 |
List(HTML.title(title + Isabelle_System.isabelle_heading())), |
|
298 |
HTML.chapter(title) :: |
|
75991 | 299 |
(if (index.is_empty) Nil |
75961 | 300 |
else |
301 |
List(HTML.div("sessions", |
|
302 |
List(HTML.description( |
|
75991 | 303 |
index.items.map(item => |
304 |
(List(HTML.link(item.name + "/index.html", HTML.text(item.name))), |
|
305 |
if (item.description.isEmpty) Nil |
|
306 |
else HTML.break ::: List(HTML.pre(HTML.text(item.description)))))))))), |
|
75961 | 307 |
root = Some(root_dir)) |
308 |
} |
|
75953
32c4f8766831
clarified synchronized operations: approximate file-system transactions;
wenzelm
parents:
75952
diff
changeset
|
309 |
|
75961 | 310 |
index.print_json |
311 |
} |
|
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
312 |
} |
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
313 |
|
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
314 |
def update_root(): Unit = synchronized { |
82023
9601f5582f33
more robust wrt. Par_List.map in Browser_Info.build(), see also 2fff9ce6b460 and 787a203a20b6;
wenzelm
parents:
81566
diff
changeset
|
315 |
Meta_Info.init_directory(root_dir, permissive = true) |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
316 |
HTML.init_fonts(root_dir) |
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
317 |
Isabelle_System.copy_file(Path.explode("~~/lib/logo/isabelle.gif"), |
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
318 |
root_dir + Path.explode("isabelle.gif")) |
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
319 |
|
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
320 |
Meta_Info.change(root_dir, Meta_Info.INDEX) { text => |
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
321 |
val index0 = Meta_Info.Index.parse(text, "root") |
75989
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
322 |
val index = { |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
323 |
val items1 = |
75999
b831a0bdd751
clarified signature of Sessions.Session: chapter_defs: vs. known_chapters (in declaration order) vs. chapters (covered by visible sessions);
wenzelm
parents:
75994
diff
changeset
|
324 |
sessions_structure.known_chapters |
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
325 |
.map(ch => Meta_Info.Item(ch.name, description = ch.description)) |
75999
b831a0bdd751
clarified signature of Sessions.Session: chapter_defs: vs. known_chapters (in declaration order) vs. chapters (covered by visible sessions);
wenzelm
parents:
75994
diff
changeset
|
326 |
val items2 = index0.items.filterNot(item => items1.exists(_.name == item.name)) |
b831a0bdd751
clarified signature of Sessions.Session: chapter_defs: vs. known_chapters (in declaration order) vs. chapters (covered by visible sessions);
wenzelm
parents:
75994
diff
changeset
|
327 |
index0.copy(items = items1 ::: items2) |
75989
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
328 |
} |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
329 |
|
75989
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
330 |
if (index != index0) { |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
331 |
val title = "The " + XML.text(Isabelle_System.isabelle_name()) + " Library" |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
332 |
HTML.write_document(root_dir, "index.html", |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
333 |
List(HTML.title(title + Isabelle_System.isabelle_heading())), |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
334 |
HTML.chapter(title) :: |
75991 | 335 |
(if (index.is_empty) Nil |
75989
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
336 |
else |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
337 |
List(HTML.div("sessions", |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
338 |
List(HTML.description( |
75991 | 339 |
index.items.map(item => |
340 |
(List(HTML.link(item.name + "/index.html", HTML.text(item.name))), |
|
341 |
if (item.description.isEmpty) Nil |
|
342 |
else HTML.break ::: List(HTML.pre(HTML.text(item.description)))))))))), |
|
75989
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
343 |
root = Some(root_dir)) |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
344 |
} |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
345 |
|
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
346 |
index.print_json |
46c6f649a943
produce root index based on sessions_structure.chapter_defs;
wenzelm
parents:
75982
diff
changeset
|
347 |
} |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
348 |
} |
72959 | 349 |
} |
350 |
||
75884
3d8b37b1d798
clarified signature: avoid object-oriented HTML_Context;
wenzelm
parents:
75792
diff
changeset
|
351 |
sealed case class HTML_Document(title: String, content: String) |
3d8b37b1d798
clarified signature: avoid object-oriented HTML_Context;
wenzelm
parents:
75792
diff
changeset
|
352 |
|
72957 | 353 |
|
74678 | 354 |
/* formal entities */ |
74677 | 355 |
|
75891 | 356 |
object Theory_Ref { |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
357 |
def unapply(props: Properties.T): Option[String] = |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
358 |
(props, props) match { |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
359 |
case (Markup.Kind(Markup.THEORY), Markup.Name(theory)) => Some(theory) |
75891 | 360 |
case _ => None |
361 |
} |
|
362 |
} |
|
74765 | 363 |
|
75891 | 364 |
object Entity_Ref { |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
365 |
def unapply(props: Properties.T): Option[(String, String, String)] = |
75891 | 366 |
(props, props, props, props) match { |
75913 | 367 |
case (Markup.Entity.Ref.Prop(_), Position.Def_File(file), Markup.Kind(kind), Markup.Name(name)) |
368 |
if Path.is_wellformed(file) => Some((file, kind, name)) |
|
75891 | 369 |
case _ => None |
370 |
} |
|
371 |
} |
|
74765 | 372 |
|
75927 | 373 |
object Node_Context { |
374 |
val empty: Node_Context = new Node_Context |
|
74752
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
375 |
|
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
376 |
def make( |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
377 |
context: Context, |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
378 |
session_name: String, |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
379 |
theory_name: String, |
75929
811092261546
proper node_dir within presentation_dir, not source file directory;
wenzelm
parents:
75928
diff
changeset
|
380 |
file_name: String, |
811092261546
proper node_dir within presentation_dir, not source file directory;
wenzelm
parents:
75928
diff
changeset
|
381 |
node_dir: Path, |
75927 | 382 |
): Node_Context = |
383 |
new Node_Context { |
|
74752
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
384 |
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
|
385 |
|
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
386 |
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
|
387 |
body match { |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
388 |
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
|
389 |
case _ => |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
390 |
for (theory <- context.theory_by_name(session_name, theory_name)) |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
391 |
yield { |
74752
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
392 |
val body1 = |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
393 |
if (seen_ranges.contains(range)) { |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
394 |
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
|
395 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
396 |
else HTML.span(body) |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
397 |
theory.get_defs(file_name, range).foldLeft(body1) { |
75896 | 398 |
case (elem, entity) => |
399 |
HTML.entity_def(HTML.span(HTML.id(entity.kname), List(elem))) |
|
74752
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
400 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
401 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
402 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
403 |
|
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
404 |
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
|
405 |
"offset_" + range.start + ".." + range.stop |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
406 |
|
76009
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
407 |
override def make_file_ref(file: String, body: XML.Body): Option[XML.Elem] = { |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
408 |
for (theory <- context.theory_by_file(session_name, file)) |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
409 |
yield { |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
410 |
val html_path = context.theory_dir(theory) + context.smart_html(theory, file) |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
411 |
val html_link = HTML.relative_href(html_path, base = Some(node_dir)) |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
412 |
HTML.link(html_link, body) |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
413 |
} |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
414 |
} |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
415 |
|
75393 | 416 |
override def make_ref(props: Properties.T, body: XML.Body): Option[XML.Elem] = { |
74765 | 417 |
props match { |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
418 |
case Theory_Ref(thy_name) => |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
419 |
for (theory <- context.theory_by_name(session_name, thy_name)) |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
420 |
yield { |
75946 | 421 |
val html_path = context.theory_dir(theory) + context.theory_html(theory) |
75933 | 422 |
val html_link = HTML.relative_href(html_path, base = Some(node_dir)) |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
423 |
HTML.link(html_link, body) |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
424 |
} |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
425 |
case Entity_Ref(def_file, kind, name) => |
75907 | 426 |
def logical_ref(theory: Document_Info.Theory): Option[String] = |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
427 |
theory.get_def(def_file, kind, name).map(_.kname) |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
428 |
|
75907 | 429 |
def physical_ref(theory: Document_Info.Theory): Option[String] = |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
430 |
props match { |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
431 |
case Position.Def_Range(range) if theory.name == theory_name => |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
432 |
seen_ranges += range |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
433 |
Some(offset_id(range)) |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
434 |
case _ => None |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
435 |
} |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
436 |
|
74752
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
437 |
for { |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
438 |
theory <- context.theory_by_file(session_name, def_file) |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
439 |
html_ref <- logical_ref(theory) orElse physical_ref(theory) |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
440 |
} |
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
441 |
yield { |
75946 | 442 |
val html_path = context.theory_dir(theory) + context.smart_html(theory, def_file) |
75933 | 443 |
val html_link = HTML.relative_href(html_path, base = Some(node_dir)) |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
444 |
HTML.entity_ref(HTML.link(html_link + "#" + html_ref, body)) |
74752
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
445 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
446 |
case _ => None |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
447 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
448 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
449 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
450 |
} |
ebd3a685bfc9
clarified signature: more explicit class Entity_Context with private state + operations;
wenzelm
parents:
74751
diff
changeset
|
451 |
|
75927 | 452 |
class Node_Context { |
74753 | 453 |
def make_def(range: Symbol.Range, body: XML.Body): Option[XML.Elem] = None |
454 |
def make_ref(props: Properties.T, body: XML.Body): Option[XML.Elem] = None |
|
76009
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
455 |
def make_file_ref(file: String, body: XML.Body): Option[XML.Elem] = None |
73055 | 456 |
|
75928 | 457 |
val div_elements: Set[String] = |
458 |
Set(HTML.div.name, HTML.pre.name, HTML.par.name, HTML.list.name, HTML.`enum`.name, |
|
459 |
HTML.descr.name) |
|
72957 | 460 |
|
75928 | 461 |
def make_html(elements: Elements, xml: XML.Body): XML.Body = { |
462 |
def html_div(html: XML.Body): Boolean = |
|
463 |
html exists { |
|
464 |
case XML.Elem(markup, body) => div_elements.contains(markup.name) || html_div(body) |
|
465 |
case XML.Text(_) => false |
|
466 |
} |
|
467 |
||
468 |
def html_class(c: String, html: XML.Body): XML.Body = |
|
469 |
if (c == "") html |
|
470 |
else if (html_div(html)) List(HTML.div(c, html)) |
|
471 |
else List(HTML.span(c, html)) |
|
72957 | 472 |
|
75928 | 473 |
def html_body(xml_body: XML.Body, end_offset: Symbol.Offset): (XML.Body, Symbol.Offset) = |
474 |
xml_body.foldRight((List.empty[XML.Tree], end_offset)) { case (tree, (res, end_offset1)) => |
|
475 |
val (res1, offset) = html_body_single(tree, end_offset1) |
|
476 |
(res1 ++ res, offset) |
|
477 |
} |
|
74677 | 478 |
|
75928 | 479 |
@tailrec |
480 |
def html_body_single(xml_tree: XML.Tree, end_offset: Symbol.Offset): (XML.Body, Symbol.Offset) = |
|
481 |
xml_tree match { |
|
81562
d387683ea725
more accurate HTML markup: suppress text_color that has_syntax (amending b57996a0688c);
wenzelm
parents:
81561
diff
changeset
|
482 |
case XML.Wrapped_Elem(markup, _, body) => |
d387683ea725
more accurate HTML markup: suppress text_color that has_syntax (amending b57996a0688c);
wenzelm
parents:
81561
diff
changeset
|
483 |
html_body_single(XML.Elem(markup, body), end_offset) |
75928 | 484 |
case XML.Elem(Markup(Markup.ENTITY, props @ Markup.Kind(kind)), body) => |
485 |
val (body1, offset) = html_body(body, end_offset) |
|
486 |
if (elements.entity(kind)) { |
|
487 |
make_ref(props, body1) match { |
|
488 |
case Some(link) => (List(link), offset) |
|
489 |
case None => (body1, offset) |
|
490 |
} |
|
73056 | 491 |
} |
75928 | 492 |
else (body1, offset) |
76009
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
493 |
case XML.Elem(Markup.Path(file), body) => |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
494 |
val (body1, offset) = html_body(body, end_offset) |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
495 |
make_file_ref(file, body1) match { |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
496 |
case Some(link) => (List(link), offset) |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
497 |
case None => (body1, offset) |
adf9c4d68581
more links, for files that formally belong to this session;
wenzelm
parents:
76008
diff
changeset
|
498 |
} |
76008 | 499 |
case XML.Elem(Markup.Url(href), body) => |
500 |
val (body1, offset) = html_body(body, end_offset) |
|
501 |
(List(HTML.link(href, body1)), offset) |
|
75928 | 502 |
case XML.Elem(Markup(Markup.LANGUAGE, Markup.Name(name)), body) => |
503 |
val (body1, offset) = html_body(body, end_offset) |
|
504 |
(html_class(if (elements.language(name)) name else "", body1), offset) |
|
505 |
case XML.Elem(Markup(Markup.MARKDOWN_PARAGRAPH, _), body) => |
|
506 |
val (body1, offset) = html_body(body, end_offset) |
|
507 |
(List(HTML.par(body1)), offset) |
|
508 |
case XML.Elem(Markup(Markup.MARKDOWN_ITEM, _), body) => |
|
509 |
val (body1, offset) = html_body(body, end_offset) |
|
510 |
(List(HTML.item(body1)), offset) |
|
511 |
case XML.Elem(Markup(Markup.Markdown_Bullet.name, _), text) => |
|
512 |
(Nil, end_offset - XML.symbol_length(text)) |
|
513 |
case XML.Elem(Markup.Markdown_List(kind), body) => |
|
514 |
val (body1, offset) = html_body(body, end_offset) |
|
515 |
if (kind == Markup.ENUMERATE) (List(HTML.`enum`(body1)), offset) |
|
516 |
else (List(HTML.list(body1)), offset) |
|
517 |
case XML.Elem(markup, body) => |
|
518 |
val (body1, offset) = html_body(body, end_offset) |
|
519 |
val html = |
|
520 |
markup.properties match { |
|
521 |
case Markup.Kind(kind) if kind == Markup.COMMAND || kind == Markup.KEYWORD => |
|
522 |
html_class(kind, body1) |
|
523 |
case _ => |
|
524 |
body1 |
|
525 |
} |
|
81562
d387683ea725
more accurate HTML markup: suppress text_color that has_syntax (amending b57996a0688c);
wenzelm
parents:
81561
diff
changeset
|
526 |
val c = |
81564
56075edacb10
tuned: more robust wrt. changes the Markup space;
wenzelm
parents:
81562
diff
changeset
|
527 |
if (Markup.has_syntax(markup.properties)) "" |
56075edacb10
tuned: more robust wrt. changes the Markup space;
wenzelm
parents:
81562
diff
changeset
|
528 |
else { |
56075edacb10
tuned: more robust wrt. changes the Markup space;
wenzelm
parents:
81562
diff
changeset
|
529 |
Rendering.get_foreground_text_color(markup) match { |
56075edacb10
tuned: more robust wrt. changes the Markup space;
wenzelm
parents:
81562
diff
changeset
|
530 |
case Some(color) => color.toString |
56075edacb10
tuned: more robust wrt. changes the Markup space;
wenzelm
parents:
81562
diff
changeset
|
531 |
case None => markup.name |
56075edacb10
tuned: more robust wrt. changes the Markup space;
wenzelm
parents:
81562
diff
changeset
|
532 |
} |
81562
d387683ea725
more accurate HTML markup: suppress text_color that has_syntax (amending b57996a0688c);
wenzelm
parents:
81561
diff
changeset
|
533 |
} |
d387683ea725
more accurate HTML markup: suppress text_color that has_syntax (amending b57996a0688c);
wenzelm
parents:
81561
diff
changeset
|
534 |
(html_class(c, html), offset) |
75928 | 535 |
case XML.Text(text) => |
536 |
val offset = end_offset - Symbol.length(text) |
|
537 |
val body = HTML.text(Symbol.decode(text)) |
|
538 |
make_def(Text.Range(offset, end_offset), body) match { |
|
539 |
case Some(body1) => (List(body1), offset) |
|
540 |
case None => (body, offset) |
|
541 |
} |
|
542 |
} |
|
73054 | 543 |
|
75928 | 544 |
html_body(xml, XML.symbol_length(xml) + 1)._1 |
545 |
} |
|
73054 | 546 |
} |
72957 | 547 |
|
548 |
||
549 |
||
75945 | 550 |
/** build presentation **/ |
72649 | 551 |
|
75888 | 552 |
val session_graph_path: Path = Path.explode("session_graph.pdf") |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
553 |
|
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
554 |
def build_session( |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
555 |
context: Context, |
75778
d18c96b9b955
prefer Export.Context/Session_Context/Theory_Context over Sessions.Database_Context;
wenzelm
parents:
75774
diff
changeset
|
556 |
session_context: Export.Session_Context, |
72992 | 557 |
progress: Progress = new Progress, |
75393 | 558 |
): Unit = { |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
559 |
progress.expose_interrupt() |
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
560 |
|
75902 | 561 |
val session_name = session_context.session_name |
562 |
val session_info = session_context.sessions_structure(session_name) |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
563 |
|
75961 | 564 |
val session_dir = context.session_dir(session_name).expand |
565 |
progress.echo("Presenting " + session_name + " in " + session_dir + " ...") |
|
75899
d50c2129e73a
more robust directory structure: always relative to session_dir;
wenzelm
parents:
75898
diff
changeset
|
566 |
|
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
567 |
Meta_Info.init_directory(context.chapter_dir(session_name)) |
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
568 |
Meta_Info.clean_directory(session_dir) |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
569 |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
570 |
val session = context.document_info.the_session(session_name) |
75905
2ee3ea69e8f1
clarified Presentation.Nodes, with explicit Nodes.Session and Nodes.Theory;
wenzelm
parents:
75902
diff
changeset
|
571 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
572 |
Bytes.write(session_dir + session_graph_path, |
75902 | 573 |
graphview.Graph_File.make_pdf(session_info.options, |
574 |
session_context.session_base.session_graph_display)) |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
575 |
|
75925 | 576 |
val document_variants = |
72683 | 577 |
for { |
75902 | 578 |
doc <- session_info.document_variants |
75780
f49c4f160b84
clarified signature: find session_database within Session_Context.db_hierarchy;
wenzelm
parents:
75778
diff
changeset
|
579 |
db <- session_context.session_db() |
75902 | 580 |
document <- Document_Build.read_document(db, session_name, doc.name) |
75899
d50c2129e73a
more robust directory structure: always relative to session_dir;
wenzelm
parents:
75898
diff
changeset
|
581 |
} |
d50c2129e73a
more robust directory structure: always relative to session_dir;
wenzelm
parents:
75898
diff
changeset
|
582 |
yield { |
d50c2129e73a
more robust directory structure: always relative to session_dir;
wenzelm
parents:
75898
diff
changeset
|
583 |
val doc_path = session_dir + doc.path.pdf |
75926
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
584 |
if (Path.eq_case_insensitive(doc.path.pdf, session_graph_path)) { |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
585 |
error("Illegal document variant " + quote(doc.name) + |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
586 |
" (conflict with " + session_graph_path + ")") |
b8ee1ef948c2
more thorough checks of browser_info file conflicts;
wenzelm
parents:
75925
diff
changeset
|
587 |
} |
77521
5642de4d225d
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
77202
diff
changeset
|
588 |
progress.echo("Presenting document " + session_name + "/" + doc.name, verbose = true) |
75902 | 589 |
if (session_info.document_echo) progress.echo("Document at " + doc_path) |
74732
015282fb3e31
clarified messages, depending on option "document_echo";
wenzelm
parents:
74731
diff
changeset
|
590 |
Bytes.write(doc_path, document.pdf) |
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
591 |
doc |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
592 |
} |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
593 |
|
75925 | 594 |
val document_links = { |
595 |
val link1 = HTML.link(session_graph_path, HTML.text("theory dependencies")) |
|
596 |
val links2 = document_variants.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
|
597 |
Library.separate(HTML.break ::: HTML.nl, |
75925 | 598 |
(link1 :: links2).map(link => HTML.text("View ") ::: List(link))).flatten |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
599 |
} |
62971
087e36ce0593
back to exact copy of non-text file (amending dcc8e1d34b18);
wenzelm
parents:
62631
diff
changeset
|
600 |
|
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
601 |
def present_theory(theory_name: String): XML.Body = { |
74795
5eac4b13d1f1
less ambitious parallelism: more direct read/write saves overall heap space and GC time;
wenzelm
parents:
74782
diff
changeset
|
602 |
progress.expose_interrupt() |
73215 | 603 |
|
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
604 |
def err(): Nothing = |
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
605 |
error("Missing document information for theory: " + quote(theory_name)) |
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
606 |
|
78280 | 607 |
val snapshot = Build.read_theory(session_context.theory(theory_name)) getOrElse err() |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
608 |
val theory = context.theory_by_name(session_name, theory_name) getOrElse err() |
74795
5eac4b13d1f1
less ambitious parallelism: more direct read/write saves overall heap space and GC time;
wenzelm
parents:
74782
diff
changeset
|
609 |
|
77521
5642de4d225d
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
77202
diff
changeset
|
610 |
progress.echo("Presenting theory " + quote(theory_name), verbose = true) |
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
611 |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
612 |
val thy_elements = theory.elements(context.elements) |
73215 | 613 |
|
75929
811092261546
proper node_dir within presentation_dir, not source file directory;
wenzelm
parents:
75928
diff
changeset
|
614 |
def node_context(file_name: String, node_dir: Path): Node_Context = |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
615 |
Node_Context.make(context, session_name, theory_name, file_name, node_dir) |
75928 | 616 |
|
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
617 |
val thy_html = |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
618 |
context.source( |
75929
811092261546
proper node_dir within presentation_dir, not source file directory;
wenzelm
parents:
75928
diff
changeset
|
619 |
node_context(theory.thy_file, session_dir). |
75928 | 620 |
make_html(thy_elements, snapshot.xml_markup(elements = thy_elements.html))) |
75899
d50c2129e73a
more robust directory structure: always relative to session_dir;
wenzelm
parents:
75898
diff
changeset
|
621 |
|
76937
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
622 |
val master_dir = Path.explode(snapshot.node_name.master_dir) |
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
623 |
|
75931 | 624 |
val files = |
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
625 |
for { |
76930 | 626 |
blob_name <- snapshot.node_files.tail |
627 |
xml = snapshot.switch(blob_name).xml_markup(elements = thy_elements.html) |
|
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
628 |
if xml.nonEmpty |
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
629 |
} |
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
630 |
yield { |
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
631 |
progress.expose_interrupt() |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
632 |
|
76937
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
633 |
val file = blob_name.node |
77521
5642de4d225d
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
77202
diff
changeset
|
634 |
progress.echo("Presenting file " + quote(file), verbose = true) |
74715
129fb11b357f
use all entity kinds from theory export, e.g. "method", "attribute";
wenzelm
parents:
74714
diff
changeset
|
635 |
|
76937
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
636 |
val file_html = session_dir + context.file_html(file) |
75932 | 637 |
val file_dir = file_html.dir |
75933 | 638 |
val html_link = HTML.relative_href(file_html, base = Some(session_dir)) |
76937
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
639 |
val html = context.source(node_context(file, file_dir).make_html(thy_elements, xml)) |
75931 | 640 |
|
76937
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
641 |
val path = Path.explode(file) |
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
642 |
val src_path = File.relative_path(master_dir, path).getOrElse(path) |
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
643 |
|
099486b09c0e
prefer relative src_path (if possible) -- in contrast to 9ce0aa145d21:
wenzelm
parents:
76933
diff
changeset
|
644 |
val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short) |
75932 | 645 |
HTML.write_document(file_dir, file_html.file_name, |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
646 |
List(HTML.title(file_title)), List(context.head(file_title), html), |
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
647 |
root = Some(context.root_dir)) |
75931 | 648 |
List(HTML.link(html_link, HTML.text(file_title))) |
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
649 |
} |
73215 | 650 |
|
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
651 |
val thy_title = "Theory " + theory.print_short |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
652 |
HTML.write_document(session_dir, context.theory_html(theory).implode, |
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
653 |
List(HTML.title(thy_title)), List(context.head(thy_title), thy_html), |
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
654 |
root = Some(context.root_dir)) |
73215 | 655 |
|
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
656 |
List(HTML.link(context.theory_html(theory), |
75925 | 657 |
HTML.text(theory.print_short) ::: |
658 |
(if (files.isEmpty) Nil else List(HTML.itemize(files))))) |
|
72989 | 659 |
} |
61500 | 660 |
|
75924
1402a1696dca
prefer strict operations with explicit errors (instead of missing HTML output);
wenzelm
parents:
75917
diff
changeset
|
661 |
val theories = session.used_theories.map(present_theory) |
74795
5eac4b13d1f1
less ambitious parallelism: more direct read/write saves overall heap space and GC time;
wenzelm
parents:
74782
diff
changeset
|
662 |
|
75902 | 663 |
val title = "Session " + session_name |
75899
d50c2129e73a
more robust directory structure: always relative to session_dir;
wenzelm
parents:
75898
diff
changeset
|
664 |
HTML.write_document(session_dir, "index.html", |
d50c2129e73a
more robust directory structure: always relative to session_dir;
wenzelm
parents:
75898
diff
changeset
|
665 |
List(HTML.title(title + Isabelle_System.isabelle_heading())), |
75942
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
666 |
context.head(title, List(HTML.par(document_links))) :: |
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
667 |
context.contents("Theories", theories), |
603852abed8f
clarified names: Browser_Info.Config vs. Browser_Info.Context;
wenzelm
parents:
75941
diff
changeset
|
668 |
root = Some(context.root_dir)) |
75961 | 669 |
|
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
670 |
Meta_Info.set_build_uuid(session_dir, session.build_uuid) |
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
671 |
|
75980 | 672 |
context.update_chapter(session_name, session_info.description) |
61372 | 673 |
} |
75947 | 674 |
|
675 |
def build( |
|
676 |
browser_info: Config, |
|
78178 | 677 |
store: Store, |
75947 | 678 |
deps: Sessions.Deps, |
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
679 |
sessions: List[String], |
78379 | 680 |
progress: Progress = new Progress, |
681 |
server: SSH.Server = SSH.no_server |
|
75947 | 682 |
): Unit = { |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
683 |
val root_dir = browser_info.presentation_dir(store).absolute |
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
684 |
progress.echo("Presentation in " + root_dir) |
75947 | 685 |
|
78379 | 686 |
using(Export.open_database_context(store, server = server)) { database_context => |
75979 | 687 |
val context0 = context(deps.sessions_structure, root_dir = root_dir) |
75947 | 688 |
|
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
689 |
val sessions1 = |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
690 |
deps.sessions_structure.build_requirements(sessions).filter { session_name => |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
691 |
using(database_context.open_database(session_name)) { session_database => |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
692 |
database_context.store.read_build(session_database.db, session_name) match { |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
693 |
case None => false |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
694 |
case Some(build) => |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
695 |
val session_dir = context0.session_dir(session_name) |
77202
064566bc1f35
clarified signature: follow terminology of isabelle.Sessions and isabelle.Build;
wenzelm
parents:
76937
diff
changeset
|
696 |
!Meta_Info.check_build_uuid(session_dir, build.uuid) |
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
697 |
} |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
698 |
} |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
699 |
} |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
700 |
|
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
701 |
val context1 = |
75979 | 702 |
context(deps.sessions_structure, root_dir = root_dir, |
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
703 |
document_info = Document_Info.read(database_context, deps, sessions1)) |
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
704 |
|
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
705 |
context1.update_root() |
75952
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
706 |
|
864b10457a7d
more robust concurrency: use shared Browser_Info.Context with synchronized file-system operations;
wenzelm
parents:
75949
diff
changeset
|
707 |
Par_List.map({ (session: String) => |
76656 | 708 |
using(database_context.open_session(deps.background(session))) { session_context => |
77521
5642de4d225d
clarified signature: manage "verbose" flag via "progress";
wenzelm
parents:
77202
diff
changeset
|
709 |
build_session(context1, session_context, progress = progress) |
75947 | 710 |
} |
75971
cec22f403c25
more accurate management of dependencies: change of build_uuid causes output of HTML, but already existing/current HTML is not produced again;
wenzelm
parents:
75969
diff
changeset
|
711 |
}, sessions1) |
75947 | 712 |
} |
713 |
} |
|
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
714 |
} |