4 Export foundational theory content. |
4 Export foundational theory content. |
5 *) |
5 *) |
6 |
6 |
7 signature EXPORT_THEORY = |
7 signature EXPORT_THEORY = |
8 sig |
8 sig |
9 val entity_markup: Name_Space.T -> string -> Markup.T |
|
10 end; |
9 end; |
11 |
10 |
12 structure Export_Theory: EXPORT_THEORY = |
11 structure Export_Theory: EXPORT_THEORY = |
13 struct |
12 struct |
14 |
13 |
15 (* name space entries *) |
14 (* name space entries *) |
16 |
15 |
17 fun entity_markup space name = |
16 fun entity_markup adjust_pos space name = |
18 let |
17 let |
19 val {serial, pos, ...} = Name_Space.the_entry space name; |
18 val {serial, pos, ...} = Name_Space.the_entry space name; |
20 val props = Markup.serial_properties serial @ Position.offset_properties_of pos; |
19 val props = Markup.serial_properties serial @ Position.offset_properties_of (adjust_pos pos); |
21 in (Markup.entityN, (Markup.nameN, name) :: props) end; |
20 in (Markup.entityN, (Markup.nameN, name) :: props) end; |
22 |
21 |
23 fun export_decls export_decl parents thy space decls = |
22 fun export_decls export_decl parents thy adjust_pos space decls = |
24 (decls, []) |-> fold (fn (name, decl) => |
23 (decls, []) |-> fold (fn (name, decl) => |
25 if exists (fn space => Name_Space.declared space name) parents then I |
24 if exists (fn space => Name_Space.declared space name) parents then I |
26 else |
25 else |
27 (case export_decl thy name decl of |
26 (case export_decl thy name decl of |
28 NONE => I |
27 NONE => I |
29 | SOME body => cons (name, XML.Elem (entity_markup space name, body)))) |
28 | SOME body => cons (name, XML.Elem (entity_markup adjust_pos space name, body)))) |
30 |> sort_by #1 |> map #2; |
29 |> sort_by #1 |> map #2; |
31 |
30 |
32 |
31 |
33 (* present *) |
32 (* present *) |
34 |
33 |
35 fun present get_space get_decls export name thy = |
34 fun present get_space get_decls export name adjust_pos thy = |
36 if Options.default_bool "export_theory" then |
35 if Options.default_bool "export_theory" then |
37 (case export (map get_space (Theory.parents_of thy)) thy (get_space thy) (get_decls thy) of |
36 (case |
|
37 export (map get_space (Theory.parents_of thy)) thy adjust_pos (get_space thy) (get_decls thy) |
|
38 of |
38 [] => () |
39 [] => () |
39 | body => Export.export thy ("theory/" ^ name) [YXML.string_of_body body]) |
40 | body => Export.export thy ("theory/" ^ name) [YXML.string_of_body body]) |
40 else (); |
41 else (); |
41 |
42 |
42 fun present_decls get_space get_decls = |
43 fun present_decls get_space get_decls = |
43 present get_space get_decls o export_decls; |
44 present get_space get_decls o export_decls; |
44 |
45 |
45 fun setup_presentation f = Theory.setup (Thy_Info.add_presentation (K f)); |
46 val setup_presentation = Theory.setup o Thy_Info.add_presentation; |
46 |
47 |
47 |
48 |
48 (* types *) |
49 (* types *) |
49 |
50 |
50 local |
51 local |