Skip to content

Non-option lists are misread as options in parseList #321

Closed
@avivkeller

Description

@avivkeller

Take a look at this snippet from https://github.com/nodejs/node/blob/main/doc/api/test.md:

* `count` {number} The number of assertions and subtests that are expected to run.
* `options` {Object} Additional options for the plan.
  * `wait` {boolean|number} The wait time for the plan:
    * If `true`, the plan waits indefinitely for all assertions and subtests to run.
    * If `false`, the plan performs an immediate check after the test function completes,
      without waiting for any pending assertions or subtests.
      Any assertions or subtests that complete after this check will not be counted towards the plan.
    * If a number, it specifies the maximum wait time in milliseconds
      before timing out while waiting for expected assertions and subtests to be matched.
      If the timeout is reached, the test will fail.
      **Default:** `false`.

In both the nodejs/node generator, and the legacy-json generator, the following is parsed to1:

{
  "textRaw": "`options` {Object} Additional options for the plan.",
  "name": "options",
  "type": "Object",
  "desc": "Additional options for the plan.",
  "options": [
    {
      "textRaw": "`wait` {boolean|number} The wait time for the plan:",
      "name": "wait",
      "type": "boolean|number",
      "desc": "The wait time for the plan:",
      "options": [
        {
          "textRaw": "If `true`, the plan waits indefinitely for all assertions and subtests to run.",
          "name": "If",
          "desc": "`true`, the plan waits indefinitely for all assertions and subtests to run."
        },
        {
          "textRaw": "If `false`, the plan performs an immediate check after the test function completes, without waiting for any pending assertions or subtests. Any assertions or subtests that complete after this check will not be counted towards the plan.",
          "name": "If",
          "desc": "`false`, the plan performs an immediate check after the test function completes, without waiting for any pending assertions or subtests. Any assertions or subtests that complete after this check will not be counted towards the plan."
        },
        {
          "textRaw": "If a number, it specifies the maximum wait time in milliseconds before timing out while waiting for expected assertions and subtests to be matched. If the timeout is reached, the test will fail. **Default:** `false`.",
          "name": "If",
          "default": "`false`",
          "desc": "a number, it specifies the maximum wait time in milliseconds before timing out while waiting for expected assertions and subtests to be matched. If the timeout is reached, the test will fail."
        }
      ]
    }
  ]
}

As you can see, the If ... lines are incorrectly treated as sub-options.

Footnotes

  1. With whatever little differences between the generators

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