Skip to content

@param and @returns are overly sensitive to whitespace #1164

@ssokolow

Description

@ssokolow

Expected Behavior

@param and @returns should ignore up to two characters of leading whitespace between a * beginning a comment line and an @ beginning a javadoc annotation.

(Or, at the bare minimum, there should be a boldface warning in the docs and some kind of lint so such a subtle typo can't slip in unnoticed.)

Actual Behavior

When I tried to use @param and @returns to document function signatures in interface declarations, I kept getting them passing through as literals.

I wound up utterly convinced that there was a bug in the aspect of the parser which dealt with what subset of javadoc comments were supported and it was only while minimizing the testcase to report it here that I realized it wasn't actually a case of "@param and @returns are broken inside interface definitions" but rather the leading space I'd added so they visually lined up with the text on the /** line.

Steps to reproduce the bug

  1. Install TypeDoc on top of Using TypeScript 3.7.4 (what I got when I asked npm for the latest versions)
  2. Put the following in test.ts in an empty folder:
interface TestInterface {
  /** Function description
   *
   *  @param scope Test description.
   *  @returns Test description.
   */
  testFunc(scope: string): boolean;
}
  1. Run rm -rf docs; typedoc --out docs test.ts with the working directory set to the folder containing test.ts.

Backspacing away one character of whitespace before each @ will result in it working, but you have to know to do that and it's easy for it to slip back in if something like Vim is handling indentation and line-wrapping within comments.

Environment

  • Typedoc version: 0.16.1
  • Node.js version: v8.16.0
  • OS: Kbuntu 16.04.6 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions