angulartypescriptdocumentation-generationcompodoc

How to properly document interface properties in compodoc + angular2


I've started using compodoc to document my app and I'm struggling to get clean code whilst commented to document openWeather api interface.

I've tried the common @property JSDoc marker but it doesn't work with compodoc, so to make it work as expected, I need to write something like this

/**
 * Weather information
 */
interface CityWeather {
  /**
   * Weather condition id
   */
  id: number;

  /**
   * Group of weather parameters (Rain, Snow, Extreme etc.)
   */
  main: string;

  /**
   * Weather condition within the group
   */
  description: string;

  /**
   * Weather icon id
   */
  icon: string;
}

I'd like to have the comments only on the start of the code and not above each property, like the old JSDoc @property {type} [name] Something like below is even possible? Or maybe a cleaner way than above?

/**
 * Weather information
 *
 * @property id Weather condition id
 * @property main Group of weather parameters (Rain, Snow, Extreme etc.)
 * @property description Weather condition within the group
 * @property icon Weather icon id
 */
interface CityWeather {
  id: number;
  main: string;
  description: string;
  icon: string;
}

Small Edit on my side

There is no need for a line break on the comments, you can have everything inside a one-line /** */, like this:

/** Weather information */
export interface CityWeather {
  /** Weather condition id */
  id: number;

  /** Group of weather parameters (Rain, Snow, Extreme etc.) */
  main: string;

  /** Weather condition within the group */
  description: string;

  /** Weather icon id */
  icon: string;
}

Solution

  • This is currently not supported, but a feature request has been made in the compodoc github issues.