JSDoc for Class Methods

Generate JSDoc comments for class methods including static methods, getters, setters, and async methods. Covers @memberof and @static tags.

Classes

Detailed Explanation

Documenting Class Methods

Class methods are documented similarly to functions but with additional context about the class they belong to and their visibility (public, private, protected).

Example Signature

class UserService {
  async findByEmail(email: string): Promise<User | null>

  static fromConfig(config: ServiceConfig): UserService
}

Generated JSDoc

/**
 * Finds a user by their email address.
 *
 * @param {string} email - The email address to search for (case-insensitive).
 * @returns {Promise<User | null>} The user if found, or null if no
 *   user exists with that email.
 * @throws {ValidationError} If the email format is invalid.
 *
 * @memberof UserService
 *
 * @example
 * ```typescript
 * const user = await service.findByEmail("alice@example.com");
 * if (user) {
 *   console.log(user.name);
 * }
 * ```
 */

Static Methods

Static methods use the @static tag:

/**
 * Creates a UserService from a configuration object.
 *
 * @static
 * @param {ServiceConfig} config - The service configuration.
 * @returns {UserService} A configured UserService instance.
 */

Getters and Setters

Document getters with @returns and setters with @param:

/**
 * Gets the user's full name.
 * @returns {string} First and last name joined by a space.
 */
get fullName(): string

/**
 * Sets the user's display name.
 * @param {string} value - The new display name (max 50 characters).
 */
set displayName(value: string)

Visibility Tags

Tag Meaning
@public Visible in public API (default)
@protected Accessible to subclasses only
@private Internal to the class
@internal (TSDoc) Not part of the public API

Use Case

Documenting service layer methods, repository patterns, controller actions, and any class-based architecture where methods form a public API consumed by other modules.

Try It — JSDoc / TSDoc Generator

Open full tool