author | wenzelm |
Tue, 07 Apr 2020 21:49:36 +0200 | |
changeset 71726 | a5fda30edae2 |
parent 71678 | 6fff34b5293e |
child 71807 | cdfa8f027bb9 |
permissions | -rw-r--r-- |
68308
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
1 |
/* Title: Pure/Tools/dump.scala |
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
2 |
Author: Makarius |
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
3 |
|
68348 | 4 |
Dump cumulative PIDE session database. |
68308
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
5 |
*/ |
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
6 |
|
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
7 |
package isabelle |
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
8 |
|
71534 | 9 |
import java.io.{BufferedWriter, FileOutputStream, OutputStreamWriter} |
10 |
||
68308
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
11 |
|
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
12 |
object Dump |
119fc05f6b00
support to dump build database produced by PIDE session;
wenzelm
parents:
diff
changeset
|
13 |
{ |
68316 | 14 |
/* aspects */ |
15 |
||
16 |
sealed case class Aspect_Args( |
|
68355 | 17 |
options: Options, |
70640
5f4b8a505090
more explicit type Dump.Session, with context information;
wenzelm
parents:
70634
diff
changeset
|
18 |
deps: Sessions.Deps, |
68355 | 19 |
progress: Progress, |
69896 | 20 |
output_dir: Path, |
68929 | 21 |
snapshot: Document.Snapshot, |
69534 | 22 |
status: Document_Status.Node_Status) |
68319 | 23 |
{ |
71534 | 24 |
def write_path(file_name: Path): Path = |
68319 | 25 |
{ |
68929 | 26 |
val path = output_dir + Path.basic(snapshot.node_name.theory) + file_name |
68319 | 27 |
Isabelle_System.mkdirs(path.dir) |
71534 | 28 |
path |
68319 | 29 |
} |
30 |
||
71534 | 31 |
def write(file_name: Path, bytes: Bytes): Unit = |
32 |
Bytes.write(write_path(file_name), bytes) |
|
33 |
||
68365 | 34 |
def write(file_name: Path, text: String): Unit = |
35 |
write(file_name, Bytes(text)) |
|
68332 | 36 |
|
68365 | 37 |
def write(file_name: Path, body: XML.Body): Unit = |
71534 | 38 |
using(File.writer(write_path(file_name).file))( |
39 |
writer => YXML.traversal(s => writer.write(Symbol.encode(s)), body)) |
|
68319 | 40 |
} |
68316 | 41 |
|
68347 | 42 |
sealed case class Aspect(name: String, description: String, operation: Aspect_Args => Unit, |
43 |
options: List[String] = Nil) |
|
68345 | 44 |
{ |
45 |
override def toString: String = name |
|
46 |
} |
|
68316 | 47 |
|
69521 | 48 |
val known_aspects: List[Aspect] = |
68316 | 49 |
List( |
68365 | 50 |
Aspect("markup", "PIDE markup (YXML format)", |
51 |
{ case args => |
|
52 |
args.write(Path.explode("markup.yxml"), |
|
53 |
args.snapshot.markup_to_XML(Text.Range.full, Markup.Elements.full)) |
|
54 |
}), |
|
68319 | 55 |
Aspect("messages", "output messages (YXML format)", |
56 |
{ case args => |
|
68365 | 57 |
args.write(Path.explode("messages.yxml"), |
58 |
args.snapshot.messages.iterator.map(_._1).toList) |
|
68347 | 59 |
}), |
60 |
Aspect("latex", "generated LaTeX source", |
|
61 |
{ case args => |
|
68365 | 62 |
for (entry <- args.snapshot.exports if entry.name == "document.tex") |
63 |
args.write(Path.explode(entry.name), entry.uncompressed()) |
|
69533
1d2e6a4e073f
clarified options: ensure consolidated Node_Status and thus percentage = 100% for progress;
wenzelm
parents:
69532
diff
changeset
|
64 |
}, options = List("export_document")), |
68347 | 65 |
Aspect("theory", "foundational theory content", |
66 |
{ case args => |
|
67 |
for { |
|
68365 | 68 |
entry <- args.snapshot.exports |
68347 | 69 |
if entry.name.startsWith(Export_Theory.export_prefix) |
68365 | 70 |
} args.write(Path.explode(entry.name), entry.uncompressed()) |
69533
1d2e6a4e073f
clarified options: ensure consolidated Node_Status and thus percentage = 100% for progress;
wenzelm
parents:
69532
diff
changeset
|
71 |
}, options = List("export_theory")) |
68345 | 72 |
).sortBy(_.name) |
68316 | 73 |
|
74 |
def show_aspects: String = |
|
68345 |