Skip to content

Provide a way to hide code blocks in .mld files #1331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dbuenzli opened this issue Mar 18, 2025 · 2 comments
Open

Provide a way to hide code blocks in .mld files #1331

dbuenzli opened this issue Mar 18, 2025 · 2 comments
Labels
enhancement New feature or request output

Comments

@dbuenzli
Copy link
Contributor

dbuenzli commented Mar 18, 2025

With new features comes new wishes :–)

When you do code extraction you sometimes have setup code (e.g. a license header) that you'd like to hide in the rendering. With mli files you can simply use a stop comment but in .mld files there is no such thing, everything gets rendered, as noticed in #998.

I think we should standardize an info string tag, e.g. @hidden which should work regardless of whether we are processing .mld file or a cmti one and that removes the tagged code block from the rendering.

So for example I can have:

{@ocaml @hidden name=header[
(*---------------------------------------------------------------------------
   Copyright (c) 2011 The cmdliner programmers. All rights reserved.
   SPDX-License-Identifier: CC0-1.0
  ---------------------------------------------------------------------------*)
]}

And then:

{@ocaml name=example1.ml[
…
|}

{@ocaml name=example2.ml[
…
|}

And extract the examples as

 odoc extract-code --name header --name example1.ml
 odoc extract-code --name header --name example2.ml
@dbuenzli dbuenzli added enhancement New feature or request output labels Mar 18, 2025
@jonludlam
Copy link
Member

Yes, this is a good idea. I'm not sure whether we should go with @hidden or just hidden - I can see why using the same string as the tag is nice, It'll look a bit odd if other atoms/bindings don't also start with an '@', and that seems unnecessary.

@dbuenzli
Copy link
Contributor Author

dbuenzli commented Mar 20, 2025

I'm not sure whether we should go with @hidden or just hidden

Neither I am :–) Initially I was more leaning towards @-less. But arguments in favour are that it gives a strong hint that this will be interpreted by odoc rendering and that such a tag could be introduced in the ocamldoc language in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request output
Projects
None yet
Development

No branches or pull requests

2 participants