12 /* aspects */ |
12 /* aspects */ |
13 |
13 |
14 sealed case class Aspect_Args( |
14 sealed case class Aspect_Args( |
15 options: Options, progress: Progress, output_dir: Path, result: Thy_Resources.Theories_Result) |
15 options: Options, progress: Progress, output_dir: Path, result: Thy_Resources.Theories_Result) |
16 { |
16 { |
17 def write(node_name: Document.Node.Name, file_name: String, bytes: Bytes) |
17 def write(node_name: Document.Node.Name, file_name: Path, bytes: Bytes) |
18 { |
18 { |
19 val path = output_dir + Path.basic(node_name.theory) + Path.basic(file_name) |
19 val path = output_dir + Path.basic(node_name.theory) + file_name |
20 Isabelle_System.mkdirs(path.dir) |
20 Isabelle_System.mkdirs(path.dir) |
21 Bytes.write(path, bytes) |
21 Bytes.write(path, bytes) |
22 } |
22 } |
23 |
23 |
24 def write(node_name: Document.Node.Name, file_name: String, text: String): Unit = |
24 def write(node_name: Document.Node.Name, file_name: Path, text: String): Unit = |
25 write(node_name, file_name, Bytes(text)) |
25 write(node_name, file_name, Bytes(text)) |
26 |
26 |
27 def write(node_name: Document.Node.Name, file_name: String, body: XML.Body): Unit = |
27 def write(node_name: Document.Node.Name, file_name: Path, body: XML.Body): Unit = |
28 write(node_name, file_name, Symbol.encode(YXML.string_of_body(body))) |
28 write(node_name, file_name, Symbol.encode(YXML.string_of_body(body))) |
29 } |
29 } |
30 |
30 |
31 sealed case class Aspect(name: String, description: String, operation: Aspect_Args => Unit) |
31 sealed case class Aspect(name: String, description: String, operation: Aspect_Args => Unit, |
|
32 options: List[String] = Nil) |
32 { |
33 { |
33 override def toString: String = name |
34 override def toString: String = name |
34 } |
35 } |
35 |
36 |
36 private val known_aspects = |
37 val known_aspects = |
37 List( |
38 List( |
38 Aspect("messages", "output messages (YXML format)", |
39 Aspect("messages", "output messages (YXML format)", |
39 { case args => |
40 { case args => |
40 for (node_name <- args.result.node_names) { |
41 for (node_name <- args.result.node_names) { |
41 args.write(node_name, "messages.yxml", |
42 args.write(node_name, Path.explode("messages.yxml"), |
42 args.result.messages(node_name).iterator.map(_._1).toList) |
43 args.result.messages(node_name).iterator.map(_._1).toList) |
43 } |
44 } |
44 }), |
45 }), |
45 Aspect("markup", "PIDE markup (YXML format)", |
46 Aspect("markup", "PIDE markup (YXML format)", |
46 { case args => |
47 { case args => |
47 for (node_name <- args.result.node_names) { |
48 for (node_name <- args.result.node_names) { |
48 args.write(node_name, "markup.yxml", args.result.markup_to_XML(node_name)) |
49 args.write(node_name, Path.explode("markup.yxml"), |
|
50 args.result.markup_to_XML(node_name)) |
49 } |
51 } |
50 }) |
52 }), |
|
53 Aspect("latex", "generated LaTeX source", |
|
54 { case args => |
|
55 for { |
|
56 node_name <- args.result.node_names |
|
57 entry <- args.result.exports(node_name) |
|
58 if entry.name == "document.tex" |
|
59 } args.write(node_name, Path.explode(entry.name), entry.uncompressed()) |
|
60 }, options = List("editor_presentation")), |
|
61 Aspect("theory", "foundational theory content", |
|
62 { case args => |
|
63 for { |
|
64 node_name <- args.result.node_names |
|
65 entry <- args.result.exports(node_name) |
|
66 if entry.name.startsWith(Export_Theory.export_prefix) |
|
67 } args.write(node_name, Path.explode(entry.name), entry.uncompressed()) |
|
68 }, options = List("editor_presentation", "export_theory")) |
51 ).sortBy(_.name) |
69 ).sortBy(_.name) |
52 |
70 |
53 def show_aspects: String = |
71 def show_aspects: String = |
54 cat_lines(known_aspects.map(aspect => aspect.name + " - " + aspect.description)) |
72 cat_lines(known_aspects.map(aspect => aspect.name + " - " + aspect.description)) |
55 |
73 |