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 a36e408
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@
- Add a new config option `sandboxing_preference`, the cli argument `--sandbox`,
and the dep spec `sandbox` in dune language. These let the user control the level of
sandboxing done by dune per rule and globally. The rule specification takes precedence.
The global configuration merely specifies the default.
The global configuration merely specifies the default.
(#2213, @aalekseyev, @jdimino)

- 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 a36e408

Please sign in to comment.