110 |
110 |
111 val check_session = check_name #session_positions "session" markup_session; |
111 val check_session = check_name #session_positions "session" markup_session; |
112 val check_doc = check_name #docs "documentation" (fn name => fn _ => Markup.doc name); |
112 val check_doc = check_name #docs "documentation" (fn name => fn _ => Markup.doc name); |
113 |
113 |
114 |
114 |
115 |
|
116 (* manage source files *) |
115 (* manage source files *) |
117 |
116 |
118 type files = |
117 type files = |
119 {master_dir: Path.T, (*master directory of theory source*) |
118 {master_dir: Path.T, (*master directory of theory source*) |
120 imports: (string * Position.T) list, (*source specification of imports*) |
119 imports: (string * Position.T) list, (*source specification of imports*) |
168 dirs |> get_first (fn dir => |
167 dirs |> get_first (fn dir => |
169 let val path = Path.append dir thy_file |
168 let val path = Path.append dir thy_file |
170 in if File.is_file path then SOME path else NONE end) |
169 in if File.is_file path then SOME path else NONE end) |
171 end; |
170 end; |
172 |
171 |
|
172 fun make_theory_node node_name theory = |
|
173 {node_name = node_name, master_dir = Path.dir node_name, theory_name = theory}; |
|
174 |
|
175 fun loaded_theory_node theory = |
|
176 {node_name = Path.basic theory, master_dir = Path.current, theory_name = theory}; |
|
177 |
173 fun import_name qualifier dir s = |
178 fun import_name qualifier dir s = |
174 let val theory = theory_name qualifier (Thy_Header.import_name s) in |
179 let |
175 if loaded_theory theory |
180 val theory = theory_name qualifier (Thy_Header.import_name s); |
176 then {node_name = Path.basic theory, master_dir = Path.current, theory_name = theory} |
181 fun theory_node () = |
|
182 make_theory_node (File.full_path dir (thy_path (Path.expand (Path.explode s)))) theory; |
|
183 in |
|
184 if not (Thy_Header.is_base_name s) then theory_node () |
|
185 else if loaded_theory theory then loaded_theory_node theory |
177 else |
186 else |
178 let |
187 (case find_theory_file theory of |
179 val node_name = |
188 SOME node_name => make_theory_node node_name theory |
180 (case find_theory_file theory of |
189 | NONE => if Long_Name.is_qualified s then loaded_theory_node theory else theory_node ()) |
181 SOME node_name => node_name |
|
182 | NONE => |
|
183 if Thy_Header.is_base_name s andalso Long_Name.is_qualified s |
|
184 then Path.explode s |
|
185 else File.full_path dir (thy_path (Path.expand (Path.explode s)))); |
|
186 in {node_name = node_name, master_dir = Path.dir node_name, theory_name = theory} end |
|
187 end; |
190 end; |
188 |
191 |
189 fun check_file dir file = File.check_file (File.full_path dir file); |
192 fun check_file dir file = File.check_file (File.full_path dir file); |
190 |
193 |
191 fun check_thy dir thy_name = |
194 fun check_thy dir thy_name = |