reasonml / reasonml/reason

Parse markdown comments *into* ocamldoc.

Open
#2,391 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Problem We want all the tooling to support markdown comments for Reason modules.
This includes merlin, odoc, and reason-vscode and any others.

  • Here's for odoc.

Approach one: Have each tool support markdown (merlin, odoc) for Reason syntax. This issue explores doing so in odoc.
Approach two (this github issue): Explore parsing markdown comments into ocamldoc syntax on the way in.

Approach:

  • In the Reason parser, for each docblock comment (which is modeled as a ppx attribute) /**, on the way in into the AST, parse some subset of markdown, then convert it back into a string in the ocamldoc form. For example, if you've parsed SingleBacktickCode(str) - then in the AST store it as [str] which is the ocamldoc syntax. Do the same thing for links, and others. A large set of ocamldoc's features have no markdown equivalent and that's okay, we can still use those too. For example {!ModuleName} would just be perceived as plain text in markdown, it won't parse, but then all the other ocamldoc based tools will make sense of it.

  • Make sure the text is printed in refmt in its exact original form, not performing the substitutions.

  • Explore if approach two is the right one (poke holes in it).

  • Propose a mapping from markdown-light to ocamldoc syntax. (Comment on this task with your own ideas/observations).

  • Implement this in the parser.

  • Make sure the approach doesn't slow things down too much when compiling (heuristics like looking for any markdown token at the beginning of any newline or backtick throughout would work pretty well).

  • Make sure that markdown parsing failures never crash the parser.

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 by reviewing the Reason parser and refmt handling of docblock comments modeled as ppx attributes. First evaluate the proposed markdown-to-ocamldoc approach and define the supported mapping, including failure and performance behavior. Done means the approach is agreed, implemented in the parser, preserves original comments in refmt, and does not crash on markdown parsing failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
markdown, ocaml
Domain
compilers, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.