Skip to content

Commit

Permalink
Add JSDoc tag @preserve to classes and public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Jul 14, 2023
1 parent 6a87036 commit 24aa656
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/contributing/coding-standards/js.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ component
```mjs
/**
* Component name
*
* @preserve
*/
export class Example {
/**
* @preserve
* @param {Element} $module - HTML element to use for component
*/
constructor ($module) {
Expand All @@ -32,6 +35,8 @@ export class Example {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { I18n } from '../../i18n.mjs'
*
* The state of each section is saved to the DOM via the `aria-expanded`
* attribute, which also provides accessibility.
*
* @preserve
*/
export class Accordion {
/** @private */
Expand Down Expand Up @@ -109,6 +111,7 @@ export class Accordion {
$showAllText = null

/**
* @preserve
* @param {Element} $module - HTML element to use for accordion
* @param {AccordionConfig} [config] - Accordion config
*/
Expand Down Expand Up @@ -138,6 +141,8 @@ export class Accordion {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const DEBOUNCE_TIMEOUT_IN_SECONDS = 1

/**
* JavaScript enhancements for the Button component
*
* @preserve
*/
export class Button {
/** @private */
Expand All @@ -24,7 +26,7 @@ export class Button {
debounceFormSubmitTimer = null

/**
*
* @preserve
* @param {Element} $module - HTML element to use for button
* @param {ButtonConfig} [config] - Button config
*/
Expand All @@ -44,6 +46,8 @@ export class Button {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { I18n } from '../../i18n.mjs'
*
* You can configure the message to only appear after a certain percentage
* of the available characters/words has been entered.
*
* @preserve
*/
export class CharacterCount {
/** @private */
Expand Down Expand Up @@ -60,6 +62,7 @@ export class CharacterCount {
maxLength = Infinity

/**
* @preserve
* @param {Element} $module - HTML element to use for character count
* @param {CharacterCountConfig} [config] - Character count config
*/
Expand Down Expand Up @@ -123,6 +126,8 @@ export class CharacterCount {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Checkboxes component
*
* @preserve
*/
export class Checkboxes {
/** @private */
Expand All @@ -9,6 +11,7 @@ export class Checkboxes {
$inputs

/**
* @preserve
* @param {Element} $module - HTML element to use for checkboxes
*/
constructor ($module) {
Expand Down Expand Up @@ -39,6 +42,8 @@ export class Checkboxes {
* We also need to restore the state of any conditional reveals on the page (for
* example if the user has navigated back), and set up event handlers to keep
* the reveal in sync with the checkbox state.
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { normaliseDataset } from '../../common/normalise-dataset.mjs'
* Error summary component
*
* Takes focus on initialisation for accessible announcement, unless disabled in configuration.
*
* @preserve
*/
export class ErrorSummary {
/** @private */
Expand All @@ -17,7 +19,7 @@ export class ErrorSummary {
config

/**
*
* @preserve
* @param {Element} $module - HTML element to use for error summary
* @param {ErrorSummaryConfig} [config] - Error summary config
*/
Expand All @@ -44,6 +46,8 @@ export class ErrorSummary {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { I18n } from '../../i18n.mjs'

/**
* Exit This Page component
*
* @preserve
*/
export class ExitThisPage {
/** @private */
Expand Down Expand Up @@ -71,6 +73,7 @@ export class ExitThisPage {
timeoutMessageId = null

/**
* @preserve
* @param {Element} $module - HTML element that wraps the Exit This Page button
* @param {ExitThisPageConfig} [config] - Exit This Page config
*/
Expand Down Expand Up @@ -102,6 +105,8 @@ export class ExitThisPage {

/**
* Initialise component
*
* @preserve
*/
init () {
this.buildIndicator()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Header component
*
* @preserve
*/
export class Header {
/** @private */
Expand Down Expand Up @@ -32,6 +34,7 @@ export class Header {
mql = null

/**
* @preserve
* @param {Element} $module - HTML element to use for header
*/
constructor ($module) {
Expand All @@ -53,6 +56,8 @@ export class Header {
* missing then there's nothing to do so return early.
* Apply a matchMedia for desktop which will trigger a state sync if the browser
* viewport moves between states.
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { normaliseDataset } from '../../common/normalise-dataset.mjs'

/**
* Notification Banner component
*
* @preserve
*/
export class NotificationBanner {
/** @private */
Expand All @@ -15,6 +17,7 @@ export class NotificationBanner {
config

/**
* @preserve
* @param {Element} $module - HTML element to use for notification banner
* @param {NotificationBannerConfig} [config] - Notification banner config
*/
Expand All @@ -34,6 +37,8 @@ export class NotificationBanner {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Radios component
*
* @preserve
*/
export class Radios {
/** @private */
Expand All @@ -9,6 +11,7 @@ export class Radios {
$inputs

/**
* @preserve
* @param {Element} $module - HTML element to use for radios
*/
constructor ($module) {
Expand Down Expand Up @@ -39,6 +42,8 @@ export class Radios {
* We also need to restore the state of any conditional reveals on the page (for
* example if the user has navigated back), and set up event handlers to keep
* the reveal in sync with the radio state.
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Skip link component
*
* @preserve
*/
export class SkipLink {
/** @private */
Expand All @@ -15,7 +17,7 @@ export class SkipLink {
linkedElementListener = false

/**
*
* @preserve
* @param {Element} $module - HTML element to use for skip link
*/
constructor ($module) {
Expand All @@ -28,6 +30,8 @@ export class SkipLink {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
5 changes: 5 additions & 0 deletions packages/govuk-frontend/src/govuk/components/tabs/tabs.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/**
* Tabs component
*
* @preserve
*/
export class Tabs {
/** @private */
Expand Down Expand Up @@ -33,6 +35,7 @@ export class Tabs {
mql = null

/**
* @preserve
* @param {Element} $module - HTML element to use for tabs
*/
constructor ($module) {
Expand All @@ -57,6 +60,8 @@ export class Tabs {

/**
* Initialise component
*
* @preserve
*/
init () {
// Check that required elements are present
Expand Down
2 changes: 2 additions & 0 deletions packages/govuk-frontend/src/govuk/i18n.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
* Internal support for selecting messages to render, with placeholder
* interpolation and locale-aware number formatting and pluralisation
*
* @preserve
* @private
*/
export class I18n {
translations
locale

/**
* @preserve
* @param {{ [key: string]: unknown }} translations - Key-value pairs of the translation strings to use.
* @param {object} [config] - Configuration options for the function.
* @param {string} [config.locale] - An overriding locale for the PluralRules functionality.
Expand Down

0 comments on commit 24aa656

Please sign in to comment.