Skip to content

Commit

Permalink
Move ident_env into loader
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Ludlam <jon@recoil.org>
  • Loading branch information
jonludlam committed Feb 8, 2021
1 parent 6d3226a commit 9a92326
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 62 deletions.
3 changes: 1 addition & 2 deletions src/loader/cmi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ open Odoc_model.Paths
open Odoc_model.Lang
open Odoc_model.Names

module Env = Odoc_model.Ident_env
module Env = Ident_env
module Paths = Odoc_model.Paths
module Ident_env = Odoc_model.Ident_env

let opt_map f = function
| None -> None
Expand Down
2 changes: 0 additions & 2 deletions src/loader/cmi.mli
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@


module Paths = Odoc_model.Paths
module Ident_env = Odoc_model.Ident_env



val read_interface: Odoc_model.Paths.Identifier.ContainerPage.t -> string -> Odoc_model.Compat.signature ->
Expand Down
2 changes: 1 addition & 1 deletion src/loader/cmt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module OCamlPath = Path
open Odoc_model.Paths
open Odoc_model.Lang

module Env = Odoc_model.Ident_env
module Env = Ident_env


let read_core_type env ctyp =
Expand Down
3 changes: 1 addition & 2 deletions src/loader/cmti.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ open Odoc_model.Paths
open Odoc_model.Lang
open Odoc_model.Names

module Env = Odoc_model.Ident_env
module Env = Ident_env
module Paths = Odoc_model.Paths
module Ident_env = Odoc_model.Ident_env

let read_module_expr : (Ident_env.t -> Identifier.Signature.t -> Identifier.LabelParent.t -> Typedtree.module_expr -> ModuleType.expr) ref = ref (fun _ _ _ _ -> failwith "unset")

Expand Down
1 change: 0 additions & 1 deletion src/loader/cmti.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*)

module Paths = Odoc_model.Paths
module Ident_env = Odoc_model.Ident_env

val read_module_expr : (Ident_env.t -> Paths.Identifier.Signature.t -> Paths.Identifier.LabelParent.t -> Typedtree.module_expr -> Odoc_model.Lang.ModuleType.expr) ref
val read_interface :
Expand Down
18 changes: 18 additions & 0 deletions src/loader/dune
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
(rule
(targets ident_env.ml)
(deps
(:x ident_env.cppo.ml))
(action
(chdir
%{workspace_root}
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{x} -o %{targets}))))

(rule
(targets ident_env.mli)
(deps
(:x ident_env.cppo.mli))
(action
(chdir
%{workspace_root}
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{x} -o %{targets}))))

(library
(name odoc_loader)
(public_name odoc.loader)
Expand Down
53 changes: 17 additions & 36 deletions src/model/ident_env.cppo.ml → src/loader/ident_env.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

open Odoc_model
open Predefined
open Names

Expand All @@ -23,6 +24,8 @@ open Typedtree

type type_ident = Paths.Identifier.Path.Type.t

let dummy_parent : Paths.Identifier.LabelParent.t = `Root (`RootPage (PageName.of_string ""), ModuleName.of_string "")

type t =
{ modules : Id.Module.t Ident.tbl;
module_paths : P.Module.t Ident.tbl;
Expand Down Expand Up @@ -194,22 +197,12 @@ let extract_signature_tree_item item =
| Tsig_include incl ->
[`Include (extract_signature_type_items (Compat.signature incl.incl_type))]

| Tsig_attribute
{
attr_name = { txt = "ocaml.text"; _ };
attr_payload =
PStr
[
{
pstr_desc =
Pstr_eval
({ pexp_desc = Pexp_constant (Pconst_string ("/*", _)); _ }, _);
_
};
];
_;
} -> doc_off_mode_on := not !doc_off_mode_on; []

| Tsig_attribute attr -> begin
match Doc_attr.standalone dummy_parent attr with
| Some `Stop ->
doc_off_mode_on := not !doc_off_mode_on; []
| _ -> []
end
| Tsig_class cls ->
List.map
(fun cld ->
Expand Down Expand Up @@ -240,8 +233,7 @@ let extract_signature_tree_item item =
List.map (fun decl -> `Type (decl.typ_id, false)) ts
#endif
| Tsig_typext _
| Tsig_exception _ | Tsig_open _
| Tsig_attribute _ -> []
| Tsig_exception _ | Tsig_open _ -> []

let extract_signature_tree_items sg =
let open Typedtree in
Expand Down Expand Up @@ -301,22 +293,12 @@ let extract_structure_tree_item item =
| Tstr_include incl ->
[`Include (extract_signature_type_items (Compat.signature incl.incl_type))]

| Tstr_attribute
{
attr_name = { txt = "ocaml.text"; _ };
attr_payload =
PStr
[
{
pstr_desc =
Pstr_eval
({ pexp_desc = Pexp_constant (Pconst_string ("/*", _)); _ }, _);
_
};
];
_;
} -> doc_off_mode_on := not !doc_off_mode_on; []

| Tstr_attribute attr -> begin
match Doc_attr.standalone dummy_parent attr with
| Some `Stop ->
doc_off_mode_on := not !doc_off_mode_on; []
| _ -> []
end
| Tstr_class cls ->
List.map
#if OCAML_MAJOR = 4 && OCAML_MINOR = 02
Expand Down Expand Up @@ -353,8 +335,7 @@ let extract_structure_tree_item item =
#endif
| Tstr_eval _
| Tstr_primitive _ | Tstr_typext _
| Tstr_exception _
| Tstr_attribute _ -> []
| Tstr_exception _ -> []

let extract_structure_tree_items str =
let open Typedtree in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

open Odoc_model

type t

val empty : t
Expand Down
18 changes: 0 additions & 18 deletions src/model/dune
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
(rule
(targets ident_env.ml)
(deps
(:x ident_env.cppo.ml))
(action
(chdir
%{workspace_root}
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{x} -o %{targets}))))

(rule
(targets ident_env.mli)
(deps
(:x ident_env.cppo.mli))
(action
(chdir
%{workspace_root}
(run %{bin:cppo} -V OCAML:%{ocaml_version} %{x} -o %{targets}))))

(rule
(targets compat.ml)
(deps
Expand Down

0 comments on commit 9a92326

Please # to comment.