Skip to content

feat(#3159): add JSDocs to React and Angular component wrappers#3715

Open
bdfranck wants to merge 2 commits intodevfrom
benji/3159-add-jsdocs-to-wrappers
Open

feat(#3159): add JSDocs to React and Angular component wrappers#3715
bdfranck wants to merge 2 commits intodevfrom
benji/3159-add-jsdocs-to-wrappers

Conversation

@bdfranck
Copy link
Copy Markdown
Collaborator

@bdfranck bdfranck commented Mar 31, 2026

This PR adds JSDocs to our React and Angular wrappers. Changes include...

  1. Descriptions for components
  1. Descriptions for properties
  1. Descriptions for common types

Review feedback addressed

  • Changed all "Defines the..." JSDoc comments to "Sets the..." across Angular (badge.ts, input.ts, input-number.ts) and React (badge.tsx, modal.tsx, callout.tsx) wrappers
  • Updated testId comment in base.component.ts to "Sets the data-testid attribute for automated testing."
  • Added @required tag to the GoabFormItemSlot slot property comment in form-item-slot.ts

Before (the change)

JSDoc comments were missing from React and Angular wrapper components, and some existing comments used inconsistent phrasing ("Defines the..." instead of "Sets the...").

After (the change)

All React and Angular wrapper components, properties, and common types have JSDoc comments. Comments consistently use "Sets the..." phrasing, testId comments correctly reference data-testid, and required slot inputs are marked with @required.

Make sure that you've checked the boxes below before you submit the PR

  • I have read and followed the setup steps
  • I have created necessary unit tests
  • I have tested the functionality in both React and Angular.

Steps needed to test

Open a React or Angular project consuming @abgov/react-components or @abgov/angular-components and verify that hovering over component names and props in your IDE shows the updated JSDoc descriptions.

@bdfranck bdfranck linked an issue Mar 31, 2026 that may be closed by this pull request
@Spark450 Spark450 added the P1 Priority 1 (must have): Prevents product teams from adopting/using DS 2.0 as intended at launch. label Mar 31, 2026
@bdfranck bdfranck force-pushed the benji/3159-add-jsdocs-to-wrappers branch 2 times, most recently from d245d76 to ba51038 Compare April 1, 2026 21:58
Co-Authored-By: Copilot <198982749+Copilot@users.noreply.github.com>
@bdfranck bdfranck force-pushed the benji/3159-add-jsdocs-to-wrappers branch from ba51038 to 1813a47 Compare April 1, 2026 22:05
@bdfranck bdfranck requested a review from ArakTaiRoth April 1, 2026 22:15
@bdfranck bdfranck marked this pull request as ready for review April 1, 2026 22:16
@bdfranck bdfranck requested a review from vanessatran-ddi April 2, 2026 21:32
@Input() ml?: Spacing;
/** Sets the right margin spacing token. */
@Input() mr?: Spacing;
/** Sets the test id rendered on the underlying web component. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment should be Sets the data-testid attribute for automated testing. because the attribute we render is data-testid not test id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in b76d497: /** Sets the data-testid attribute for automated testing. */

* // similar to app-footer-meta-section & app-footer-nav-section
*/
export class GoabFormItemSlot {
/** Sets which form-item slot this content should render into. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have the @required in the comment?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added @required to the slot comment in b76d497: /** @required Sets which form-item slot this content should render into. */

private cdr = inject(ChangeDetectorRef);

/** Defines the context and colour of the badge. */
@Input() type?: GoabBadgeType;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should update type, content, icon, iconType to begins vs Sets the ... like the rest of some properties

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated type comment from "Defines the..." to "Sets the..." in b76d497. The content, icon, and iconType comments didn't use "Defines the..." so they were already consistent.

export class GoabBadge extends GoabBaseComponent implements OnInit {
private cdr = inject(ChangeDetectorRef);

/** Defines the context and colour of the badge. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked locally and the Docs site props table still shows the description and logic from Svelte web component *under extract-api.ts

Image

For example Badge has type not required but on the docs we have this:

Image

I think for this ticket we need to update the extract-api to make sure if we choose the language Angular we use the js docs from Angular, and React is from React js docs.
I think this is the scope of this ticket too ? cc @twjeffery and @Spark450 for the clarification. If we don't handle in this ticket, we will need another story to make sure we update the docs probs table according to React/Angular wrapper JS Docs comments.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanessatran-ddi I have a separate PR for updating the docs: #3754

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bdfranck Thank you.
@chrisolsen For the PR #3754 should we remove JS Docs comments on Svelte files too? Or we just leave those comments there.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vanessatran-ddi We have the "Web components" section in our new docs so we may as well keep them. I'll make sure #3754 includes the Web Components version.

@bdfranck
Copy link
Copy Markdown
Collaborator Author

bdfranck commented Apr 7, 2026

@copilot Make the following changes:

  • Change the comments from "Defines the..." with "Sets the..."
  • Change the testId comments to "Sets the data-testid attribute for automated testing."
  • Make the GoabFormItemSlot comment @required

- Change 'Defines the...' to 'Sets the...' in Angular and React wrappers
- Fix testId comment in base.component.ts to 'Sets the data-testid attribute for automated testing.'
- Add @required to GoabFormItemSlot slot comment

Agent-Logs-Url: https://github.com/GovAlta/ui-components/sessions/7e34d1c9-e70e-42de-8686-0ee52733ec88

Co-authored-by: bdfranck <1479091+bdfranck@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

@copilot Make the following changes:

  • Change the comments from "Defines the..." with "Sets the..."
  • Change the testId comments to "Sets the data-testid attribute for automated testing."
    ...

Done in b76d497:

  • Changed all "Defines the..." comments to "Sets the..." across Angular (badge.ts, input.ts, input-number.ts) and React (badge.tsx, modal.tsx, callout.tsx) wrappers
  • Updated testId comment in base.component.ts to "Sets the data-testid attribute for automated testing."
  • Added @required to the GoabFormItemSlot slot comment in form-item-slot.ts


/** Sets the context and colour of the badge. */
@Input() type?: GoabBadgeType;
/** Text label of the badge. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Sets the text label of the badge

// Ensure boolean input; attribute only set when true so default behaviour is false
/** @deprecated Use icontype instead. Includes an icon in the badge. */
@Input({ transform: booleanAttribute }) icon?: boolean;
/** Icon type to display in the badge. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Sets the icon type to display in the badge

@Input() size?: GoabBadgeSize = "medium";
/** Sets the visual emphasis. 'subtle' for less prominent, 'strong' for more emphasis. @default "strong" */
@Input() emphasis?: GoabBadgeEmphasis = "strong";
/** Accessible label for screen readers. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Sets the accessible label for screen readers

export class GoabBlock extends GoabBaseComponent implements OnInit {
private cdr = inject(ChangeDetectorRef);

/** Spacing between items. Uses design system spacing tokens. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should starts vs Sets the ...


/** Spacing between items. Uses design system spacing tokens. */
@Input() gap?: Spacing;
/** Stacking direction of child components. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should starts vs Sets the ...

@Input() gap?: Spacing;
/** Stacking direction of child components. */
@Input() direction?: GoabBlockDirection;
/** Primary axis alignment of child components. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should start vs Sets the ....


/** Sets the visual style of the button. Use "primary" for main actions, "secondary" for alternative actions, "tertiary" for low-emphasis actions, and "start" for prominent call-to-action buttons. @default "primary" */
@Input() type?: GoabButtonType = "primary";
/** Controls the size of the button. Use "compact" for inline actions or space-constrained layouts. @default "normal" */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should starts vs Sets the size...

@Input() size?: GoabButtonSize;
/** Sets the color variant for semantic meaning. Use "destructive" for delete or irreversible actions, "inverse" for dark backgrounds. @default "normal" */
@Input() variant?: GoabButtonVariant;
/** When true, prevents user interaction and applies disabled styling. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Sets the disabled state...

@Input() variant?: GoabButtonVariant;
/** When true, prevents user interaction and applies disabled styling. */
@Input({ transform: booleanAttribute }) disabled?: boolean;
/** Icon displayed before the button text. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Sets the icon displayed...

Copy link
Copy Markdown
Collaborator

@vanessatran-ddi vanessatran-ddi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see some properties in angular documented as Sets the ... while some are not. I checked this rule https://github.com/GovAlta/ui-components/blob/dev/CLAUDE.md?plain=1#L109 and looks like we should follow the rule starts vs Sets the .. pattern. However it is not a blocker for me.


export interface GoabAccordionProps extends Margins, DataAttributes {
/** @required Sets the heading text. */
heading: string;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heading is required in React but not in Angular, think we should make this heading optional in this React wrapper too

@Input({ required: true, transform: booleanAttribute }) open!: boolean;
/** @required The position of the drawer. */
@Input({ required: true }) position!: GoabDrawerPosition;
/** @required The heading text displayed at the top of the drawer. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heading is optional for both react and angular, so this comment @required is not correct

/** @required The name of the uploaded file to display. */
@Input({ required: true }) filename!: string;
/** The file size in bytes. Displayed in a human-readable format (KB, MB). */
@Input({ transform: numberAttribute }) size?: number;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size is a required attribute, so we miss it in Angular here, can you add required: true to the Input and update the comment

/** Sets the id attribute on the file upload input element. */
@Input() id?: string = "";
/** @required The input display variant. "dragdrop" shows a drag-and-drop area, "button" shows a simple button. */
@Input({ required: true }) variant!: GoabFileUploadInputVariant;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variant is set required in angular but not in React. Checking from Svelte, I think we can make this variant here optional

* The modal will always use role="dialog".
*/
@Input() role?: string;
/** @required The heading text displayed at the top of the modal. */
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this heading is not required so this JS doc @required is not correct

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

Labels

P1 Priority 1 (must have): Prevents product teams from adopting/using DS 2.0 as intended at launch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSDocs in Wrappers

5 participants