Skip to content

extracted docs of types include escaped linebreaks in signature #888

Closed
@woeps

Description

@woeps

This rescript code:

type variant = FirstButVeryLongAndMeaninglessVariantConstructor

type t = {thisIsSomeReallyLongFieldWhichIsJustHereForDemonstration: bool}

gets extracted as:

{
  "name": "MinimalExample",
  "docstrings": [],
  "items": [
  {
    "id": "MinimalExample.variant",
    "kind": "type",
    "name": "variant",
    "signature": "type variant =\\n  | FirstButVeryLongAndMeaninglessVariantConstructor", <-- HERE
    "docstrings": [],
    "detail": 
    {
      "kind": "variant",
      "items": [
      {
        "name": "FirstButVeryLongAndMeaninglessVariantConstructor",
        "docstrings": [],
        "signature": "FirstButVeryLongAndMeaninglessVariantConstructor"
      }]
    }
  }, 
  {
    "id": "MinimalExample.t",
    "kind": "type",
    "name": "t",
    "signature": "type t = {\\n  thisIsSomeReallyLongFieldWhichIsJustHereForDemonstration: bool,\\n}", <-- HERE
    "docstrings": [],
    "detail": 
    {
      "kind": "record",
      "items": [{
        "name": "thisIsSomeReallyLongFieldWhichIsJustHereForDemonstration",
        "optional": false,
        "docstrings": [],
        "signature": "bool"
      }]
    }
  }]
}

Note the escaped linebreaks (\\n) in the signature.
This seems to happen, if a signature reaches some minimal length.

I would expect the line breaks to not be escaped.

edit:
I believe, this is due to calling Json.escape.

Not sure, what's best. But I guess, it's ether not escaping those special characters or "unescaping" them, when actually parsing the json in Tools_DocGen.res?

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