diff --git a/.gitignore b/.gitignore
index dc6053a44d..0b1e1185b8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -61,7 +61,6 @@ lib/ocaml
*.tgz
bin/*
jscomp/bin/*.exe
-odoc_gen/*.cmxs
# for npm publish
*.exe
diff --git a/Makefile b/Makefile
index d616fe2e05..098fb7dfca 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,9 @@ test-gentype: build
test-all: test test-gentype
+lib: build
+ node scripts/install -force-lib-rebuild
+
clean-gentype:
make -C jscomp/gentype_tests/typescript-react-example clean
@@ -32,4 +35,4 @@ clean-all: clean clean-gentype
.DEFAULT_GOAL := build
-.PHONY: clean clean-gentype clean-all config build test test-gentype test-all
+.PHONY: build clean clean-gentype clean-all config lib test test-all test-gentype
diff --git a/odoc_gen/generator.ml b/odoc_gen/generator.ml
deleted file mode 100644
index 27c9b4a805..0000000000
--- a/odoc_gen/generator.ml
+++ /dev/null
@@ -1,354 +0,0 @@
-(*
-open Odoc_info
-open Value
-open Type
-open Extension
-open Exception
-open Class
-open Module
-
-module Naming = Odoc_html.Naming
-
-let opt = Odoc_info.apply_opt
-
-let new_buf () = Buffer.create 1024
-let bp = Printf.bprintf
-let bs = Buffer.add_string
-
-let bufferize f t =
- let b = new_buf () in
- f b t;
- Buffer.contents b
-
-let opt_iter opt f =
- match opt with
- | None -> ()
- | Some x -> f x
-let (|?) = opt_iter
-let print_concat b sep f =
- let rec iter = function
- [] -> ()
- | [c] -> f c
- | c :: q ->
- f c;
- bs b sep;
- iter q
- in
- iter
-
-let charset = ref "utf-8"
-
-
-type tag_function = Odoc_info.text -> string
-
-
-let wrap_tag f b v =
- bp b {|
%a
|} f v
-
-let wrap_tag_list f b = function
- | [] -> ()
- | l -> wrap_tag f b l
-
-let wrap_tag_opt f b = function
- | None -> ()
- | v -> wrap_tag f b v
-let encoding = {||}
-
-
-module Generator (G : Odoc_html.Html_generator) =
-struct
- let html_of_example b (g : G.html) t =
- bp b {|
%a
|} (fun a b -> g#html_of_text a b) t
-
- class html =
- object(self)
- inherit G.html as super
-
- val! mutable doctype = "\n"
- method! html_of_author_list = wrap_tag_list super#html_of_author_list
- method! html_of_version_opt = wrap_tag_opt super#html_of_version_opt
- method! html_of_before = wrap_tag_list super#html_of_before
- method! html_of_since_opt = wrap_tag_opt super#html_of_since_opt
- method! html_of_raised_exceptions = wrap_tag_list super#html_of_raised_exceptions
- method! html_of_return_opt = wrap_tag_opt super#html_of_return_opt
- method! html_of_sees = wrap_tag_list super#html_of_sees
-
- method! html_of_info_first_sentence b info_opt =
- bp b {|
-
- %a
-
-
|} (fun b () ->
- info_opt |? fun ({i_deprecated;i_desc} : Odoc_info.info ) ->
- i_deprecated
- |? (fun d ->
- bp b {|
- %s
- %a
-
- |}
- Odoc_messages.deprecated (fun a b -> self#html_of_text a b) d );
- i_desc |?
- (function
- | [Odoc_info.Raw ""] -> ()
- | d -> self#html_of_text b d; bs b " \n"
- )) ();
-
-
- method! html_of_info ?(cls="") ?(indent=true) b
- (info_opt : Odoc_info.info option) =
- opt_iter info_opt
- (fun ({
- i_authors ; i_version; i_before ; i_since ; i_raised_exceptions ;
- i_return_value ;
- i_sees;
- i_deprecated;
- i_desc;
- i_custom
- } ) ->
- bp b {|%a
-
- %a
-
- %a
- %a
- |}
- (fun b indent -> if indent then bp b {|
|} cls)
- indent
- (fun b () ->
- i_deprecated |?
- (fun d ->
- bp b {|
- %s
- %a
-
- |}
- Odoc_messages.deprecated (fun a b -> self#html_of_text a b) d );
- i_desc |?
- (function
- | [Odoc_info.Raw ""] -> ()
- | d -> self#html_of_text b d; bs b " \n"
- );
- self#html_of_author_list b i_authors;
- self#html_of_version_opt b i_version;
- self#html_of_before b i_before;
- self#html_of_since_opt b i_since;
- self#html_of_raised_exceptions b i_raised_exceptions;
- self#html_of_return_opt b i_return_value;
- self#html_of_sees b i_sees)
- ()
- (fun b () ->
- if i_custom <> [] then
- bp b {|
- %a
-
|}
- self#html_of_custom i_custom
- ) ()
- (fun b indent -> if indent then bs b "
\n") indent )
-
- (** Print html code for the given list of custom tagged texts. *)
- method! html_of_custom b l =
- List.iter
- (fun (tag, text) ->
- try
- let f = List.assoc tag tag_functions in
- Buffer.add_string b (f text)
- with
- Not_found ->
- Odoc_info.warning (Odoc_messages.tag_not_handled tag)
- )
- l
-
- val mutable navbar_module_index = ""
-
- method private print_module_index b =
- bs b "\n";
-
- (** Html code for navigation bar.
- @param pre optional name for optional previous module/class
- @param post optional name for optional next module/class
- @param name name of current module/class *)
- method! print_navbar b pre post name =
- self#print_module_index b; (* not really the appropriate place, but easy *)
- bs b "
";
- (
- match pre with
- None -> ()
- | Some name ->
- bp b "%s\n"
- (fst (Naming.html_files name))
- name
- Odoc_messages.previous
- );
- bs b " ";
- let father = Name.father name in
- let href = if father = "" then self#index else fst (Naming.html_files father) in
- let father_name = if father = "" then "Index" else father in
- bp b "%s\n" href father_name Odoc_messages.up;
- bs b " ";
- (
- match post with
- None -> ()
- | Some name ->
- bp b "%s\n"
- (fst (Naming.html_files name))
- name
- Odoc_messages.next
- );
- bs b "
\n"
-
- method private prepare_navbar_module_index module_list =
- let print_one b m =
- let html_file = fst (Naming.html_files m.m_name) in
- bp b "
" html_file m.m_name
- in
- navbar_module_index <- bufferize (fun b () ->
- bs b "
";
- print_concat b "\n" (print_one b) module_list;
- bs b "
";
- ) ()
-
- (** A function to build the header of pages. *)
- method! prepare_header module_list =
- let f b ?(nav=None) ?(comments=[]) t =
-
- bp b {|
-
-
-
-
-
- %s
- %a
- %s
- |}
- encoding
-
- (fun b nav ->
- nav |?
- (fun (pre_opt, post_opt, _name) ->
- pre_opt |?
- (fun name ->
- bp b {||}
- (fst (Naming.html_files name))
- );
- ( post_opt |?
- (fun name ->
- bp b {||}
- (fst (Naming.html_files name));
- )))
- )
- nav
- t
- in
- self#prepare_navbar_module_index module_list;
- (* not really the appopriate place to do this, but it's easy. Easy is good *)
- header <- f
-
- (** Generate the [.html] file corresponding to the given module list.
- @raise Failure if an error occurs.*)
- method! generate_index module_list =
- try
- let chanout = open_out (Filename.concat !Global.target_dir self#index) in
- let b = new_buf () in
- let title = match !Global.title with None -> "" | Some t -> self#escape t in
- bs b doctype ;
- bs b "\n";
- self#print_header b self#title;
- bs b "\n";
-
- bs b "
";
- bs b title;
- bs b "
\n" ;
- let info = Odoc_info.apply_opt
- (Odoc_info.info_of_comment_file module_list)
- !Odoc_info.Global.intro_file
- in
- (
- match info with
- None ->
- self#html_of_Index_list b;
- bs b " ";
- self#html_of_Module_list b
- (List.map (fun m -> m.m_name) module_list);
- | Some i -> self#html_of_info ~indent: false b info
- );
- bs b "\n";
- Buffer.output_buffer chanout b;
- close_out chanout
- with
- Sys_error s ->
- raise (Failure s)
-
-
- (** A method to create index files. *)
- method! generate_elements_index :
- 'a.
- 'a list ->
- ('a -> Odoc_info.Name.t) ->
- ('a -> Odoc_info.info option) ->
- ('a -> string) -> string -> string -> unit =
- fun elements name info target title simple_file ->
- try
- let chanout = open_out (Filename.concat !Global.target_dir simple_file) in
- let b = new_buf () in
- bs b "\n";
- self#print_header b (self#inner_title title);
- bs b "\n";
- self#print_navbar b None None "";
- bs b "
";
- bs b title;
- bs b "
\n" ;
-
- let sorted_elements = List.sort
- (fun e1 e2 -> compare (Name.simple (name e1)) (Name.simple (name e2)))
- elements
- in
- let groups = Odoc_info.create_index_lists sorted_elements (fun e -> Name.simple (name e)) in
- let f_ele e =
- let simple_name = Name.simple (name e) in
- let father_name = Name.father (name e) in
- bp b "
%s " (target e) (self#escape simple_name);
- if simple_name <> father_name && father_name <> "" then
- bp b "[%s]" (fst (Naming.html_files father_name)) father_name;
- bs b "
\n
";
- self#html_of_info_first_sentence b (info e);
- bs b "
\n";
- in
- let f_group l =
- match l with
- [] -> ()
- | e :: _ ->
- let s =
- match (Char.uppercase_ascii (Name.simple (name e)).[0]) with
- 'A'..'Z' as c -> String.make 1 c
- | _ -> ""
- in
- bs b "