Skip to main content

Documentation & DX

Mandatory TSDoc

Every exported function in Pithos must include a complete TSDoc comment block. This ensures consistent API documentation, enables IDE autocompletion hints, and powers the generated reference pages. Below is a full example showing all required tags for a typical utility function:

/**
* Splits an array into groups of specified size.
*
* @template T - The type of array elements.
* @param input - The array to split.
* @param size - The size of each group (must be > 0).
* @returns An array of arrays, each containing at most `size` elements.
* @throws {TypeError} If `input` is not an array.
* @throws {RangeError} If `size` <= 0.
* @since 1.1.0
*
* @example
* ```typescript
* chunk([1, 2, 3, 4, 5], 2)
* // → [[1, 2], [3, 4], [5]]
* ```
*
* @example
* ```typescript
* chunk(['a', 'b', 'c'], 3)
* // → [['a', 'b', 'c']]
* ```
*/

Required Elements

ElementRequiredDescription
DescriptioncheckmarkShort, clear, starts with a verb
@templatecheckmarkIf generics are used
@paramcheckmarkAll parameters
@returnscheckmarkReturn type and description
@throwscheckmarkIf can throw, document when and what
@sincecheckmarkIntroduction version
@examplecheckmarkAt least one working example
@deprecatedIf applicableWith @see pointing to replacement

Related