src/Pure/Thy/present.ML
changeset 61381 ddca85598c65
parent 61372 cf40b6b1de54
child 62549 9498623b27f0
equal deleted inserted replaced
61380:3907f20bef8c 61381:ddca85598c65
     8 sig
     8 sig
     9   val session_name: theory -> string
     9   val session_name: theory -> string
    10   val session_graph: string -> (string -> bool) -> theory -> Graph_Display.entry list
    10   val session_graph: string -> (string -> bool) -> theory -> Graph_Display.entry list
    11   val document_enabled: string -> bool
    11   val document_enabled: string -> bool
    12   val document_variants: string -> (string * string) list
    12   val document_variants: string -> (string * string) list
    13   val init: bool -> bool -> Path.T -> string -> string -> (string * string) list ->
    13   val init: HTML.symbols -> bool -> bool -> Path.T -> string -> string -> (string * string) list ->
    14     (Path.T * Path.T) list -> Path.T -> string * string -> bool -> unit
    14     (Path.T * Path.T) list -> Path.T -> string * string -> bool -> unit
    15   val finish: unit -> unit
    15   val finish: unit -> unit
    16   val theory_output: string -> string -> unit
    16   val theory_output: string -> string -> unit
    17   val begin_theory: int -> (unit -> HTML.text) -> theory -> theory
    17   val begin_theory: int -> (unit -> HTML.text) -> theory -> theory
    18   val display_drafts: Path.T list -> int
    18   val display_drafts: Path.T list -> int
   136 (** global session state **)
   136 (** global session state **)
   137 
   137 
   138 (* session_info *)
   138 (* session_info *)
   139 
   139 
   140 type session_info =
   140 type session_info =
   141   {name: string, chapter: string, info_path: Path.T, info: bool, doc_format: string,
   141   {symbols: HTML.symbols, name: string, chapter: string, info_path: Path.T, info: bool,
   142     doc_output: Path.T option, doc_files: (Path.T * Path.T) list, graph_file: Path.T,
   142     doc_format: string, doc_output: Path.T option, doc_files: (Path.T * Path.T) list,
   143     documents: (string * string) list, verbose: bool, readme: Path.T option};
   143     graph_file: Path.T, documents: (string * string) list, verbose: bool, readme: Path.T option};
   144 
   144 
   145 fun make_session_info
   145 fun make_session_info
   146   (name, chapter, info_path, info, doc_format, doc_output, doc_files,
   146   (symbols, name, chapter, info_path, info, doc_format, doc_output, doc_files,
   147     graph_file, documents, verbose, readme) =
   147     graph_file, documents, verbose, readme) =
   148   {name = name, chapter = chapter, info_path = info_path, info = info, doc_format = doc_format,
   148   {symbols = symbols, name = name, chapter = chapter, info_path = info_path, info = info,
   149     doc_output = doc_output, doc_files = doc_files, graph_file = graph_file,
   149     doc_format = doc_format, doc_output = doc_output, doc_files = doc_files, graph_file = graph_file,
   150     documents = documents, verbose = verbose, readme = readme}: session_info;
   150     documents = documents, verbose = verbose, readme = readme}: session_info;
   151 
   151 
   152 
   152 
   153 (* state *)
   153 (* state *)
   154 
   154 
   179   in variants end;
   179   in variants end;
   180 
   180 
   181 
   181 
   182 (* init session *)
   182 (* init session *)
   183 
   183 
   184 fun init build info info_path doc document_output doc_variants doc_files graph_file
   184 fun init symbols build info info_path doc document_output doc_variants doc_files graph_file
   185     (chapter, name) verbose =
   185     (chapter, name) verbose =
   186   if not build andalso not info andalso doc = "" then
   186   if not build andalso not info andalso doc = "" then
   187     (Synchronized.change browser_info (K empty_browser_info); session_info := NONE)
   187     (Synchronized.change browser_info (K empty_browser_info); session_info := NONE)
   188   else
   188   else
   189     let
   189     let
   202       val docs =
   202       val docs =
   203         (case readme of NONE => [] | SOME p => [(Url.File p, "README")]) @
   203         (case readme of NONE => [] | SOME p => [(Url.File p, "README")]) @
   204           map (fn (name, _) => (Url.File (Path.ext doc (Path.basic name)), name)) documents;
   204           map (fn (name, _) => (Url.File (Path.ext doc (Path.basic name)), name)) documents;
   205     in
   205     in
   206       session_info :=
   206       session_info :=
   207         SOME (make_session_info (name, chapter, info_path, info, doc,
   207         SOME (make_session_info (symbols, name, chapter, info_path, info, doc,
   208           doc_output, doc_files, graph_file, documents, verbose, readme));
   208           doc_output, doc_files, graph_file, documents, verbose, readme));
   209       Synchronized.change browser_info (K empty_browser_info);
   209       Synchronized.change browser_info (K empty_browser_info);
   210       add_html_index (0, HTML.begin_session_index name (Url.File session_graph_path) docs)
   210       add_html_index (0, HTML.begin_session_index symbols name (Url.File session_graph_path) docs)
   211     end;
   211     end;
   212 
   212 
   213 
   213 
   214 (* isabelle tool wrappers *)
   214 (* isabelle tool wrappers *)
   215 
   215 
   318     else if chapter = Context.PureN then NONE
   318     else if chapter = Context.PureN then NONE
   319     else SOME (Path.appends [Path.parent, Path.parent, Path.basic chapter, Path.basic session, link])
   319     else SOME (Path.appends [Path.parent, Path.parent, Path.basic chapter, Path.basic session, link])
   320   end;
   320   end;
   321 
   321 
   322 fun begin_theory update_time mk_text thy =
   322 fun begin_theory update_time mk_text thy =
   323   with_session_info thy (fn {name = session_name, chapter, ...} =>
   323   with_session_info thy (fn {symbols, name = session_name, chapter, ...} =>
   324     let
   324     let
   325       val name = Context.theory_name thy;
   325       val name = Context.theory_name thy;
   326       val parents = Theory.parents_of thy;
   326       val parents = Theory.parents_of thy;
   327 
   327 
   328       val parent_specs = parents |> map (fn parent =>
   328       val parent_specs = parents |> map (fn parent =>
   329         (Option.map Url.File (theory_link (chapter, session_name) parent),
   329         (Option.map Url.File (theory_link (chapter, session_name) parent),
   330           (Context.theory_name parent)));
   330           (Context.theory_name parent)));
   331       val html_source = HTML.theory name parent_specs (mk_text ());
   331       val html_source = HTML.theory symbols name parent_specs (mk_text ());
   332     in
   332     in
   333       init_theory_info name (make_theory_info ("", html_source));
   333       init_theory_info name (make_theory_info ("", html_source));
   334       add_html_index (update_time, HTML.theory_entry (Url.File (html_path name), name));
   334       add_html_index (update_time, HTML.theory_entry symbols (Url.File (html_path name), name));
   335       add_tex_index (update_time, Latex.theory_entry name);
   335       add_tex_index (update_time, Latex.theory_entry name);
   336       Browser_Info.put {chapter = chapter, name = session_name} thy
   336       Browser_Info.put {chapter = chapter, name = session_name} thy
   337     end);
   337     end);
   338 
   338 
   339 
   339