Skip to content

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

@dbuenzli

Description

@dbuenzli

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions