reasonml / reasonml/reason

[refmt] Module-level doc comment not respected

Open
#2,177 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Input

/** module-level docs */

open A;

Reformatted

/** module-level docs */
open A;

Expected Output

[@@ocaml.doc " module-level docs "]

open A

Actual Output due to Reformatting

open A[@@ocaml.doc " module-level docs "]

The removal of the space between the module-wide comment and the module open seems to make the compilation think the doc annotation is for the open rather than the module.

I'm struggling with this, and my current workaround is to include a top-level abstract type that will be displayed. This of course is undesirable.

Happy to jump into the reformatter code if I can get a few pointers 🙌

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the refmt formatting entry point and reproduce the issue using the Reason input shown. Compare its output with the expected OCaml annotation placement; done means the module-level documentation remains attached to the module rather than the following open.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.