@hrefcl/apidoc - v4.0.5
    Preparing search index...
    • Converts a parsed TypeScript interface to APIDoc documentation elements

      Parameters

      • iface: ParsedInterface

        Parsed interface definition to convert

      • elementType: string = 'apiParam'

        Target APIDoc element type (default: 'apiParam')

      • Optionalgroup: string

        Optional group name for parameter organization

      Returns any[]

      Array of APIDoc elements ready for documentation generation

      This function transforms a parsed interface definition into an array of APIDoc elements (@apiParam, @apiSuccess, @apiError, etc.). It handles optional properties, group organization, and proper bracket notation for APIDoc formatting. Each interface property becomes a separate APIDoc element with appropriate type information and descriptions.

      const userInterface = {
      name: 'UserProfile',
      properties: [
      { name: 'id', type: 'Number', optional: false, description: 'User ID' },
      { name: 'email', type: 'String', optional: false, description: 'Email address' },
      { name: 'name', type: 'String', optional: true, description: 'Display name' }
      ]
      };

      const elements = interfaceToApiDocElements(userInterface);
      // Returns: [
      // { source: '@apiParam {Number} id User ID', name: 'apiparam', ... },
      // { source: '@apiParam {String} email Email address', name: 'apiparam', ... },
      // { source: '@apiParam {String} [name] Display name', name: 'apiparam', ... }
      // ]
      const responseInterface = {
      name: 'ApiResponse',
      properties: [
      { name: 'status', type: 'String', optional: false, description: 'Response status' },
      { name: 'data', type: 'Object', optional: true, description: 'Response data' }
      ]
      };

      const elements = interfaceToApiDocElements(responseInterface, 'apiSuccess', 'Response');
      // Returns: [
      // { source: '@apiSuccess (Response) {String} status Response status', ... },
      // { source: '@apiSuccess (Response) {Object} [data] Response data', ... }
      // ]
      const errorInterface = {
      name: 'ErrorResponse',
      properties: [
      { name: 'error', type: 'String', optional: false, description: 'Error message' },
      { name: 'code', type: 'Number', optional: false, description: 'Error code' }
      ]
      };

      const elements = interfaceToApiDocElements(errorInterface, 'apiError');
      // Returns error response documentation elements

      4.0.0