knitwork icon indicating copy to clipboard operation
knitwork copied to clipboard

Support jsdoc comments for interface fields

Open blasdfaa opened this issue 1 year ago • 0 comments

Describe the feature

Add support for jsdoc comments in the genInterface function to improve documentation of generated ts interfaces

console.log(genInterface(
  'User',
  {
    id: {
      type: 'string',
      jsdoc: 'Unique identifier for the user',
    },
    email: {
      type: 'string',
      jsdoc: {
        description: 'User email address',
        example: '[email protected]',
      },
    },
    password: 'string',
  },
  {
    jsdoc: {
      description: 'Represents a user in the system',
      since: '1.0.0',
    },
  },
))

Output

/**
 * Represents a user in the system
 * @since 1.0.0
 */
interface User {
  /** Unique identifier for the user */
  id: string;
  /**
   * User email address
   * @example [email protected]
   */
  email: string;
  password: string;
}

Additional information

  • [x] Would you be willing to help implement this feature?

blasdfaa avatar Mar 16 '25 03:03 blasdfaa