author | wenzelm |
Sun, 03 Jan 2021 16:21:59 +0100 | |
changeset 73036 | b028e8d22d8d |
parent 73028 | 95e0f014cd24 |
child 73041 | 66b45c3389d3 |
permissions | -rw-r--r-- |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/Thy/present.scala |
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 |
|
72957 | 4 |
HTML/PDF presentation of theory documents. |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
6 |
|
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
8 |
|
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
9 |
|
51402 | 10 |
import scala.collection.immutable.SortedMap |
11 |
||
12 |
||
72652 | 13 |
object Presentation |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
14 |
{ |
72957 | 15 |
/** HTML documents **/ |
16 |
||
72962 | 17 |
val fonts_path = Path.explode("fonts") |
18 |
||
72957 | 19 |
sealed case class HTML_Document(title: String, content: String) |
20 |
||
72959 | 21 |
def html_context(fonts_url: String => String = HTML.fonts_url()): HTML_Context = |
22 |
new HTML_Context(fonts_url) |
|
23 |
||
24 |
final class HTML_Context private[Presentation](fonts_url: String => String) |
|
25 |
{ |
|
72962 | 26 |
def init_fonts(dir: Path) |
27 |
{ |
|
28 |
val fonts_dir = Isabelle_System.make_directory(dir + fonts_path) |
|
29 |
for (entry <- Isabelle_Fonts.fonts(hidden = true)) |
|
30 |
File.copy(entry.path, fonts_dir) |
|
31 |
} |
|
32 |
||
33 |
def head(title: String, rest: XML.Body = Nil): XML.Tree = |
|
34 |
HTML.div("head", HTML.chapter(title) :: rest) |
|
35 |
||
36 |
def source(body: XML.Body): XML.Tree = HTML.pre("source", body) |
|
37 |
||
38 |
def contents(heading: String, items: List[XML.Body], css_class: String = "contents") |
|
39 |
: List[XML.Elem] = |
|
40 |
{ |
|
41 |
if (items.isEmpty) Nil |
|
42 |
else List(HTML.div(css_class, List(HTML.section(heading), HTML.itemize(items)))) |
|
43 |
} |
|
44 |
||
72959 | 45 |
def output_document(title: String, body: XML.Body): String = |
46 |
HTML.output_document( |
|
47 |
List( |
|
48 |
HTML.style(HTML.fonts_css(fonts_url) + "\n\n" + File.read(HTML.isabelle_css)), |
|
49 |
HTML.title(title)), |
|
50 |
List(HTML.source(body)), css = "", structural = false) |
|
51 |
||
52 |
def html_document(title: String, body: XML.Body): HTML_Document = |
|
53 |
HTML_Document(title, output_document(title, body)) |
|
54 |
} |
|
55 |
||
72957 | 56 |
|
57 |
/* HTML body */ |
|
58 |
||
73036 | 59 |
val html_elements1: Markup.Elements = |
60 |
Rendering.foreground_elements ++ Rendering.text_color_elements + |
|
61 |
Markup.NUMERAL + Markup.COMMENT |
|
62 |
||
63 |
val html_elements2: Markup.Elements = |
|
64 |
html_elements1 ++ Rendering.markdown_elements + Markup.LANGUAGE |
|
65 |
||
72957 | 66 |
private val div_elements = |
67 |
Set(HTML.div.name, HTML.pre.name, HTML.par.name, HTML.list.name, HTML.enum.name, |
|
68 |
HTML.descr.name) |
|
69 |
||
70 |
private def html_div(html: XML.Body): Boolean = |
|
71 |
html exists { |
|
72 |
case XML.Elem(markup, body) => div_elements.contains(markup.name) || html_div(body) |
|
73 |
case XML.Text(_) => false |
|
74 |
} |
|
75 |
||
76 |
private def html_class(c: String, html: XML.Body): XML.Tree = |
|
73028 | 77 |
if (html.forall(_ == XML.no_text)) XML.no_text |
72957 | 78 |
else if (html_div(html)) HTML.div(c, html) |
79 |
else HTML.span(c, html) |
|
80 |
||
81 |
private def html_body(xml: XML.Body): XML.Body = |
|
82 |
xml map { |
|
83 |
case XML.Elem(Markup(Markup.LANGUAGE, Markup.Name(Markup.Language.DOCUMENT)), body) => |
|
84 |
html_class(Markup.Language.DOCUMENT, html_body(body)) |
|
85 |
case XML.Elem(Markup(Markup.MARKDOWN_PARAGRAPH, _), body) => HTML.par(html_body(body)) |
|
86 |
case XML.Elem(Markup(Markup.MARKDOWN_ITEM, _), body) => HTML.item(html_body(body)) |
|
73028 | 87 |
case XML.Elem(Markup(Markup.Markdown_Bullet.name, _), _) => XML.no_text |
72957 | 88 |
case XML.Elem(Markup.Markdown_List(kind), body) => |
89 |
if (kind == Markup.ENUMERATE) HTML.enum(html_body(body)) else HTML.list(html_body(body)) |
|
90 |
case XML.Elem(markup, body) => |
|
91 |
val name = markup.name |
|
92 |
val html = |
|
93 |
markup.properties match { |
|
94 |
case Markup.Kind(kind) if kind == Markup.COMMAND || kind == Markup.KEYWORD => |
|
95 |
List(html_class(kind, html_body(body))) |
|
96 |
case _ => |
|
97 |
html_body(body) |
|
98 |
} |
|
99 |
Rendering.foreground.get(name) orElse Rendering.text_color.get(name) match { |
|
100 |
case Some(c) => html_class(c.toString, html) |
|
101 |
case None => html_class(name, html) |
|
102 |
} |
|
103 |
case XML.Text(text) => |
|
104 |
XML.Text(Symbol.decode(text)) |
|
105 |
} |
|
106 |
||
107 |
||
108 |
/* PIDE HTML document */ |
|
109 |
||
110 |
def html_document( |
|
111 |
resources: Resources, |
|
112 |
snapshot: Document.Snapshot, |
|
72962 | 113 |
html_context: HTML_Context, |
73036 | 114 |
html_elements: Markup.Elements, |
72959 | 115 |
plain_text: Boolean = false): HTML_Document = |
72957 | 116 |
{ |
117 |
require(!snapshot.is_outdated) |
|
118 |
||
119 |
val name = snapshot.node_name |
|
120 |
if (plain_text) { |
|
72962 | 121 |
val title = "File " + Symbol.cartouche_decoded(name.path.file_name) |
72959 | 122 |
val body = HTML.text(snapshot.node.source) |
72962 | 123 |
html_context.html_document(title, body) |
72957 | 124 |
} |
125 |
else { |
|
72962 | 126 |
resources.html_document(snapshot) getOrElse { |
127 |
val title = |
|
128 |
if (name.is_theory) "Theory " + quote(name.theory_base_name) |
|
129 |
else "File " + Symbol.cartouche_decoded(name.path.file_name) |
|
130 |
val body = html_body(snapshot.xml_markup(elements = html_elements)) |
|
131 |
html_context.html_document(title, body) |
|
72957 | 132 |
} |
133 |
} |
|
134 |
} |
|
135 |
||
136 |
||
137 |
||
138 |
/** PDF LaTeX documents **/ |
|
139 |
||
72696 | 140 |
/* document info */ |
72649 | 141 |
|
72696 | 142 |
abstract class Document_Name |
143 |
{ |
|
144 |
def name: String |
|
145 |
def path: Path = Path.basic(name) |
|
146 |
||
147 |
override def toString: String = name |
|
148 |
} |
|
72683 | 149 |
|
72649 | 150 |
object Document_Variant |
151 |
{ |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
152 |
def parse(name: String, tags: String): Document_Variant = |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
153 |
Document_Variant(name, Library.space_explode(',', tags)) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
154 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
155 |
def parse(opt: String): Document_Variant = |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
156 |
Library.space_explode('=', opt) match { |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
157 |
case List(name) => Document_Variant(name, Nil) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
158 |
case List(name, tags) => parse(name, tags) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
159 |
case _ => error("Malformed document variant: " + quote(opt)) |
72649 | 160 |
} |
161 |
} |
|
162 |
||
72696 | 163 |
sealed case class Document_Variant(name: String, tags: List[String]) extends Document_Name |
72649 | 164 |
{ |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
165 |
def print_tags: String = tags.mkString(",") |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
166 |
def print: String = if (tags.isEmpty) name else name + "=" + print_tags |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
167 |
|
72649 | 168 |
def latex_sty: String = |
169 |
Library.terminate_lines( |
|
170 |
tags.map(tag => |
|
171 |
tag.toList match { |
|
172 |
case '/' :: cs => "\\isafoldtag{" + cs.mkString + "}" |
|
173 |
case '-' :: cs => "\\isadroptag{" + cs.mkString + "}" |
|
174 |
case '+' :: cs => "\\isakeeptag{" + cs.mkString + "}" |
|
175 |
case cs => "\\isakeeptag{" + cs.mkString + "}" |
|
176 |
})) |
|
72696 | 177 |
} |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
178 |
|
72696 | 179 |
sealed case class Document_Input(name: String, sources: SHA1.Digest) |
180 |
extends Document_Name |
|
181 |
||
182 |
sealed case class Document_Output(name: String, sources: SHA1.Digest, log_xz: Bytes, pdf: Bytes) |
|
183 |
extends Document_Name |
|
184 |
{ |
|
185 |
def log: String = log_xz.uncompress().text |
|
72699 | 186 |
def log_lines: List[String] = split_lines(log) |
72700 | 187 |
|
72880 | 188 |
def write(db: SQL.Database, session_name: String): Unit = |
72700 | 189 |
write_document(db, session_name, this) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
190 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
191 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
192 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
193 |
/* SQL data model */ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
194 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
195 |
object Data |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
196 |
{ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
197 |
val session_name = SQL.Column.string("session_name").make_primary_key |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
198 |
val name = SQL.Column.string("name").make_primary_key |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
199 |
val sources = SQL.Column.string("sources") |
72696 | 200 |
val log_xz = SQL.Column.bytes("log_xz") |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
201 |
val pdf = SQL.Column.bytes("pdf") |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
202 |
|
72696 | 203 |
val table = SQL.Table("isabelle_documents", List(session_name, name, sources, log_xz, pdf)) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
204 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
205 |
def where_equal(session_name: String, name: String = ""): SQL.Source = |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
206 |
"WHERE " + Data.session_name.equal(session_name) + |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
207 |
(if (name == "") "" else " AND " + Data.name.equal(name)) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
208 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
209 |
|
72696 | 210 |
def read_documents(db: SQL.Database, session_name: String): List[Document_Input] = |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
211 |
{ |
72696 | 212 |
val select = Data.table.select(List(Data.name, Data.sources), Data.where_equal(session_name)) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
213 |
db.using_statement(select)(stmt => |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
214 |
stmt.execute_query().iterator(res => |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
215 |
{ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
216 |
val name = res.string(Data.name) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
217 |
val sources = res.string(Data.sources) |
72696 | 218 |
Document_Input(name, SHA1.fake(sources)) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
219 |
}).toList) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
220 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
221 |
|
72696 | 222 |
def read_document(db: SQL.Database, session_name: String, name: String): Option[Document_Output] = |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
223 |
{ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
224 |
val select = Data.table.select(sql = Data.where_equal(session_name, name)) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
225 |
db.using_statement(select)(stmt => |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
226 |
{ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
227 |
val res = stmt.execute_query() |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
228 |
if (res.next()) { |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
229 |
val name = res.string(Data.name) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
230 |
val sources = res.string(Data.sources) |
72696 | 231 |
val log_xz = res.bytes(Data.log_xz) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
232 |
val pdf = res.bytes(Data.pdf) |
72696 | 233 |
Some(Document_Output(name, SHA1.fake(sources), log_xz, pdf)) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
234 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
235 |
else None |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
236 |
}) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
237 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
238 |
|
72696 | 239 |
def write_document(db: SQL.Database, session_name: String, doc: Document_Output) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
240 |
{ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
241 |
db.using_statement(Data.table.insert())(stmt => |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
242 |
{ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
243 |
stmt.string(1) = session_name |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
244 |
stmt.string(2) = doc.name |
72696 | 245 |
stmt.string(3) = doc.sources.toString |
246 |
stmt.bytes(4) = doc.log_xz |
|
247 |
stmt.bytes(5) = doc.pdf |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
248 |
stmt.execute() |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
249 |
}) |
72649 | 250 |
} |
251 |
||
252 |
||
72648 | 253 |
/* presentation context */ |
254 |
||
255 |
object Context |
|
256 |
{ |
|
257 |
val none: Context = new Context { def enabled: Boolean = false } |
|
258 |
val standard: Context = new Context { def enabled: Boolean = true } |
|
259 |
||
260 |
def dir(path: Path): Context = |
|
261 |
new Context { |
|
262 |
def enabled: Boolean = true |
|
263 |
override def dir(store: Sessions.Store): Path = path |
|
264 |
} |
|
265 |
||
266 |
def make(s: String): Context = |
|
267 |
if (s == ":") standard else dir(Path.explode(s)) |
|
268 |
} |
|
269 |
||
270 |
abstract class Context private |
|
271 |
{ |
|
272 |
def enabled: Boolean |
|
273 |
def enabled(info: Sessions.Info): Boolean = enabled || info.browser_info |
|
274 |
def dir(store: Sessions.Store): Path = store.presentation_dir |
|
275 |
def dir(store: Sessions.Store, info: Sessions.Info): Path = |
|
72670 | 276 |
dir(store) + Path.explode(info.chapter_session) |
72648 | 277 |
} |
278 |
||
279 |
||
72957 | 280 |
|
281 |
/** HTML presentation **/ |
|
282 |
||
72955
942bf91545fa
clarified comments: file-system access is always unsynchronized;
wenzelm
parents:
72882
diff
changeset
|
283 |
/* maintain chapter index */ |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
284 |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
285 |
private val sessions_path = Path.basic(".sessions") |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
286 |
|
51402 | 287 |
private def read_sessions(dir: Path): List[(String, String)] = |
288 |
{ |
|
51416 | 289 |
val path = dir + sessions_path |
290 |
if (path.is_file) { |
|
291 |
import XML.Decode._ |
|
65344
b99283eed13c
clarified YXML vs. symbol encoding: operate on whole message;
wenzelm
parents:
65089
diff
changeset
|
292 |
list(pair(string, string))(Symbol.decode_yxml(File.read(path))) |
51416 | 293 |
} |
294 |
else Nil |
|
51402 | 295 |
} |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
296 |
|
51402 | 297 |
private def write_sessions(dir: Path, sessions: List[(String, String)]) |
298 |
{ |
|
299 |
import XML.Encode._ |
|
300 |
File.write(dir + sessions_path, YXML.string_of_body(list(pair(string, string))(sessions))) |
|
301 |
} |
|
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
302 |
|
61372 | 303 |
def update_chapter_index(browser_info: Path, chapter: String, new_sessions: List[(String, String)]) |
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
304 |
{ |
72376 | 305 |
val dir = Isabelle_System.make_directory(browser_info + Path.basic(chapter)) |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
306 |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
307 |
val sessions0 = |
51406
950b897f95bb
proper path -- I/O was hidden due to permissiveness;
wenzelm
parents:
51402
diff
changeset
|
308 |
try { read_sessions(dir) } |
51987 | 309 |
catch { case _: XML.Error => Nil } |
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
310 |
|
51402 | 311 |
val sessions = (SortedMap.empty[String, String] ++ sessions0 ++ new_sessions).toList |
65988 | 312 |
write_sessions(dir, sessions) |
51402 | 313 |
|
65988 | 314 |
val title = "Isabelle/" + chapter + " sessions" |
315 |
HTML.write_document(dir, "index.html", |
|
316 |
List(HTML.title(title + " (" + Distribution.version + ")")), |
|
317 |
HTML.chapter(title) :: |
|
318 |
(if (sessions.isEmpty) Nil |
|
319 |
else |
|
65992 | 320 |
List(HTML.div("sessions", |
321 |
List(HTML.description( |
|
65988 | 322 |
sessions.map({ case (name, description) => |
69318 | 323 |
val descr = Symbol.trim_blank_lines(description) |
65989 | 324 |
(List(HTML.link(name + "/index.html", HTML.text(name))), |
69318 | 325 |
if (descr == "") Nil |
326 |
else HTML.break ::: List(HTML.pre(HTML.text(descr)))) }))))))) |
|
51399
6ac3c29a300e
discontinued "isabelle usedir" option -r (reset session path);
wenzelm
parents:
50707
diff
changeset
|
327 |
} |
61372 | 328 |
|
329 |
def make_global_index(browser_info: Path) |
|
330 |
{ |
|
331 |
if (!(browser_info + Path.explode("index.html")).is_file) { |
|
72375 | 332 |
Isabelle_System.make_directory(browser_info) |
61372 | 333 |
File.copy(Path.explode("~~/lib/logo/isabelle.gif"), |
334 |
browser_info + Path.explode("isabelle.gif")) |
|
335 |
File.write(browser_info + Path.explode("index.html"), |
|
336 |
File.read(Path.explode("~~/lib/html/library_index_header.template")) + |
|
337 |
File.read(Path.explode("~~/lib/html/library_index_content.template")) + |
|
338 |
File.read(Path.explode("~~/lib/html/library_index_footer.template"))) |
|
339 |
} |
|
340 |
} |
|
341 |
||
342 |
||
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
343 |
/* present session */ |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
344 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
345 |
val session_graph_path = Path.explode("session_graph.pdf") |
72959 | 346 |
val readme_path = Path.explode("README.html") |
347 |
val files_path = Path.explode("files") |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
348 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
349 |
def html_name(name: Document.Node.Name): String = name.theory_base_name + ".html" |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
350 |
|
72669 | 351 |
def token_markups(keywords: Keyword.Keywords, tok: Token): List[String] = { |
352 |
if (keywords.is_command(tok, Keyword.theory_end)) |
|
353 |
List(Markup.KEYWORD2, Markup.KEYWORD) |
|
354 |
else if (keywords.is_command(tok, Keyword.proof_asm)) |
|
355 |
List(Markup.KEYWORD3, Markup.COMMAND) |
|
356 |
else if (keywords.is_command(tok, Keyword.improper)) |
|
357 |
List(Markup.KEYWORD1, Markup.IMPROPER, Markup.COMMAND) |
|
358 |
else if (tok.is_command) List(Markup.KEYWORD1, Markup.COMMAND) |
|
359 |
else if (tok.is_delimiter) List(Markup.DELIMITER, Markup.KEYWORD) |
|
360 |
else if (tok.is_keyword) List(Markup.KEYWORD2, Markup.KEYWORD) |
|
361 |
else if (tok.is_comment) List(Markup.COMMENT) |
|
362 |
else { |
|
363 |
tok.kind match { |
|
364 |
case Token.Kind.VAR => List(Markup.VAR) |
|
365 |
case Token.Kind.TYPE_IDENT => List(Markup.TFREE) |
|
366 |
case Token.Kind.TYPE_VAR => List(Markup.TVAR) |
|
367 |
case Token.Kind.STRING => List(Markup.STRING) |
|
368 |
case Token.Kind.ALT_STRING => List(Markup.ALT_STRING) |
|
369 |
case Token.Kind.VERBATIM => List(Markup.VERBATIM) |
|
370 |
case Token.Kind.CARTOUCHE => List(Markup.CARTOUCHE) |
|
371 |
case _ => Nil |
|
372 |
} |
|
373 |
} |
|
374 |
} |
|
61372 | 375 |
|
72648 | 376 |
def session_html( |
72962 | 377 |
resources: Resources, |
72648 | 378 |
session: String, |
379 |
deps: Sessions.Deps, |
|
72683 | 380 |
db_context: Sessions.Database_Context, |
72992 | 381 |
progress: Progress = new Progress, |
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
382 |
verbose: Boolean = false, |
72962 | 383 |
html_context: HTML_Context, |
73036 | 384 |
html_elements: Markup.Elements, |
72683 | 385 |
presentation: Context) |
61372 | 386 |
{ |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
387 |
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
|
388 |
val options = info.options |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
389 |
val base = deps(session) |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
390 |
|
72683 | 391 |
val session_dir = presentation.dir(db_context.store, info) |
72962 | 392 |
|
393 |
html_context.init_fonts(session_dir) |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
394 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
395 |
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
|
396 |
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
|
397 |
|
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
398 |
val documents = |
72683 | 399 |
for { |
400 |
doc <- info.document_variants |
|
72716 | 401 |
document <- db_context.input_database(session)(read_document(_, _, doc.name)) |
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
402 |
} yield { |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
403 |
if (verbose) progress.echo("Presenting document " + session + "/" + doc.name) |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
404 |
Bytes.write(session_dir + doc.path.pdf, document.pdf) |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
405 |
doc |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
406 |
} |
72673
8ff7a0e394f9
clarified PDF/HTML presentation, based on pdf blobs from session database (e.g. from earlier builds);
wenzelm
parents:
72670
diff
changeset
|
407 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
408 |
val links = |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
409 |
{ |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
410 |
val deps_link = |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
411 |
HTML.link(session_graph_path, HTML.text("theory dependencies")) |
61372 | 412 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
413 |
val readme_links = |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
414 |
if ((info.dir + readme_path).is_file) { |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
415 |
File.copy(info.dir + readme_path, session_dir + readme_path) |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
416 |
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
|
417 |
} |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
418 |
else Nil |
62971
087e36ce0593
back to exact copy of non-text file (amending dcc8e1d34b18);
wenzelm
parents:
62631
diff
changeset
|
419 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
420 |
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
|
421 |
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
|
422 |
|
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
423 |
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
|
424 |
(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
|
425 |
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
|
426 |
} |
62971
087e36ce0593
back to exact copy of non-text file (amending dcc8e1d34b18);
wenzelm
parents:
62631
diff
changeset
|
427 |
|
72669 | 428 |
def theory_link(name1: Document.Node.Name, body: XML.Body): XML.Tree = |
429 |
{ |
|
430 |
val session1 = base.theory_qualifier(name1) |
|
431 |
val info1 = deps.sessions_structure(session1) |
|
432 |
val prefix = |
|
433 |
if (session == session1) "" |
|
434 |
else if (info.chapter == info1.chapter) "../" + session1 + "/" |
|
72670 | 435 |
else "../../" + info1.chapter_session + "/" |
72669 | 436 |
HTML.link(prefix + html_name(name1), body) |
437 |
} |
|
438 |
||
72989 | 439 |
val theories: List[XML.Body] = |
72962 | 440 |
{ |
441 |
var seen_files = List.empty[(Path, String, Document.Node.Name)] |
|
442 |
||
72989 | 443 |
for (thy_name <- base.session_theories) |
72669 | 444 |
yield { |
72992 | 445 |
progress.expose_interrupt() |
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
446 |
if (verbose) progress.echo("Presenting theory " + thy_name) |
72992 | 447 |
|
72989 | 448 |
val syntax = base.theory_syntax(thy_name) |
72669 | 449 |
val keywords = syntax.keywords |
72989 | 450 |
val spans = syntax.parse_spans(Symbol.decode(File.read(thy_name.path))) |
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
451 |
|
72669 | 452 |
val thy_body = |
453 |
{ |
|
72989 | 454 |
val imports_offset = base.known_theories(thy_name.theory).header.imports_offset |
72669 | 455 |
var token_offset = 1 |
456 |
spans.flatMap(span => |
|
457 |
{ |
|
458 |
val is_init = span.is_kind(keywords, Keyword.theory_begin, false) |
|
459 |
span.content.flatMap(tok => |
|
460 |
{ |
|
461 |
val text = HTML.text(tok.source) |
|
462 |
val item = |
|
463 |
if (is_init && imports_offset.isDefinedAt(token_offset)) { |
|
464 |
List(theory_link(imports_offset(token_offset), text)) |
|
465 |
} |
|
466 |
else text |
|
467 |
||
468 |
token_offset += tok.symbol_length |
|
469 |
||
470 |
(token_markups(keywords, tok) :\ item)( |
|
471 |
{ case (c, body) => List(HTML.span(c, body)) }) |
|
472 |
}) |
|
473 |
}) |
|
474 |
} |
|
475 |
||
72989 | 476 |
val files = |
477 |
(for { |
|
478 |
thy_command <- |
|
479 |
Build_Job.read_theory(db_context, resources, session, thy_name.theory).iterator |
|
480 |
snapshot = Document.State.init.snippet(thy_command) |
|
481 |
(src_path, xml) <- snapshot.xml_markup_blobs(elements = html_elements).iterator |
|
482 |
if xml.nonEmpty |
|
483 |
} yield { |
|
72992 | 484 |
progress.expose_interrupt() |
485 |
||
72989 | 486 |
val file_name = (files_path + src_path.squash.html).implode |
487 |
||
488 |
seen_files.find(p => p._1 == src_path || p._2 == file_name) match { |
|
489 |
case None => seen_files ::= (src_path, file_name, thy_name) |
|
490 |
case Some((_, _, thy_name1)) => |
|
491 |
error("Incoherent use of file name " + src_path + " as " + quote(file_name) + |
|
492 |
" in theory " + thy_name1 + " vs. " + thy_name) |
|
493 |
} |
|
72669 | 494 |
|
73022
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
495 |
if (verbose) progress.echo("Presenting file " + src_path) |
38528017e4c8
more verbosity for potentially bulky presentation;
wenzelm
parents:
72992
diff
changeset
|
496 |
|
72989 | 497 |
val file_path = session_dir + Path.explode(file_name) |
498 |
html_context.init_fonts(file_path.dir) |
|
499 |
||
500 |
val file_title = "File " + Symbol.cartouche_decoded(src_path.implode_short) |
|
501 |
HTML.write_document(file_path.dir, file_path.file_name, |
|
502 |
List(HTML.title(file_title)), |
|
503 |
List(html_context.head(file_title), html_context.source(html_body(xml)))) |
|
504 |
||
505 |
List(HTML.link(file_name, HTML.text(file_title))) |
|
506 |
}).toList |
|
507 |
||
508 |
val thy_title = "Theory " + thy_name.theory_base_name |
|
509 |
HTML.write_document(session_dir, html_name(thy_name), |
|
510 |
List(HTML.title(thy_title)), |
|
511 |
List(html_context.head(thy_title), html_context.source(thy_body))) |
|
512 |
||
513 |
List(HTML.link(html_name(thy_name), |
|
514 |
HTML.text(thy_name.theory_base_name) ::: |
|
515 |
(if (files.isEmpty) Nil else List(HTML.itemize(files))))) |
|
72669 | 516 |
} |
72989 | 517 |
} |
61500 | 518 |
|
72622
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
519 |
val title = "Session " + session |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
520 |
HTML.write_document(session_dir, "index.html", |
830222403681
HTML presentation in Isabelle/Scala, based on theory html exports from Isabelle/ML;
wenzelm
parents:
72600
diff
changeset
|
521 |
List(HTML.title(title + " (" + Distribution.version + ")")), |
72962 | 522 |
html_context.head(title, List(HTML.par(links))) :: |
72989 | 523 |
html_context.contents("Theories", theories)) |
61372 | 524 |
} |
66040 | 525 |
|
526 |
||
72682 | 527 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
528 |
/** build documents **/ |
72565 | 529 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
530 |
val session_tex_path = Path.explode("session.tex") |
72565 | 531 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
532 |
def tex_name(name: Document.Node.Name): String = name.theory_base_name + ".tex" |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
533 |
def document_tex_name(name: Document.Node.Name): String = "document/" + tex_name(name) |
72309
564012e31db1
discontinued obsolete DVI document format and related settings/tools;
wenzelm
parents:
71114
diff
changeset
|
534 |
|
72882 | 535 |
class Build_Error(val log_lines: List[String], val message: String) |
536 |
extends Exn.User_Error(message) |
|
537 |
||
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
538 |
def build_documents( |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
539 |
session: String, |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
540 |
deps: Sessions.Deps, |
72683 | 541 |
db_context: Sessions.Database_Context, |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
542 |
progress: Progress = new Progress, |
72675 | 543 |
output_sources: Option[Path] = None, |
544 |
output_pdf: Option[Path] = None, |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
545 |
verbose: Boolean = false, |
72696 | 546 |
verbose_latex: Boolean = false): List[Document_Output] = |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
547 |
{ |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
548 |
/* session info */ |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
549 |
|
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
550 |
val info = deps.sessions_structure(session) |
72854 | 551 |
val hierarchy = deps.sessions_structure.hierarchy(session) |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
552 |
val options = info.options |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
553 |
val base = deps(session) |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
554 |
val graph_pdf = graphview.Graph_File.make_pdf(options, base.session_graph_display) |
67177 | 555 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
556 |
|
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
557 |
/* prepare document directory */ |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
558 |
|
72600
2fa4f25d9d07
official support for document theories from other sessions;
wenzelm
parents:
72599
diff
changeset
|
559 |
lazy val tex_files = |
72683 | 560 |
for (name <- base.session_theories ::: base.document_theories) |
561 |
yield { |
|
72854 | 562 |
val entry = db_context.get_export(hierarchy, name.theory, document_tex_name(name)) |
72847
9dda93a753b1
clarified signature: provide XZ.Cache where Export.Entry is created;
wenzelm
parents:
72763
diff
changeset
|
563 |
Path.basic(tex_name(name)) -> entry.uncompressed |
72683 | 564 |
} |
72600
2fa4f25d9d07
official support for document theories from other sessions;
wenzelm
parents:
72599
diff
changeset
|
565 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
566 |
def prepare_dir1(dir: Path, doc: Document_Variant): (Path, String) = |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
567 |
{ |
72649 | 568 |
val doc_dir = dir + Path.basic(doc.name) |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
569 |
Isabelle_System.make_directory(doc_dir) |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
570 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
571 |
Isabelle_System.bash("isabelle latex -o sty", cwd = doc_dir.file).check |
72649 | 572 |
File.write(doc_dir + Path.explode("isabelletags.sty"), doc.latex_sty) |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
573 |
for ((base_dir, src) <- info.document_files) File.copy_base(info.dir + base_dir, src, doc_dir) |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
574 |
|
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
575 |
File.write(doc_dir + session_tex_path, |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
576 |
Library.terminate_lines( |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
577 |
base.session_theories.map(name => "\\input{" + tex_name(name) + "}"))) |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
578 |
|
72600
2fa4f25d9d07
official support for document theories from other sessions;
wenzelm
parents:
72599
diff
changeset
|
579 |
for ((path, tex) <- tex_files) Bytes.write(doc_dir + path, tex) |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
580 |
|
72649 | 581 |
val root1 = "root_" + doc.name |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
582 |
val root = if ((doc_dir + Path.explode(root1).tex).is_file) root1 else "root" |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
583 |
|
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
584 |
(doc_dir, root) |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
585 |
} |
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
586 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
587 |
def prepare_dir2(dir: Path, doc: Document_Variant): Unit = |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
588 |
{ |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
589 |
val doc_dir = dir + Path.basic(doc.name) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
590 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
591 |
// non-deterministic, but irrelevant |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
592 |
Bytes.write(doc_dir + session_graph_path, graph_pdf) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
593 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
594 |
|
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
595 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
596 |
/* produce documents */ |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
597 |
|
72649 | 598 |
val documents = |
599 |
for (doc <- info.documents) |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
600 |
yield { |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
601 |
Isabelle_System.with_tmp_dir("document")(tmp_dir => |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
602 |
{ |
72699 | 603 |
progress.echo("Preparing " + session + "/" + doc.name + " ...") |
72665 | 604 |
val start = Time.now() |
605 |
||
606 |
||
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
607 |
// prepare sources |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
608 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
609 |
val (doc_dir, root) = prepare_dir1(tmp_dir, doc) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
610 |
val digests = File.find_files(doc_dir.file, follow_links = true).map(SHA1.digest) |
72696 | 611 |
val sources = SHA1.digest_set(digests) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
612 |
prepare_dir2(tmp_dir, doc) |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
613 |
|
72675 | 614 |
for (dir <- output_sources) { |
615 |
prepare_dir1(dir, doc) |
|
616 |
prepare_dir2(dir, doc) |
|
617 |
} |
|
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
618 |
|
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
619 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
620 |
// old document from database |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
621 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
622 |
val old_document = |
72683 | 623 |
for { |
72716 | 624 |
old_doc <- db_context.input_database(session)(read_document(_, _, doc.name)) |
72696 | 625 |
if old_doc.sources == sources |
72683 | 626 |
} |
627 |
yield { |
|
72696 | 628 |
Bytes.write(doc_dir + doc.path.pdf, old_doc.pdf) |
629 |
old_doc |
|
72683 | 630 |
} |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
631 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
632 |
old_document getOrElse { |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
633 |
// bash scripts |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
634 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
635 |
def root_bash(ext: String): String = Bash.string(root + "." + ext) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
636 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
637 |
def latex_bash(fmt: String = "pdf", ext: String = "tex"): String = |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
638 |
"isabelle latex -o " + Bash.string(fmt) + " " + Bash.string(root + "." + ext) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
639 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
640 |
def bash(items: String*): Process_Result = |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
641 |
progress.bash(items.mkString(" && "), cwd = doc_dir.file, |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
642 |
echo = verbose_latex, watchdog = Time.seconds(0.5)) |
67204 | 643 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
644 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
645 |
// prepare document |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
646 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
647 |
val result = |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
648 |
if ((doc_dir + Path.explode("build")).is_file) { |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
649 |
bash("./build pdf " + Bash.string(doc.name)) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
650 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
651 |
else { |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
652 |
bash( |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
653 |
latex_bash(), |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
654 |
"{ [ ! -f " + root_bash("bib") + " ] || " + latex_bash("bbl") + "; }", |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
655 |
"{ [ ! -f " + root_bash("idx") + " ] || " + latex_bash("idx") + "; }", |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
656 |
latex_bash(), |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
657 |
latex_bash()) |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
658 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
659 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
660 |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
661 |
// result |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
662 |
|
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
663 |
val root_pdf = Path.basic(root).pdf |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
664 |
val result_path = doc_dir + root_pdf |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
665 |
|
72882 | 666 |
val log_lines = result.out_lines ::: result.err_lines |
667 |
||
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
668 |
if (!result.ok) { |
72882 | 669 |
val message = |
670 |
Exn.cat_message( |
|
671 |
Library.trim_line(result.err), |
|
672 |
cat_lines(Latex.latex_errors(doc_dir, root) ::: Bibtex.bibtex_errors(doc_dir, root)), |
|
673 |
"Failed to build document " + quote(doc.name)) |
|
674 |
throw new Build_Error(log_lines, message) |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
675 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
676 |
else if (!result_path.is_file) { |
72882 | 677 |
val message = "Bad document result: expected to find " + root_pdf |
678 |
throw new Build_Error(log_lines, message) |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
679 |
} |
72665 | 680 |
else { |
681 |
val stop = Time.now() |
|
682 |
val timing = stop - start |
|
72699 | 683 |
progress.echo("Finished " + session + "/" + doc.name + |
72665 | 684 |
" (" + timing.message_hms + " elapsed time)") |
685 |
||
72882 | 686 |
val log_xz = Bytes(cat_lines(log_lines)).compress() |
72696 | 687 |
val pdf = Bytes.read(result_path) |
688 |
Document_Output(doc.name, sources, log_xz, pdf) |
|
72665 | 689 |
} |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
690 |
} |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
691 |
}) |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
692 |
} |
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
693 |
|
72696 | 694 |
for (dir <- output_pdf; doc <- documents) { |
72675 | 695 |
Isabelle_System.make_directory(dir) |
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
696 |
val path = dir + doc.path.pdf |
72696 | 697 |
Bytes.write(path, doc.pdf) |
72699 | 698 |
progress.echo("Document at " + path.absolute) |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
699 |
} |
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
700 |
|
72649 | 701 |
documents |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
702 |
} |
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
703 |
|
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
704 |
|
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
705 |
/* Isabelle tool wrapper */ |
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
706 |
|
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
707 |
val isabelle_tool = |
72763 | 708 |
Isabelle_Tool("document", "prepare session theory document", Scala_Project.here, args => |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
709 |
{ |
72675 | 710 |
var output_sources: Option[Path] = None |
711 |
var output_pdf: Option[Path] = None |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
712 |
var verbose_latex = false |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
713 |
var dirs: List[Path] = Nil |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
714 |
var options = Options.init() |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
715 |
var verbose_build = false |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
716 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
717 |
val getopts = Getopts( |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
718 |
""" |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
719 |
Usage: isabelle document [OPTIONS] SESSION |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
720 |
|
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
721 |
Options are: |
72675 | 722 |
-O DIR output directory for LaTeX sources and resulting PDF |
723 |
-P DIR output directory for resulting PDF |
|
724 |
-S DIR output directory for LaTeX sources |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
725 |
-V verbose latex |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
726 |
-d DIR include session directory |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
727 |
-o OPTION override Isabelle system OPTION (via NAME=VAL or NAME) |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
728 |
-v verbose build |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
729 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
730 |
Prepare the theory document of a session. |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
731 |
""", |
72675 | 732 |
"O:" -> (arg => |
733 |
{ |
|
734 |
val dir = Path.explode(arg) |
|
735 |
output_sources = Some(dir) |
|
736 |
output_pdf = Some(dir) |
|
737 |
}), |
|
738 |
"P:" -> (arg => { output_pdf = Some(Path.explode(arg)) }), |
|
739 |
"S:" -> (arg => { output_sources = Some(Path.explode(arg)) }), |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
740 |
"V" -> (_ => verbose_latex = true), |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
741 |
"d:" -> (arg => dirs = dirs ::: List(Path.explode(arg))), |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
742 |
"o:" -> (arg => options = options + arg), |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
743 |
"v" -> (_ => verbose_build = true)) |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
744 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
745 |
val more_args = getopts(args) |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
746 |
val session = |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
747 |
more_args match { |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
748 |
case List(a) => a |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
749 |
case _ => getopts.usage() |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
750 |
} |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
751 |
|
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
752 |
val progress = new Console_Progress(verbose = verbose_build) |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
753 |
val store = Sessions.store(options) |
67176
13b5c3ff1954
re-implemented "isabelle document" in Isabelle/Scala, include latex_errors here;
wenzelm
parents:
66075
diff
changeset
|
754 |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
755 |
progress.interrupt_handler { |
72650
787ba1d19d3a
more robust: ensure coherence wrt. build database;
wenzelm
parents:
72649
diff
changeset
|
756 |
val res = |
787ba1d19d3a
more robust: ensure coherence wrt. build database;
wenzelm
parents:
72649
diff
changeset
|
757 |
Build.build(options, selection = Sessions.Selection.session(session), |
787ba1d19d3a
more robust: ensure coherence wrt. build database;
wenzelm
parents:
72649
diff
changeset
|
758 |
dirs = dirs, progress = progress, verbose = verbose_build) |
787ba1d19d3a
more robust: ensure coherence wrt. build database;
wenzelm
parents:
72649
diff
changeset
|
759 |
if (!res.ok) error("Failed to build session " + quote(session)) |
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
760 |
|
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
761 |
val deps = |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
762 |
Sessions.load_structure(options + "document=pdf", dirs = dirs). |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
763 |
selection_deps(Sessions.Selection.session(session)) |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
764 |
|
72675 | 765 |
if (output_sources.isEmpty && output_pdf.isEmpty) { |
766 |
progress.echo_warning("No output directory") |
|
72653
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
767 |
} |
ea35afdb1366
store documents within session database, instead of browser_info directory;
wenzelm
parents:
72652
diff
changeset
|
768 |
|
72854 | 769 |
using(store.open_database_context())(db_context => |
72683 | 770 |
build_documents(session, deps, db_context, progress = progress, |
771 |
output_sources = output_sources, output_pdf = output_pdf, |
|
772 |
verbose = true, verbose_latex = verbose_latex)) |
|
72574
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
773 |
} |
d892f6d66402
build documents in Isabelle/Scala, based on generated tex files as session exports;
wenzelm
parents:
72565
diff
changeset
|
774 |
}) |
50707
5b2bf7611662
maintain session index on Scala side, for more determistic results;
wenzelm
parents:
diff
changeset
|
775 |
} |