Skip to content

Commit

Permalink
When generating a hidden module, mention why it is empty.
Browse files Browse the repository at this point in the history
Signed-off-by: Paul-Elliot <peada@free.fr>
  • Loading branch information
panglesd committed Jan 17, 2024
1 parent 4011e9d commit 0e67109
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 31 additions & 1 deletion src/odoc/odoc_link.ml
Expand Up @@ -4,14 +4,44 @@ let link_page ~resolver ~filename page =
let env = Resolver.build_env_for_page resolver page in
Odoc_xref2.Link.resolve_page ~filename env page

let content_for_hidden_modules =
let open Odoc_model in
let open Lang.Signature in
let with_loc v =
let open Location_ in
{
location =
{
file = "_none_";
start = { line = 1; column = 0 };
end_ = { line = 1; column = 0 };
};
value = v;
}
in
let sentence =
[
`Word "This";
`Space;
`Word "module";
`Space;
`Word "is";
`Space;
`Word "hidden.";
]
in
[ Comment (`Docs [ with_loc @@ `Paragraph (List.map with_loc sentence) ]) ]

let link_unit ~resolver ~filename m =
let open Odoc_model in
let open Lang.Compilation_unit in
let m =
if Root.Odoc_file.hidden m.root.file then
{
m with
content = Module { items = []; compiled = false; doc = [] };
content =
Module
{ items = content_for_hidden_modules; compiled = false; doc = [] };
expansion = None;
}
else m
Expand Down
2 changes: 1 addition & 1 deletion test/xref2/module_preamble.t/run.t
Expand Up @@ -122,6 +122,6 @@ and that "hidden" modules (eg. `A__b`, rendered to `html/A__b`) are not rendered
</nav>
<header class="odoc-preamble">
<h1>Module <code><span>A__b</span></code></h1>
</header><div class="odoc-content"></div>
</header><div class="odoc-content"><p>This module is hidden.</p></div>
</body>
</html>

0 comments on commit 0e67109

Please sign in to comment.