src/Pure/Thy/present.ML
changeset 59448 149d2bc5ddb6
parent 59446 4427f04fca57
child 60082 d3573eb7728f
     1.1 --- a/src/Pure/Thy/present.ML	Mon Jan 26 13:44:37 2015 +0100
     1.2 +++ b/src/Pure/Thy/present.ML	Mon Jan 26 13:48:29 2015 +0100
     1.3 @@ -1,7 +1,7 @@
     1.4  (*  Title:      Pure/Thy/present.ML
     1.5      Author:     Markus Wenzel and Stefan Berghofer, TU Muenchen
     1.6  
     1.7 -Theory presentation: HTML, graph files, (PDF)LaTeX documents.
     1.8 +Theory presentation: HTML and PDF-LaTeX documents.
     1.9  *)
    1.10  
    1.11  signature PRESENT =
    1.12 @@ -10,7 +10,7 @@
    1.13    val document_enabled: string -> bool
    1.14    val document_variants: string -> (string * string) list
    1.15    val init: bool -> bool -> Path.T -> string -> string -> (string * string) list ->
    1.16 -    (Path.T * Path.T) list -> Path.T -> string * string -> bool -> theory list -> unit
    1.17 +    (Path.T * Path.T) list -> Path.T -> string * string -> bool -> unit
    1.18    val finish: unit -> unit
    1.19    val theory_output: string -> string -> unit
    1.20    val begin_theory: int -> (unit -> HTML.text) -> theory -> theory
    1.21 @@ -32,8 +32,7 @@
    1.22  val documentN = "document";
    1.23  val document_path = Path.basic documentN;
    1.24  val doc_indexN = "session";
    1.25 -val graph_path = Path.basic "session.graph";
    1.26 -val graph_pdf_path = Path.basic "session_graph.pdf";
    1.27 +val session_graph_path = Path.basic "session_graph.pdf";
    1.28  
    1.29  fun show_path path = Path.implode (Path.expand (Path.append (File.pwd ()) path));
    1.30  
    1.31 @@ -53,41 +52,6 @@
    1.32    (Browser_Info.put {chapter = Context.PureN, name = Context.PureN});
    1.33  
    1.34  val session_name = #name o Browser_Info.get;
    1.35 -val session_chapter_name = (fn {chapter, name} => [chapter, name]) o Browser_Info.get;
    1.36 -
    1.37 -
    1.38 -
    1.39 -(** graphs **)
    1.40 -
    1.41 -fun ident_of sess s = space_implode "/" (sess @ [s]);
    1.42 -fun ident_of_thy thy = ident_of (session_chapter_name thy) (Context.theory_name thy);
    1.43 -
    1.44 -fun theory_link (curr_chapter, curr_session) thy =
    1.45 -  let
    1.46 -    val {chapter, name = session} = Browser_Info.get thy;
    1.47 -    val link = html_path (Context.theory_name thy);
    1.48 -  in
    1.49 -    if curr_session = session then SOME link
    1.50 -    else if curr_chapter = chapter then
    1.51 -      SOME (Path.appends [Path.parent, Path.basic session, link])
    1.52 -    else if chapter = Context.PureN then NONE
    1.53 -    else SOME (Path.appends [Path.parent, Path.parent, Path.basic chapter, Path.basic session, link])
    1.54 -  end;
    1.55 -
    1.56 -fun init_graph_entry session thy =
    1.57 -  let
    1.58 -    val ident = ident_of_thy thy;
    1.59 -    val parents = map ident_of_thy (Theory.parents_of thy);
    1.60 -    val node =
    1.61 -      Graph_Display.session_node
    1.62 -       {name = Context.theory_name thy,
    1.63 -        unfold = false,
    1.64 -        directory = session_name thy,
    1.65 -        path =
    1.66 -          (case theory_link session thy of
    1.67 -            NONE => ""
    1.68 -          | SOME p => Path.implode p)};
    1.69 -  in ((ident, node), parents) end;
    1.70  
    1.71  
    1.72  
    1.73 @@ -109,19 +73,15 @@
    1.74  type browser_info =
    1.75   {theories: theory_info Symtab.table,
    1.76    tex_index: (int * string) list,
    1.77 -  html_index: (int * string) list,
    1.78 -  graph: Graph_Display.entry list};
    1.79 +  html_index: (int * string) list};
    1.80  
    1.81 -fun make_browser_info (theories, tex_index, html_index, graph) : browser_info =
    1.82 -  {theories = theories, tex_index = tex_index, html_index = html_index, graph = graph};
    1.83 +fun make_browser_info (theories, tex_index, html_index) : browser_info =
    1.84 +  {theories = theories, tex_index = tex_index, html_index = html_index};
    1.85  
    1.86 -val empty_browser_info = make_browser_info (Symtab.empty, [], [], []);
    1.87 +val empty_browser_info = make_browser_info (Symtab.empty, [], []);
    1.88  
    1.89 -fun init_browser_info session thys =
    1.90 -  make_browser_info (Symtab.empty, [], [], map (init_graph_entry session) thys);
    1.91 -
    1.92 -fun map_browser_info f {theories, tex_index, html_index, graph} =
    1.93 -  make_browser_info (f (theories, tex_index, html_index, graph));
    1.94 +fun map_browser_info f {theories, tex_index, html_index} =
    1.95 +  make_browser_info (f (theories, tex_index, html_index));
    1.96  
    1.97  
    1.98  (* state *)
    1.99 @@ -130,28 +90,23 @@
   1.100  fun change_browser_info f = Synchronized.change browser_info (map_browser_info f);
   1.101  
   1.102  fun init_theory_info name info =
   1.103 -  change_browser_info (fn (theories, tex_index, html_index, graph) =>
   1.104 -    (Symtab.update (name, info) theories, tex_index, html_index, graph));
   1.105 +  change_browser_info (fn (theories, tex_index, html_index) =>
   1.106 +    (Symtab.update (name, info) theories, tex_index, html_index));
   1.107  
   1.108  fun change_theory_info name f =
   1.109 -  change_browser_info (fn (theories, tex_index, html_index, graph) =>
   1.110 +  change_browser_info (fn (theories, tex_index, html_index) =>
   1.111      (case Symtab.lookup theories name of
   1.112        NONE => error ("Browser info: cannot access theory document " ^ quote name)
   1.113 -    | SOME info =>
   1.114 -        (Symtab.update (name, map_theory_info f info) theories, tex_index, html_index, graph)));
   1.115 +    | SOME info => (Symtab.update (name, map_theory_info f info) theories, tex_index, html_index)));
   1.116  
   1.117  
   1.118  fun add_tex_index txt =
   1.119 -  change_browser_info (fn (theories, tex_index, html_index, graph) =>
   1.120 -    (theories, txt :: tex_index, html_index, graph));
   1.121 +  change_browser_info (fn (theories, tex_index, html_index) =>
   1.122 +    (theories, txt :: tex_index, html_index));
   1.123  
   1.124  fun add_html_index txt =
   1.125 -  change_browser_info (fn (theories, tex_index, html_index, graph) =>
   1.126 -    (theories, tex_index, txt :: html_index, graph));
   1.127 -
   1.128 -fun add_graph_entry entry =
   1.129 -  change_browser_info (fn (theories, tex_index, html_index, graph) =>
   1.130 -    (theories, tex_index, html_index, update Graph_Display.eq_entry entry graph));
   1.131 +  change_browser_info (fn (theories, tex_index, html_index) =>
   1.132 +    (theories, tex_index, txt :: html_index));
   1.133  
   1.134  
   1.135  
   1.136 @@ -204,7 +159,7 @@
   1.137  (* init session *)
   1.138  
   1.139  fun init build info info_path doc document_output doc_variants doc_files graph_file
   1.140 -    (chapter, name) verbose thys =
   1.141 +    (chapter, name) verbose =
   1.142    if not build andalso not info andalso doc = "" then
   1.143      (Synchronized.change browser_info (K empty_browser_info); session_info := NONE)
   1.144    else
   1.145 @@ -228,8 +183,8 @@
   1.146        session_info :=
   1.147          SOME (make_session_info (name, chapter, info_path, info, doc,
   1.148            doc_output, doc_files, graph_file, documents, verbose, readme));
   1.149 -      Synchronized.change browser_info (K (init_browser_info (chapter, name) thys));
   1.150 -      add_html_index (0, HTML.begin_session_index name docs (Url.explode "medium.html"))
   1.151 +      Synchronized.change browser_info (K empty_browser_info);
   1.152 +      add_html_index (0, HTML.begin_session_index name (Url.File session_graph_path) docs)
   1.153      end;
   1.154  
   1.155  
   1.156 @@ -265,9 +220,8 @@
   1.157    with_session_info () (fn {name, chapter, info, info_path, doc_format,
   1.158      doc_output, doc_files, graph_file, documents, verbose, readme, ...} =>
   1.159    let
   1.160 -    val {theories, tex_index, html_index, graph} = Synchronized.value browser_info;
   1.161 +    val {theories, tex_index, html_index} = Synchronized.value browser_info;
   1.162      val thys = Symtab.dest theories;
   1.163 -    val sorted_graph = Graph_Display.sort_graph graph;
   1.164  
   1.165      val chapter_prefix = Path.append info_path (Path.basic chapter);
   1.166      val session_prefix = Path.append chapter_prefix (Path.basic name);
   1.167 @@ -280,12 +234,8 @@
   1.168         (Isabelle_System.mkdirs session_prefix;
   1.169          File.write_buffer (Path.append session_prefix index_path)
   1.170            (index_buffer html_index |> Buffer.add HTML.end_document);
   1.171 +        Isabelle_System.copy_file graph_file (Path.append session_prefix session_graph_path);
   1.172          (case readme of NONE => () | SOME path => Isabelle_System.copy_file path session_prefix);
   1.173 -        Graph_Display.write_graph_browser (Path.append session_prefix graph_path) sorted_graph;
   1.174 -        Isabelle_System.isabelle_tool "browser" "-b";
   1.175 -        Isabelle_System.copy_file (Path.explode "~~/lib/browser/GraphBrowser.jar") session_prefix;
   1.176 -        List.app (fn (a, txt) => File.write (Path.append session_prefix (Path.basic a)) txt)
   1.177 -          (HTML.applet_pages name (Url.File index_path, name));
   1.178          Isabelle_System.copy_file (Path.explode "~~/etc/isabelle.css") session_prefix;
   1.179          List.app finish_html thys;
   1.180          if verbose
   1.181 @@ -301,7 +251,7 @@
   1.182            Isabelle_System.isabelle_tool "latex"
   1.183              ("-o sty " ^ File.shell_path (Path.append doc_dir (Path.basic "root.tex")));
   1.184          val _ = List.app (fn file => Isabelle_System.copy_file_base file doc_dir) doc_files;
   1.185 -        val _ = Isabelle_System.copy_file graph_file (Path.append doc_dir graph_pdf_path);
   1.186 +        val _ = Isabelle_System.copy_file graph_file (Path.append doc_dir session_graph_path);
   1.187          val _ = write_tex_index tex_index doc_dir;
   1.188          val _ =
   1.189            List.app (fn (a, {tex_source, ...}) =>
   1.190 @@ -336,6 +286,18 @@
   1.191    with_session_info () (fn _ =>
   1.192      change_theory_info name (fn (_, html_source) => (Latex.isabelle_theory name s, html_source)));
   1.193  
   1.194 +fun theory_link (curr_chapter, curr_session) thy =
   1.195 +  let
   1.196 +    val {chapter, name = session} = Browser_Info.get thy;
   1.197 +    val link = html_path (Context.theory_name thy);
   1.198 +  in
   1.199 +    if curr_session = session then SOME link
   1.200 +    else if curr_chapter = chapter then
   1.201 +      SOME (Path.appends [Path.parent, Path.basic session, link])
   1.202 +    else if chapter = Context.PureN then NONE
   1.203 +    else SOME (Path.appends [Path.parent, Path.parent, Path.basic chapter, Path.basic session, link])
   1.204 +  end;
   1.205 +
   1.206  fun begin_theory update_time mk_text thy =
   1.207    with_session_info thy (fn {name = session_name, chapter, ...} =>
   1.208      let
   1.209 @@ -346,18 +308,8 @@
   1.210          (Option.map Url.File (theory_link (chapter, session_name) parent),
   1.211            (Context.theory_name parent)));
   1.212        val html_source = HTML.theory name parent_specs (mk_text ());
   1.213 -
   1.214 -      val graph_entry =
   1.215 -        ((ident_of [chapter, session_name] name,
   1.216 -          Graph_Display.session_node
   1.217 -           {name = name,
   1.218 -            directory = session_name,
   1.219 -            unfold = true,
   1.220 -            path = Path.implode (html_path name)}),
   1.221 -          map ident_of_thy parents);
   1.222      in
   1.223        init_theory_info name (make_theory_info ("", html_source));
   1.224 -      add_graph_entry graph_entry;
   1.225        add_html_index (update_time, HTML.theory_entry (Url.File (html_path name), name));
   1.226        add_tex_index (update_time, Latex.theory_entry name);
   1.227        Browser_Info.put {chapter = chapter, name = session_name} thy