Skip to content

fix(html): render @param docs for rest parameters#809

Open
crowlbot wants to merge 1 commit into
mainfrom
fix-rest-param-jsdoc-574
Open

fix(html): render @param docs for rest parameters#809
crowlbot wants to merge 1 commit into
mainfrom
fix-rest-param-jsdoc-574

Conversation

@crowlbot

@crowlbot crowlbot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

@param documentation was not rendered for rest/spread parameters in the HTML output (issue #574). Given:

/**
 * @param first the leading number
 * @param rest the trailing numbers
 */
export function sum(first: number, ...rest: number[]): number { /* … */ }

the doc for first rendered, but the doc for rest was silently dropped.

Cause

When matching @param tags to parameters, function.rs keyed the lookup on the rendered parameter name. For a rest parameter, param_name() produces a ...-prefixed name (...rest), while the JSDoc @param tag name is the bare identifier (rest). The keys never matched, so the description, default and optional flag were all lost for rest parameters.

Fix

Strip the leading ... from the parameter name before looking up its @param doc. Regular parameters are unaffected (their names have no leading dots).

Test

Added html_rest_param_jsdoc to tests/html_test.rs, which fails before the change and passes after. The existing diff_comprehensive snapshots also pick up the now-rendered doc for a ...middlewares rest parameter, confirming the fix end-to-end.

Fixes #574

The rendered name of a rest parameter carries a `...` prefix (e.g.
`...rest`), but JSDoc `@param` tag names are bare identifiers. The
parameter-doc lookup keyed off the rendered name, so rest parameters
never matched their `@param` tag and their documentation was dropped.

Strip the leading `...` when looking up the doc so rest parameters
render their description, default and optional flag like any other
parameter.
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@crowlKats

Copy link
Copy Markdown
Member

@crowlbot this isnt accurate, as there could be destructuring

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@param jsdoc doesnt render for parameters that dont have a name-only definition

3 participants