Skip to content

@inheritDoc is not copying parameter documentation #787

@kayahr

Description

@kayahr

When using @inheritDoc then only the method documentation is copied. Parameter documentation is not copied.

Versions:

  • TypeDoc v0.11.1
  • Node v10.4.0

Reproduction code:

// test.ts
interface Base {
    /**
     * Base doc.
     *
     * @param p  Param doc.
     * @return Return value doc.
     */
    method(p: number): string;
}

class Test implements Base {
    /** @inheritDoc */
    method(p: number): string {
        return "";
    }
}
$ typedoc --out doc test.ts

Expected behavior:

The parameter p of the Test class must be documented with the text Param doc.

Actual behavior:

Parameter p is not documented at all. Only the name and type is printed to the HTML output.

The reason for this can be found in ImplementsPlugin.copyComment. This method only copies the parameter documentation when the parameter is already documented on the target method. This isn't the case when the method is simply annotated with @inheritDoc. There must be at least a @param p comment so the parameter documentation gets copied from the interface.

This can easily be fixed by reversing the logic. When target parameter is not already documented then copy documentation from the interface. This fixes the issue and also allows to write a more specific documentation for the parameter in the class.

This can be fixed with a few lines of code. Maybe I'll come up with a PR soon.

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