Skip to content

handling of module types (in doc extraction) #902

Closed
@woeps

Description

@woeps

Currently, it seems to me there is no distinction made between a module and a module type in doc extraction (I believe, this is true for the LSP as well?). The extracted docs (json) gives no hint, that it's a module type and not an actual implementation.

Furthermore, any implementing module explicitly annotated with the module type is being ignored in doc extraction:

The following rescript code:

// ModuleType.res

/***
extracted docs don't give a hint, that Example is not an implementation, but a module type

module M is missing in extracted docs
*/

module type Example = {
  /***
  this is an example module type 
  */

  /**
  main type of this module 
  */
  type t

  /**
  function from t to t
  */
  let f: t => t
}

module M: Example = {
  /***
  implementation of Example module type
  */

  /**
  main type 
  */
  type t = int

  /**
  identity function
  */
  let f = (x: int) => x
}

produces this json:

{
  "name": "ModuleType",
  "docstrings": ["extracted docs don't give a hint, that Example is not an implementation, but a module type\n\nmodule M is missing in extracted docs"],
  "items": [
  {
    "id": "ModuleType.Example",
    "name": "Example",
    "kind": "module",
    "docstrings": [],
    "items": [
    {
      "id": "ModuleType.Example.t",
      "kind": "type",
      "name": "t",
      "signature": "type t",
      "docstrings": ["main type of this module"]
    }, 
    {
      "id": "ModuleType.Example.f",
      "kind": "value",
      "name": "f",
      "signature": "let f: (. t) => t",
      "docstrings": ["function from t to t"]
    }]
  }]
}

I'm honestly not sure how I'd expect it to be represented in the extracted json. (kind currently being one of Value, Type, Module)

  1. I believe the minimal requirement is to distinguish an actual module implementation from a module type, since I won't be able to actually call the lather one. [addressed in distinguish regular modules from module types #925]
  2. Any (Sub-) Module (not hidden by a *.resi file) should be present in the docs.
  3. There is no autocompletion help by the LSP to help with annotating the module type with a module type being a submodule in the same file. (The LSP helps annotating the module type, when the module type from another file is used.)
  4. The LSP doesn't distinguish between module and module type as well:
    Typing let x = ModuleType.Example., LSP offers completion for ModuleType.Example.f. - Which is just defined in the module type. Therefore this will yield a compilation error. [addressed in distinguish regular modules from module types #925]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions