Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Unreleased

### Added
- Support for OxCaml unboxed named types (@art-w, #1407)
- Support for OxCaml zero alloc definitions (@Leonidas-from-XIV, #1422, #1444)
- Remove requirement for ppx_expect in tests (@jonludlam, #1445)
- Support for OxCaml modalities (@art-w, #1420)
- Support OxCaml 5.2.0minus39 (@jonludlam, #1469)

### Fixed
- Remove requirement for ppx_expect in tests (@jonludlam, #1445)
- Fix resolving functor through `module type of` (@Leonidas-from-XIV, #1471)

# 3.2.1
Expand Down
2 changes: 1 addition & 1 deletion odoc.opam
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ depends: [

conflicts: [
"ocaml-option-bytecode-only"
"oxcaml-compiler" {< "5.2.0minus31"}
"oxcaml-compiler" {< "5.2.0minus39"}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be

Suggested change
"oxcaml-compiler" {< "5.2.0minus39"}
"oxcaml-compiler" {!= "5.2.0minus39"}

?
I just tried to install odoc on oxcaml minus39, and instead of failing as not compatible, it tried (and failed without this PR).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the plan was to be 'optimistic' - what we should do is modify the opam file for odoc.3.2.1 in opam-repository to have an upper bound, but to leave this as is, just in case by some miracle minus47 comes out next week and it doesn't require changes :-)

]

x-extra-doc-deps: [
Expand Down
4 changes: 3 additions & 1 deletion src/loader/cmi.ml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ let mark_type ty =
| Tlink _ -> assert false
#if defined OXCAML
| Tquote typ -> loop visited typ
| Tquote_eval typ -> loop visited typ
| Tsplice typ -> loop visited typ
| Tof_kind _ -> ()
| Trepr _ -> ()
Expand Down Expand Up @@ -499,7 +500,7 @@ let rec read_jkind_annotation (jk : Parsetree.jkind_annotation) =
let open Kind in
match jk.pjka_desc with
| Pjk_default -> Default
| Pjk_abbreviation s -> Abbreviation (Env.Fragment.read_type s.txt)
| Pjk_abbreviation (s, _) -> Abbreviation (Env.Fragment.read_type s.txt)
| Pjk_mod (jk', modes) ->
let modes = List.map (fun (m : Parsetree.mode Location.loc) ->
let (Parsetree.Mode s) = m.txt in s) modes in
Expand Down Expand Up @@ -665,6 +666,7 @@ let rec read_type_expr env typ =
| Tlink _ -> assert false
#if defined OXCAML
| Tquote typ -> Quote (read_type_expr env typ)
| Tquote_eval typ -> Quote (read_type_expr env typ)
| Tsplice typ -> Splice (read_type_expr env typ)
| Tof_kind _ -> assert false
| Trepr _ -> Any (* oxcaml: representation annotations are ignored *)
Expand Down
5 changes: 3 additions & 2 deletions src/loader/cmt.ml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ let rec read_pattern env parent doc id_attrs pat =
#if OCAML_VERSION < (5,2,0)
| Tpat_var(id, _) ->
#elif defined OXCAML
| Tpat_var(id, _, _uid, _, _) ->
| Tpat_var { id; _ } ->
#else
| Tpat_var(id, _, _uid) ->
#endif
Expand All @@ -58,7 +58,7 @@ let rec read_pattern env parent doc id_attrs pat =
#if OCAML_VERSION < (5,2, 0)
| Tpat_alias(pat, id, _) ->
#elif defined OXCAML
| Tpat_alias(pat, id, _, _, _, _, _) ->
| Tpat_alias { pattern = pat; id; _ } ->
#elif OCAML_VERSION < (5,4,0)
| Tpat_alias(pat, id, _,_) ->
#else
Expand Down Expand Up @@ -120,6 +120,7 @@ let rec read_pattern env parent doc id_attrs pat =
#if defined OXCAML
| Tpat_unboxed_unit -> []
| Tpat_unboxed_bool _ -> []
| Tpat_fun_layout _ -> []
#endif

let read_value_binding env parent id_attrs vb =
Expand Down
22 changes: 15 additions & 7 deletions src/loader/cmti.ml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ let rec read_core_type env container ctyp =
| Ttyp_call_pos -> Constr(Env.Path.read_type env.ident_env Predef.path_lexing_position, [])
| Ttyp_of_kind _ -> assert false
| Ttyp_repr _ -> Any (* oxcaml: representation annotations are ignored *)
| Ttyp_newlayout (_, ct) ->
(* oxcaml: layout-variable binder; odoc ignores the layout vars *)
read_core_type env container ct
#elif OCAML_VERSION >= (5,5,0)
| Ttyp_functor (lbl, id, pkg, ret_type) ->
let lbl = read_label lbl in
Expand Down Expand Up @@ -586,28 +589,33 @@ let rec read_with_constraint env global_parent parent (_, frag, constr) =
| Twith_type decl ->
let frag = Env.Fragment.read_type frag.Location.txt in
let eq = read_type_equation env parent decl in
TypeEq(frag, eq)
Some (TypeEq(frag, eq))
| Twith_module(p, _) ->
let frag = Env.Fragment.read_module frag.Location.txt in
let eq = read_module_equation env p in
ModuleEq(frag, eq)
Some (ModuleEq(frag, eq))
| Twith_typesubst decl ->
let frag = Env.Fragment.read_type frag.Location.txt in
let eq = read_type_equation env parent decl in
TypeSubst(frag, eq)
Some (TypeSubst(frag, eq))
| Twith_modsubst(p, _) ->
let frag = Env.Fragment.read_module frag.Location.txt in
let p = Env.Path.read_module env.ident_env p in
ModuleSubst(frag, p)
Some (ModuleSubst(frag, p))
#if OCAML_VERSION >= (4,13,0)
| Twith_modtype mty ->
let frag = Env.Fragment.read_module_type frag.Location.txt in
let mty = read_module_type env global_parent parent mty in
ModuleTypeEq(frag, mty)
Some (ModuleTypeEq(frag, mty))
| Twith_modtypesubst mty ->
let frag = Env.Fragment.read_module_type frag.Location.txt in
let mty = read_module_type env global_parent parent mty in
ModuleTypeSubst(frag, mty)
Some (ModuleTypeSubst(frag, mty))
#endif
#if defined OXCAML
(* oxcaml: [with kind] constraints have no representation in odoc's
model, so they are dropped. *)
| Twith_jkind _ | Twith_jkindsubst _ -> None
#endif

and read_module_type env parent label_parent mty =
Expand Down Expand Up @@ -671,7 +679,7 @@ and read_module_type env parent label_parent mty =
#endif
| Tmty_with(body, subs) -> (
let body = read_module_type env parent label_parent body in
let subs = List.map (read_with_constraint env parent label_parent) subs in
let subs = List.filter_map (read_with_constraint env parent label_parent) subs in
match Odoc_model.Lang.umty_of_mty body with
| Some w_expr ->
With {w_substitutions=subs; w_expansion=None; w_expr }
Expand Down
5 changes: 3 additions & 2 deletions src/loader/ident_env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ let rec read_pattern hide_item pat =
#if OCAML_VERSION < (5,2,0)
| Tpat_var(id, loc) ->
#elif defined OXCAML
| Tpat_var(id, loc, _, _, _) ->
| Tpat_var { id; name = loc; _ } ->
#else
| Tpat_var(id, loc, _) ->
#endif
[`Value(id, hide_item, Some loc.loc)]
#if OCAML_VERSION < (5,2,0)
| Tpat_alias(pat, id, loc) ->
#elif defined OXCAML
| Tpat_alias(pat, id, loc, _, _, _, _) ->
| Tpat_alias { pattern = pat; id; name = loc; _ } ->
#elif OCAML_VERSION < (5,4,0)
| Tpat_alias(pat, id, loc, _) ->
#else
Expand Down Expand Up @@ -367,6 +367,7 @@ let rec read_pattern hide_item pat =
#if defined OXCAML
| Tpat_unboxed_unit -> []
| Tpat_unboxed_bool _ -> []
| Tpat_fun_layout _ -> []
#endif

let rec extract_structure_tree_items : bool -> Typedtree.structure_item list -> items list = fun hide_item items ->
Expand Down
4 changes: 4 additions & 0 deletions src/loader/odoc_loader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ let read_cmi ~make_root ~parent ~filename ~warnings_tag () =
let name = name |> name_to_string in
let id, sg =
Cmi.read_interface parent name ~warnings_tag
#if defined OXCAML
(Odoc_model.Compat.signature (fst cmi_info.cmi_sign))
#else
(Odoc_model.Compat.signature cmi_info.cmi_sign)
#endif
in
#if defined OXCAML
let imports =
Expand Down
6 changes: 3 additions & 3 deletions src/loader/typedtree_traverse.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Analysis = struct
else
match expr.exp_desc with
#if defined OXCAML
| Texp_ident (p, _, _, _, _, _) ->
| Texp_ident { path = p; _ } ->
#else
| Texp_ident (p, _, _) ->
#endif
Expand All @@ -31,7 +31,7 @@ module Analysis = struct
let () =
match pat_desc with
#if defined OXCAML
| Tpat_var (id, loc, _uid, _, _) -> (
| Tpat_var { id; name = loc; _ } -> (
#elif OCAML_VERSION >= (5, 2, 0)
| Tpat_var (id, loc, _uid) -> (
#else
Expand All @@ -41,7 +41,7 @@ module Analysis = struct
| Some x -> poses := x :: !poses
| None -> ())
#if defined OXCAML
| Tpat_alias (_, id, loc, _uid, _, _, _) -> (
| Tpat_alias { id; name = loc; _ } -> (
#elif OCAML_VERSION >= (5, 4, 0)
| Tpat_alias (_, id, loc, _uid, _ty) -> (
#elif OCAML_VERSION >= (5, 2, 0)
Expand Down
3 changes: 1 addition & 2 deletions src/syntax_highlighter/syntax_highlighter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,14 @@ let tag_of_token (tok : Parser.token) =
| HASH_SUFFIX -> "HASH_SUFFIX"
| KIND -> "KIND"
| KIND_OF -> "KIND_OF"
| LAYOUT -> "LAYOUT"
| LBRACKETCOLON -> "LBRACKETCOLON"
| LESSLBRACKET -> "LESSLBRACKET"
| LOCAL -> "LOCAL"
| MOD -> "MOD"
| ONCE -> "ONCE"
| OVERWRITE -> "OVERWRITE"
| RBRACKETGREATER -> "RBRACKETGREATER"
| STACK -> "STACK"
| UNIQUE -> "UNIQUE"
#endif
#if OCAML_VERSION >= (5,3,0)
| METAOCAML_ESCAPE -> "METAOCAML_ESCAPE"
Expand Down
25 changes: 16 additions & 9 deletions test/xref2/lib/common.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -617,16 +617,23 @@ let my_compilation_unit id (s : Odoc_model.Lang.Signature.t) =
}

let mkresolver () =
Odoc_odoc.Resolver.create
~roots:None ~important_digests:false
~directories:(List.map Odoc_odoc.Fs.Directory.of_string
#if OCAML_VERSION >= (5,2,0)
(let paths = Load_path.get_paths () in
List.filter (fun s -> s <> "") (paths.visible @ paths.hidden))
#else
(Load_path.get_paths () |> List.filter (fun s -> s <> ""))
let str_dirs =
#if defined OXCAML
let paths = Load_path.get_paths () in
let visible = List.map (fun (v : Clflags.visible_include) -> v.path) paths.visible in
visible @ paths.hidden
#elif OCAML_VERSION >= (5,2,0)
let paths = Load_path.get_paths () in
paths.visible @ paths.hidden
#else
Load_path.get_paths ()
#endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is starting to get hard to read ^^' Maybe consider extracting?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call - I've tidied it a bit

) ~open_modules:[]
in
let nonempty_str_dirs = List.filter (fun s -> s <> "") str_dirs in
let directories = List.map Odoc_odoc.Fs.Directory.of_string nonempty_str_dirs in
Odoc_odoc.Resolver.create
~roots:None ~important_digests:false
~directories ~open_modules:[]

let warnings_options =
{ Odoc_model.Error.warn_error = false; print_warnings = true; warnings_tag = None }
Expand Down
Loading