From db467dc56f11fde42edf356369d7305e6b52243b Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 24 Sep 2022 06:13:28 +0200 Subject: [PATCH 1/3] Remove odoc_gen. --- .gitignore | 1 - odoc_gen/generator.ml | 354 ----------------------------------------- odoc_gen/generator.mli | 1 - scripts/doc_gen.js | 117 -------------- scripts/ninja.js | 5 +- 5 files changed, 1 insertion(+), 477 deletions(-) delete mode 100644 odoc_gen/generator.ml delete mode 100644 odoc_gen/generator.mli delete mode 100644 scripts/doc_gen.js 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/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 "
  • %s
  • " html_file m.m_name - in - navbar_module_index <- bufferize (fun b () -> - 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 "
    "; - bs b s ; - bs b "\n" ; - List.iter f_ele l - in - bs b "\n"; - List.iter f_group groups ; - bs b "
    \n" ; - bs b "\n"; - Buffer.output_buffer chanout b; - close_out chanout - with - Sys_error s -> - raise (Failure s) - - initializer - tag_functions <- ("example", - bufferize (fun b text -> html_of_example b (self :> G.html) text)) - :: tag_functions - end -end -let _ = Odoc_args.extend_html_generator (module Generator : Odoc_gen.Html_functor); -*) -(* local variables: *) -(* compile-command: "ocamlc.opt -I +compiler-libs -I +ocamldoc -c generator.mli generator.ml" *) -(* end: *) diff --git a/odoc_gen/generator.mli b/odoc_gen/generator.mli deleted file mode 100644 index 03ee5d5f11..0000000000 --- a/odoc_gen/generator.mli +++ /dev/null @@ -1 +0,0 @@ -(**) diff --git a/scripts/doc_gen.js b/scripts/doc_gen.js deleted file mode 100644 index be6dffa6fe..0000000000 --- a/scripts/doc_gen.js +++ /dev/null @@ -1,117 +0,0 @@ -//@ts-check - -// This assume you already have cmi at hand -// Okay to use ES6 since it is generated before shipping - -var fs = require("fs"); - -var path = require("path"); -var child_process = require("child_process"); - -var versionPrefix = require("./buildocaml.js").getVersionPrefix(); -var stdlibVersion = versionPrefix.includes("4.02") - ? "stdlib-402" - : "stdlib-406"; -var runtime_dir = path.join(__dirname, "..", "jscomp", "runtime"); -var others_dir = path.join(__dirname, "..", "jscomp", "others"); -var stdlib_dir = path.join(__dirname, "..", "jscomp", stdlibVersion); -var jscomp = path.join(__dirname, "..", "jscomp"); -var runtime_prefix = path.relative(jscomp, runtime_dir); -var others_prefix = path.relative(jscomp, others_dir); -var ocamldoc = path.join( - __dirname, - "..", - "native", - versionPrefix, - "bin", - "ocamldoc.opt" -); - -/** - * - * @param {string} s - */ -const capitalize = s => { - if (typeof s !== "string") return ""; - return s.charAt(0).toUpperCase() + s.slice(1); -}; -/** - * - * @param {string} filename - */ -const strip = filename => filename.split(".").slice(0, -1).join("."); -function main() { - /** - * @type {string[]} - */ - var hidden_list = []; - var runtime_files = fs - .readdirSync(runtime_dir) - .filter( - file => - file.startsWith("js") && - (file.endsWith(".ml") || file.endsWith(".mli")) && - !file.endsWith(".cppo.ml") && - !file.endsWith(".cppo.mli") - ) - .map(x => { - if (x.includes("internal")) { - hidden_list.push(capitalize(strip(x))); - } - return path.join(runtime_prefix, x); - }) - .join(" "); - - var others_files = fs - .readdirSync(others_dir) - .filter( - file => - (file.endsWith(".ml") || file.endsWith(".mli")) && - !file.endsWith(".cppo.ml") && - !file.endsWith(".cppo.mli") - ) - .map(x => { - if (x.includes("internal")) { - hidden_list.push(capitalize(strip(x))); - } - return path.join(others_prefix, x); - }) - .join(" "); - - var odoc_gendir = path.join(__dirname, "..", "odoc_gen"); - - var api_doc_dir = path.join(__dirname, "..", "docs", "api"); - var intro = path.join(__dirname, "..", "jscomp", "others", "intro.txt"); - // - var generator = `-g ${odoc_gendir}/generator.cmxs`; - // var generator = `-html` - - var hidden_modules = ``; - // hidden_modules = `-hide ${hidden_list.join(',')}` - - var prefix_flags = `${ocamldoc} ${generator} ${hidden_modules} -w -40 -nostdlib -nopervasives -I ${others_dir} -I ${runtime_dir} -open Bs_stdlib_mini -charset utf-8 -intro ${intro} -sort -ppx '${path.join( - __dirname, - "..", - process.platform, - "bsc" - )} -as-ppx' -d ${api_doc_dir}`; - - // -html it is weird - // It is weird, -html will unload the plugin - - // It seems ocamldoc does need require all files for indexing modules, WTF ocamldoc !! - var cmd = `${prefix_flags} ${runtime_files} ${others_files}`; - - console.log(`Running ${cmd}`); - - child_process.execSync(cmd, { cwd: jscomp, encoding: "utf8" }); -} -exports.main = main; -if (require.main === module) { - main(); -} -// console.log(`runtime files : ${runtime_files}`) -// child_process.execSync(`${prefix_flags} ${runtime_files} `, {cwd : runtime_dir}) - -// console.log(`others files : ${others_files}`) -// child_process.execSync(`${prefix_flags} ${others_files} `, {cwd : others_dir}) diff --git a/scripts/ninja.js b/scripts/ninja.js index 9af05a06a7..4e4950f063 100755 --- a/scripts/ninja.js +++ b/scripts/ninja.js @@ -1747,10 +1747,7 @@ ${mlyRule} ${mlyList("ml", ["parser.mly"])} -rule mk_shared - command = $ocamlopt -I +compiler-libs -shared $flags -o $out $in -o ../odoc_gen/generator.cmxs : mk_shared ../odoc_gen/generator.mli ../odoc_gen/generator.ml - flags = -I +ocamldoc -I ../odoc_gen -absname + `; /** * @type { {name : string, libs: string[]}[]} From 28f0597e982803f88ba0697e375fe63a246ecd9a Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 24 Sep 2022 06:35:00 +0200 Subject: [PATCH 2/3] artifacts --- Makefile | 8 +++++++- packages/artifacts.txt | 2 -- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d616fe2e05..52520b0581 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,12 @@ test-gentype: build test-all: test test-gentype +lib: build + node scripts/install -force-lib-rebuild + +artifacts: lib + ./scripts/makeArtifactList.js + clean-gentype: make -C jscomp/gentype_tests/typescript-react-example clean @@ -32,4 +38,4 @@ clean-all: clean clean-gentype .DEFAULT_GOAL := build -.PHONY: clean clean-gentype clean-all config build test test-gentype test-all +.PHONY: artifacts build clean clean-gentype clean-all config lib test test-all test-gentype diff --git a/packages/artifacts.txt b/packages/artifacts.txt index 19974f2169..28bbee615e 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -946,7 +946,6 @@ linux/bsc.exe linux/ninja.exe linux/refmt.exe linux/rescript.exe -ninja.COPYING package.json rescript scripts/LICENSE.ml @@ -962,7 +961,6 @@ scripts/cover.sh scripts/curry_gen.ml scripts/dbg scripts/dedupe.js -scripts/doc_gen.js scripts/install.js scripts/installUtils.js scripts/js_internal_gen.js From 6ec747c43e990e59fd614cfb380586c0676eb407 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Sat, 24 Sep 2022 06:42:38 +0200 Subject: [PATCH 3/3] Locally building the list of artifacts does not really work. There are all these executables missing, and the ninja.COPYING things only happens in CI. --- Makefile | 5 +---- packages/artifacts.txt | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 52520b0581..098fb7dfca 100644 --- a/Makefile +++ b/Makefile @@ -24,9 +24,6 @@ test-all: test test-gentype lib: build node scripts/install -force-lib-rebuild -artifacts: lib - ./scripts/makeArtifactList.js - clean-gentype: make -C jscomp/gentype_tests/typescript-react-example clean @@ -38,4 +35,4 @@ clean-all: clean clean-gentype .DEFAULT_GOAL := build -.PHONY: artifacts build clean clean-gentype clean-all config lib test test-all test-gentype +.PHONY: build clean clean-gentype clean-all config lib test test-all test-gentype diff --git a/packages/artifacts.txt b/packages/artifacts.txt index 28bbee615e..0c205c4157 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -946,6 +946,7 @@ linux/bsc.exe linux/ninja.exe linux/refmt.exe linux/rescript.exe +ninja.COPYING package.json rescript scripts/LICENSE.ml