Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc extracted signature of variant with inline-record incomplete? #887

Closed
woeps opened this issue Jan 8, 2024 · 2 comments · Fixed by #889
Closed

doc extracted signature of variant with inline-record incomplete? #887

woeps opened this issue Jan 8, 2024 · 2 comments · Fixed by #889

Comments

@woeps
Copy link
Contributor

woeps commented Jan 8, 2024

Given the following rescript code:

type status =
    | /** If this is started or not */ Started(t) | /** Stopped? */ Stopped | /** Now idle.*/ Idle

is supposed to be extracted as the following (partial) json:

 {
      "id": "DocExtractionRes.SomeInnerModule.status",
      "kind": "type",
      "name": "status",
      "signature": "type status = Started(t) | Stopped | Idle",
      "docstrings": [],
      "detail": 
      {
        "kind": "variant",
        "items": [
        {
          "name": "Started",
          "docstrings": ["If this is started or not"],
          "signature": "Started(t)"        <-- HERE
        }, 
        {
          "name": "Stopped",
          "docstrings": ["Stopped?"],
          "signature": "Stopped"
        }, 
        {
          "name": "Idle",
          "docstrings": ["Now idle."],
          "signature": "Idle"
        }]
      }
    }, 

Especially mind the Started constructor having it's payload present in the json details' signature field!

Whereas it seems that the payload is not exported into it's json signature field, if it is an inline-record:
e.g. the following code:

type someVariantWithInlineRecords = | /** This has inline records...*/ SomeStuff({offline: bool})

is currently tested to result in the following (partial) json:

  {
      "id": "DocExtractionRes.AnotherModule.someVariantWithInlineRecords",
      "kind": "type",
      "name": "someVariantWithInlineRecords",
      "signature": "type someVariantWithInlineRecords =\\n  | SomeStuff({offline: bool})",
      "docstrings": ["Trying how it looks with an inline record in a variant."],
      "detail": 
      {
        "kind": "variant",
        "items": [
        {
          "name": "SomeStuff",
          "docstrings": ["This has inline records..."],
          "signature": "SomeStuff"        <-- HERE
        }]
      }
    }, 

Even though the SomeStuff Variant Constructor has a payload, it is not reflected in the extracted details contents.

I woult at least expect the detail item json to be:

{
  "name": "SomeStuff",
  "docstrings": ["This has inline records..."],
  "signature": "SomeStuff({offline: bool})"        <-- HERE
}

Is this a bug or a technical limitation?

edit:
Ideally, the docs of the inline-record would get extracted as well, by the same rules a "normal record" would be.

@zth
Copy link
Collaborator

zth commented Jan 8, 2024

Bug most likely, not a technical limitation.

@zth
Copy link
Collaborator

zth commented Jan 9, 2024

@woeps #889 this should fix it.

@zth zth closed this as completed in #889 Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants