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 Aug 1, 2019
1 parent e473e53 commit c5432f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@
- Add action (with-stdin-from <file> <action>) to redirect input from <file>
when performing <action>. (#2487, @nojb)

- Change the automatically generated odoc index to only list public modules.
This only affects unwrapped libraries (#2479, @rgrinberg)

1.11.0 (23/07/2019)
-------------------

Expand Down
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 c5432f4

Please sign in to comment.