rescript-lang / rescript-vscode

Official VSCode plugin for ReScript
MIT License
327 stars 55 forks source link

docgen should name module type for explicitly annotated module type #1010

Closed woeps closed 2 months ago

woeps commented 3 months ago

Once #1009 is implemented, I think we should include the annotated module type in the generated json:

// Example.res
module type MT = {
  let x: int
}

module M: MT = {
  let x = 42
}

should generate

{
  "name": "Example",
  "docstrings": [],
  "source": {
    "filepath": "src/Example.res",
    "line": 1,
    "col": 1
  },
  "items": [
  {
    "id": "Example.MT",
    "name": "MT",
    "kind": "moduleType",
    "docstrings": [],
    "source": {
      "filepath": "src/Example.res",
      "line": 1,
      "col": 13
    },
    "items": [
    {
      "id": "Example.MT.x",
      "kind": "value",
      "name": "x",
      "signature": "let x: int",
      "docstrings": [],
      "source": {
        "filepath": "src/Example.res",
        "line": 2,
        "col": 3
      }
    }]
  }, 
  {
    "id": "Example.M",
    "name": "M",
    "kind": "module",
    "moduleType": "Example.MT"  <-- this is new!
    "docstrings": [],
    "source": {
      "filepath": "src/Example.res",
      "line": 5,
      "col": 8
    },
    "items": [
    {
      "id": "Example.M.x",
      "kind": "value",
      "name": "x",
      "signature": "let x: int",
      "docstrings": [],
      "source": {
        "filepath": "src/Example.res",
        "line": 6,
        "col": 7
      }
    }]
  }]
}

Note in the above example, a moduleType field got added and id of the annotated module type was used as a value.

aspeddro commented 2 months ago

I was unsure if I should add this.

aspeddro commented 2 months ago

See https://github.com/rescript-lang/rescript-vscode/pull/1019

woeps commented 2 months ago

implemented in #1019