Skip to content

Commit

Permalink
[odoc] module visibility and entry list
Browse files Browse the repository at this point in the history
Only return public modules in the entry list. This change should only be
visible in unwrapped libraries. Unwrapped libraries only expose one
module that is always public anyway.

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
  • Loading branch information
rgrinberg committed Jul 31, 2019
1 parent ed64846 commit d9e31ec
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/modules.ml
Original file line number Diff line number Diff line change
Expand Up @@ -705,20 +705,21 @@ let rec obj_map
| Some (Imported_from_vlib _ | Impl_of_virtual_module _), _
| _ , Some (Imported_from_vlib _ | Impl_of_virtual_module _) -> assert false)

(* TODO perhaps return only public modules? *)
let entry_modules = function
| Stdlib w -> Stdlib.lib_interface w |> Option.to_list
| Singleton m -> [m]
| Unwrapped m -> Module.Name.Map.values m
| Wrapped m ->
(* we assume this is never called for implementations *)
begin match Wrapped.lib_interface m with
| Some m -> [m]
| None -> [m.alias_module]
end
| Impl i ->
Code_error.raise "entry_modules: not defined for implementations"
["impl", dyn_of_impl i]
let entry_modules t =
List.filter ~f:(fun m -> Module.visibility m = Public) (
match t with
| Stdlib w -> Stdlib.lib_interface w |> Option.to_list
| Singleton m -> [m]
| Unwrapped m -> Module.Name.Map.values m
| Wrapped m ->
(* we assume this is never called for implementations *)
begin match Wrapped.lib_interface m with
| Some m -> [m]
| None -> [m.alias_module]
end
| Impl i ->
Code_error.raise "entry_modules: not defined for implementations"
["impl", dyn_of_impl i])

let virtual_module_names =
fold_no_vlib ~init:Module.Name.Set.empty ~f:(fun m acc ->
Expand Down

0 comments on commit d9e31ec

Please sign in to comment.