AshTypescript.Rpc.Codegen.FunctionGenerators.JsdocGenerator (ash_typescript v0.17.3)

Copy Markdown View Source

Generates JSDoc comments for RPC functions.

Provides IDE discoverability by adding documentation with metadata tags that describe the action type, resource, internal action name, and namespace.

Summary

Functions

Generates a JSDoc comment for an RPC function.

Generates a JSDoc comment for a typed query.

Generates a JSDoc comment for a validation function.

Functions

generate_jsdoc(resource, action, rpc_action, opts \\ [])

Generates a JSDoc comment for an RPC function.

Parameters

  • resource - The Ash resource module
  • action - The Ash action struct
  • rpc_action - The RPC action configuration
  • opts - Options including:
    • :namespace - The resolved namespace for this action (optional)

Returns

A string containing the JSDoc comment block.

Example Output

Default (relative paths):

/**
 * List all users
 *
 * @ashActionType :read
 * @ashResource MyApp.User
 * @ashAction :list
 * @ashActionDef lib/my_app/resources/user.ex
 * @rpcActionDef lib/my_app/domain.ex
 * @namespace users
 * @see createUser
 * @deprecated Use listUsersV2 instead
 */

With :source_path_prefix set to "backend" (for monorepos):

/**
 * List all users
 *
 * @ashActionType :read
 * @ashResource MyApp.User
 * @ashAction :list
 * @ashActionDef backend/lib/my_app/resources/user.ex
 * @rpcActionDef backend/lib/my_app/domain.ex
 * @namespace users
 * @see createUser
 * @deprecated Use listUsersV2 instead
 */

generate_typed_query_jsdoc(typed_query, resource)

Generates a JSDoc comment for a typed query.

Parameters

  • typed_query - The typed query configuration
  • resource - The Ash resource module

Returns

A string containing the JSDoc comment block.

generate_validation_jsdoc(resource, action, rpc_action, opts \\ [])

Generates a JSDoc comment for a validation function.

Parameters

  • resource - The Ash resource module
  • action - The Ash action struct
  • rpc_action - The RPC action configuration
  • opts - Options including:
    • :namespace - The resolved namespace for this action (optional)

Returns

A string containing the JSDoc comment block.