JSDoc Best Practices for the Euchre Project
Defines five mandatory JSDoc patterns for documenting a layered card game project, with examples for pure functions and type imports.
What this file does
Defines five mandatory JSDoc patterns for documenting a layered card game project, with examples for pure functions and type imports.
When to use it
- Documenting pure Layer 1 functions that transform game state
- Creating reusable type definitions for complex objects
- Enforcing consistent JSDoc across a team or AI-assisted project
- Tracking references between related modules with @see
Assumes this stack
trigger: always_on description: When working with complex files.
JSDoc Best Practices for the Euchre Project
This ruleset outlines the mandatory JSDoc techniques for documenting the Euchre project. Proper documentation is critical for maintaining Layer 1 purity, enabling test-driven development with node:test, and ensuring clarity across the layered architecture. Consistent and detailed JSDoc provides a structured format that is easily understood by both developers and AI assistants, aligning with the project's development standards.
Table of Contents
- Basic Function Documentation (
@param,@returns) - Defining Complex Objects with In-Place
@typedef - Documenting Dependency Injection for Tests
- Creating Types from Constants (
@typedef,keyof typeof) - Mandatory Reference Tracking with
@see
1. Basic Function Documentation (@param, @returns)
This is the foundational technique for describing a function's contract. For this project, it's essential for documenting pure Layer 1 functions that operate on game state.
The Technique:
Use @param {type} name - Description for each parameter and @returns {type} - Description for the return value. All Layer 1 functions that transform state must document their inputs and outputs.
Example (Based on constants-import-usage-guide.md):
import {
GAME_PHASES,
PLAYER_POSITIONS,
CARD_VALUES,
CARD_SUITS,
TEAMS,
} from "@/config/constants";
/**
* @typedef {import('./jsdoc.md').GamePhase} GamePhase
* @typedef {import('./jsdoc.md').PlayerRole} PlayerRole
* @typedef {import('./jsdoc.md').Card} Card
* @typedef {import('./jsdoc.md').SuitConstant} SuitConstant
*/
/**
* Creates the initial state object for a new game. This is a pure function.
*
* @param {{ team: string }} player - The player object, containing their team.
* @returns {{phase: GamePhase, dealer: PlayerRole, cards: Card[], trump: SuitConstant}} A new state fragment.
*/
function setupInitialState(player) {
// Access the prefixed property from the imported `TEAMS` object.
if (player.team === TEAMS.TEAM_NS) {
// ... team logic
}
// Prefixed constants are explicit and unambiguous.
return {
phase: GAME_PHASES.GAME_PHASE_LOBBY,
dealer: PLAYER_POSITIONS.PLAYER_SOUTH,
cards: CARD_VALUES,
trump: CARD_SUITS.CARD_SUIT_HEARTS,
};
}
What's inside
5 sections covering @param/@returns, inline @typedef, dependency injection docs, keyof typeof, and @see tracking, with code examples
Change this for your project
- Replace
@/config/constantswith your own constants import path - Replace
'./jsdoc.md'type import paths with your actual file references - Replace game-specific constants like
GAME_PHASE_LOBBYandPLAYER_SOUTHwith your own
Where it goes
Save in docs/ or the repository root. Gives agents and new contributors a map of the codebase.
Worth borrowing
- Using
@typedefwithimport('./path')to reference types across files - Documenting dependency injection parameters for testability
- Creating types from constant objects with
keyof typeof
Related Documents
PCB Design Sources for Industry-Scale Testing
Lists GitHub repos and communities where you can download real PCB designs for testing optimization at scale.
Design Document: BharatSeva AI
Describes a 10-agent AWS system that helps India's informal workers access government schemes via voice-first, serverless architecture.
OpenClaw Enterprise Transformation Plan
Transforms a single-user AI agent into a dual-mode platform supporting both viral open-source and Fortune 500 enterprise deployments through phased security, IAM, audit, multi-tenancy, and Kubernetes features.
Qwen Image and Edit: Open-sourcing and Local GGUF Generations with Lightning
Documents the Qwen-Image and Qwen-Image-Edit models, covering architecture, training, benchmarks, ComfyUI setup, and prompting techniques for local GGUF deployment.