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