From 98cb20d6179600053f7d923f7410b737935179e7 Mon Sep 17 00:00:00 2001 From: Lucas Franceschino Date: Wed, 15 Nov 2023 15:30:48 +0100 Subject: [PATCH] feat(doc): init rustdoc and odoc --- cli/default.nix | 29 ++++++++++++++++++++++++++++- engine/default.nix | 10 +++++++++- engine/doc/dune | 3 +++ engine/doc/index.mld | 21 +++++++++++++++++++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 engine/doc/dune create mode 100644 engine/doc/index.mld diff --git a/cli/default.nix b/cli/default.nix index e28dd1a98..b03b15cd4 100644 --- a/cli/default.nix +++ b/cli/default.nix @@ -44,6 +44,32 @@ // { inherit cargoArtifacts pname; }); + frontend-docs = craneLib.cargoDoc (commonArgs // {inherit cargoArtifacts pname;}); + docs = stdenv.mkDerivation { + name = "hax-docs"; + unpackPhase = "true"; + buildPhase = "true"; + installPhase = '' + mkdir $out + cp -r ${frontend-docs}/share/doc $out/frontend + cp -r ${hax-engine.docs} $out/engine + cd $out + INDEX=$(mktemp) + ( + echo "" + echo "

Hax docs

" + echo "

Hax is written both in Rust and OCaml. Documentation for each is available below:

" + echo "" + ) > $INDEX + mv $INDEX index.html + ''; + }; binaries = [hax hax-engine rustc gcc]; tests = craneLib.buildPackage (commonArgs // { @@ -77,6 +103,7 @@ in meta.mainProgram = "cargo-hax"; passthru = { unwrapped = hax; - inherit tests; + engine-docs = hax-engine.docs; + inherit tests docs frontend-docs; }; } diff --git a/engine/default.nix b/engine/default.nix index 9bb289c39..3c3c82aaa 100644 --- a/engine/default.nix +++ b/engine/default.nix @@ -41,7 +41,7 @@ pname = "hax-engine"; version = "0.0.1"; duneVersion = "3"; - src = lib.sourceFilesBySuffices ./. [".ml" ".mli" ".js" "dune" "dune-project" "sh" "rs"]; + src = lib.sourceFilesBySuffices ./. [".ml" ".mli" ".js" "dune" "dune-project" "sh" "rs" "mld"]; buildInputs = with ocamlPackages; [ zarith_stubs_js @@ -87,6 +87,14 @@ ]; strictDeps = true; passthru = { + docs = hax-engine.overrideAttrs (old: { + name = "hax-engine-docs"; + nativeBuildInputs = old.nativeBuildInputs ++ [ + ocamlPackages.odoc + ]; + buildPhase = ''dune build @doc''; + installPhase = "cp -rf _build/default/_doc/_html $out"; + }); js = hax-engine.overrideAttrs (old: { name = "hax-engine.js"; nativeBuildInputs = old.nativeBuildInputs ++ [closurecompiler gnused]; diff --git a/engine/doc/dune b/engine/doc/dune new file mode 100644 index 000000000..9ee3c430b --- /dev/null +++ b/engine/doc/dune @@ -0,0 +1,3 @@ +(documentation + (package hax-engine) + (mld_files index)) \ No newline at end of file diff --git a/engine/doc/index.mld b/engine/doc/index.mld new file mode 100644 index 000000000..8ca1a52b0 --- /dev/null +++ b/engine/doc/index.mld @@ -0,0 +1,21 @@ +{0 Hax Engine} + +The engine of hax is written in OCaml, and has the following structure: +{ul {- the {!module-Hax_engine} library (located in `/engine/lib`)} + {- the {!module-Native_driver} binary (located in `/engine/bin`)} + {- the backends (located in `/engine/backends`): + {ul {- {!module-Fstar_backend}} + {- {!module-Coq_ast}} + {- {!module-Easycrypt_ast}} + } + } + {- utilities and PPXs: + {ul {- {!module-Hacspeclib_macro_parser}} + {- {!module-Ppx_functor_application}} + {- {!module-Ppx_generate_features}} + {- {!module-Ppx_inline}} + } + } +} + +