6 *) |
6 *) |
7 |
7 |
8 signature THY_INFO = |
8 signature THY_INFO = |
9 sig |
9 sig |
10 type presentation_context = |
10 type presentation_context = |
11 {options: Options.T, pos: Position.T, segments: Thy_Output.segment list} |
11 {options: Options.T, file_pos: Position.T, adjust_pos: Position.T -> Position.T, |
|
12 segments: Thy_Output.segment list} |
12 val apply_presentation: presentation_context -> theory -> unit |
13 val apply_presentation: presentation_context -> theory -> unit |
13 val add_presentation: (presentation_context -> theory -> unit) -> theory -> theory |
14 val add_presentation: (presentation_context -> theory -> unit) -> theory -> theory |
14 val get_names: unit -> string list |
15 val get_names: unit -> string list |
15 val lookup_theory: string -> theory option |
16 val lookup_theory: string -> theory option |
16 val get_theory: string -> theory |
17 val get_theory: string -> theory |
32 struct |
33 struct |
33 |
34 |
34 (** presentation of consolidated theory **) |
35 (** presentation of consolidated theory **) |
35 |
36 |
36 type presentation_context = |
37 type presentation_context = |
37 {options: Options.T, pos: Position.T, segments: Thy_Output.segment list}; |
38 {options: Options.T, file_pos: Position.T, adjust_pos: Position.T -> Position.T, |
|
39 segments: Thy_Output.segment list}; |
38 |
40 |
39 structure Presentation = Theory_Data |
41 structure Presentation = Theory_Data |
40 ( |
42 ( |
41 type T = ((presentation_context -> theory -> unit) * stamp) list; |
43 type T = ((presentation_context -> theory -> unit) * stamp) list; |
42 val empty = []; |
44 val empty = []; |
48 ignore (Presentation.get thy |> Par_List.map (fn (f, _) => f context thy)); |
50 ignore (Presentation.get thy |> Par_List.map (fn (f, _) => f context thy)); |
49 |
51 |
50 fun add_presentation f = Presentation.map (cons (f, stamp ())); |
52 fun add_presentation f = Presentation.map (cons (f, stamp ())); |
51 |
53 |
52 val _ = |
54 val _ = |
53 Theory.setup (add_presentation (fn {options, pos, segments} => fn thy => |
55 Theory.setup (add_presentation (fn {options, file_pos, segments, ...} => fn thy => |
54 if exists (Toplevel.is_skipped_proof o #state) segments then () |
56 if exists (Toplevel.is_skipped_proof o #state) segments then () |
55 else |
57 else |
56 let |
58 let |
57 val body = Thy_Output.present_thy thy segments; |
59 val body = Thy_Output.present_thy thy segments; |
58 val option = Present.document_option options; |
60 val option = Present.document_option options; |
59 in |
61 in |
60 if #disabled option then () |
62 if #disabled option then () |
61 else |
63 else |
62 let |
64 let |
63 val latex = Latex.isabelle_body (Context.theory_name thy) body; |
65 val latex = Latex.isabelle_body (Context.theory_name thy) body; |
64 val output = [Latex.output_text latex, Latex.output_positions pos latex]; |
66 val output = [Latex.output_text latex, Latex.output_positions file_pos latex]; |
65 val _ = Export.export thy "document.tex" output; |
67 val _ = Export.export thy "document.tex" output; |
66 val _ = if #enabled option then Present.theory_output thy output else (); |
68 val _ = if #enabled option then Present.theory_output thy output else (); |
67 in () end |
69 in () end |
68 end)); |
70 end)); |
69 |
71 |
318 |
320 |
319 fun present () = |
321 fun present () = |
320 let |
322 let |
321 val segments = (spans ~~ maps Toplevel.join_results results) |
323 val segments = (spans ~~ maps Toplevel.join_results results) |
322 |> map (fn (span, (tr, st')) => {span = span, command = tr, state = st'}); |
324 |> map (fn (span, (tr, st')) => {span = span, command = tr, state = st'}); |
323 val context = {options = options, pos = text_pos, segments = segments}; |
325 val context: presentation_context = |
|
326 {options = options, file_pos = text_pos, adjust_pos = I, segments = segments}; |
324 in apply_presentation context thy end; |
327 in apply_presentation context thy end; |
325 in (thy, present, size text) end; |
328 in (thy, present, size text) end; |
326 |
329 |
327 |
330 |
328 (* require_thy -- checking database entries wrt. the file-system *) |
331 (* require_thy -- checking database entries wrt. the file-system *) |