Skip to content

[P3] Documentation: Add JSDoc comments to public APIs #18

Description

@Pamacea

Priority

P3 - Low Priority

Category

Documentation

Description

Public API functions lack JSDoc comments, making auto-completion less helpful and code harder to understand.

Example

Before

export async function createCharacter(data: CharacterInput) {
  // What parameters does it accept?
  // What does it return?
  // What errors can it throw?
}

After

/**
 * Create a new character in a game world.
 *
 * @param data - Character creation data
 * @param data.name - Character name (1-200 characters)
 * @param data.gameWorldId - ID of the world to add character to
 * @param data.characterType - Type of character (PLAYER, NPC, etc.)
 * @returns Result object with created character or error
 * @throws {ValidationError} If input validation fails
 * @throws {AuthorizationError} If user lacks permission
 *
 * @example
 * ```typescript
 * const result = await createCharacter({
 *   name: 'Gandalf',
 *   gameWorldId: 'world-123',
 *   characterType: 'NPC',
 * });
 *
 * if (result.success) {
 *   console.log('Created:', result.data);
 * }
 * ```
 */
export async function createCharacter(
  data: CharacterInput
): Promise<Result<Character>> {
  // ...
}

Implementation Checklist

  • Add JSDoc to all Server Actions
  • Add JSDoc to exported hooks
  • Add JSDoc to utility functions
  • Add usage examples
  • Document error types
  • Add @example blocks

Success Criteria

  • All public APIs have JSDoc comments
  • All parameters documented
  • All return types documented
  • All error cases documented
  • IDE autocomplete shows helpful descriptions

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationp3Priority: Low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions