Skip to content

tsdoc links crossing multiple lines are mangled #1497

@TimothyJones

Description

@TimothyJones

Version: jsii@5.5.10 (via jsii-docgen@10.5.5)

Originally opened here

Summary

When using jsii-docgen in json mode, multi-line @link elements are mangled.

Description

I have some documentation like the following (note the multi-line tsdoc @link in the first line):

/**
 * Matches the content of a variable that comes from a state. See {@link https://case.contract-testing.io/docs/defining-contracts/state-definitions | state
 * definitions}
 * and {@link https://case.contract-testing.io/docs/reference/state-handlers | state handlers} for
 * more details.
 *
 * @public
 */
export class StateVariable extends AnyMatcher {
   /* ... */
}

The generated remarks section in the json doc is mangled - it assumed the first link finishes at the end of the first line, so the text link ends state} * definitions }.

Expected behaviour

The parsed link appears as:

See {@link https://case.contract-testing.io/docs/defining-contracts/state-definitions state definitions}

Actual behaviour

The link appears as

See {@link https://case.contract-testing.io/docs/defining-contracts/state-definitions state} * definitions}

Note that:

  • The link ends twice, once after state, and again after definitions
  • The * from the next line is erroneously included

Reproduction

I've created this repository illustrating this and another problem (about to be reported).

The relevant part for this issue is the parsing of this line:

/**
 * This class reproduces the bugs at {@link https://github.com/cdklabs/jsii-docgen/issues/1633 | this 
 * issue} 

Which results in this line in the assembly, which contains:

  {@link https://github.com/cdklabs/jsii-docgen/issues/1633 this } * issue} 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions