equal
deleted
inserted
replaced
4 Theory presentation: HTML and PDF-LaTeX documents. |
4 Theory presentation: HTML and PDF-LaTeX documents. |
5 *) |
5 *) |
6 |
6 |
7 signature PRESENT = |
7 signature PRESENT = |
8 sig |
8 sig |
9 val theory_qualifier: theory -> string |
|
10 val init: HTML.symbols -> bool -> Path.T -> string list -> string * string -> bool -> unit |
9 val init: HTML.symbols -> bool -> Path.T -> string list -> string * string -> bool -> unit |
11 val finish: unit -> unit |
10 val finish: unit -> unit |
12 val begin_theory: int -> (unit -> HTML.text) -> theory -> theory |
11 val begin_theory: int -> (unit -> HTML.text) -> theory -> theory |
13 end; |
12 end; |
14 |
13 |
24 val readme_html_path = Path.basic "README.html"; |
23 val readme_html_path = Path.basic "README.html"; |
25 val session_graph_path = Path.basic "session_graph.pdf"; |
24 val session_graph_path = Path.basic "session_graph.pdf"; |
26 val document_path = Path.ext "pdf" o Path.basic; |
25 val document_path = Path.ext "pdf" o Path.basic; |
27 |
26 |
28 fun show_path path = Path.implode (Path.expand (File.full_path Path.current path)); |
27 fun show_path path = Path.implode (Path.expand (File.full_path Path.current path)); |
29 |
|
30 |
|
31 |
|
32 (** theory data **) |
|
33 |
|
34 type browser_info = {chapter: string, name: string}; |
|
35 val empty_browser_info: browser_info = {chapter = "Unsorted", name = "Unknown"}; |
|
36 |
|
37 structure Browser_Info = Theory_Data |
|
38 ( |
|
39 type T = browser_info |
|
40 val empty = empty_browser_info; |
|
41 val extend = I; |
|
42 val merge = #1; |
|
43 ); |
|
44 |
|
45 fun reset_browser_info thy = |
|
46 if Browser_Info.get thy = empty_browser_info then NONE |
|
47 else SOME (Browser_Info.put empty_browser_info thy); |
|
48 |
|
49 val _ = |
|
50 Theory.setup |
|
51 (Theory.at_begin reset_browser_info #> |
|
52 Browser_Info.put {chapter = Context.PureN, name = Context.PureN}); |
|
53 |
28 |
54 |
29 |
55 |
30 |
56 (** global browser info state **) |
31 (** global browser info state **) |
57 |
32 |
160 |
135 |
161 (* theory elements *) |
136 (* theory elements *) |
162 |
137 |
163 fun theory_link (curr_chapter, curr_session) thy = |
138 fun theory_link (curr_chapter, curr_session) thy = |
164 let |
139 let |
165 val {chapter, name = session, ...} = Browser_Info.get thy; |
140 val session = Resources.theory_qualifier (Context.theory_long_name thy); |
|
141 val chapter = Resources.session_chapter session; |
166 val link = html_path (Context.theory_name thy); |
142 val link = html_path (Context.theory_name thy); |
167 in |
143 in |
168 if curr_session = session then SOME link |
144 if curr_session = session then SOME link |
169 else if curr_chapter = chapter then |
145 else if curr_chapter = chapter then |
170 SOME (Path.parent + Path.basic session + link) |
146 SOME (Path.parent + Path.basic session + link) |
186 |
162 |
187 val _ = |
163 val _ = |
188 if is_session_theory thy then |
164 if is_session_theory thy then |
189 add_html_index (update_time, HTML.theory_entry symbols (Url.File (html_path name), name)) |
165 add_html_index (update_time, HTML.theory_entry symbols (Url.File (html_path name), name)) |
190 else (); |
166 else (); |
191 in thy |> Browser_Info.put {chapter = chapter, name = session_name} end); |
167 in thy end); |
192 |
168 |
193 end; |
169 end; |