Skip to content

Commit

Permalink
build: remove leading pipes in docs generation (#3155)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeripeierSBB authored Oct 17, 2024
1 parent d43f64c commit efd2e46
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 39 deletions.
8 changes: 4 additions & 4 deletions src/elements/card/card/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ To improve coloring, it's needed to manually define styles for Window high contr

## Properties

| Name | Attribute | Privacy | Type | Default | Description |
| ------- | --------- | ------- | --------------------------------------------------------------------------------------------- | --------- | -------------------------------------------------- |
| `color` | `color` | public | `\| 'white' \| 'milk' \| 'transparent-bordered' \| 'transparent-bordered-dashed'` | `'white'` | Option to set the component's background color. |
| `size` | `size` | public | `'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl' \| 'xxxl'` | `'m'` | Size variant, either xs, s, m, l, xl, xxl or xxxl. |
| Name | Attribute | Privacy | Type | Default | Description |
| ------- | --------- | ------- | ------------------------------------------------------------------------------ | --------- | -------------------------------------------------- |
| `color` | `color` | public | `'white' \| 'milk' \| 'transparent-bordered' \| 'transparent-bordered-dashed'` | `'white'` | Option to set the component's background color. |
| `size` | `size` | public | `'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl' \| 'xxxl'` | `'m'` | Size variant, either xs, s, m, l, xl, xxl or xxxl. |

## Slots

Expand Down
4 changes: 2 additions & 2 deletions src/elements/dialog/dialog-title/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ If a back button is displayed it emits a `requestBackAction` event on click.

| Name | Attribute | Privacy | Type | Default | Description |
| ------------------------- | --------------------------- | ------- | ---------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accessibilityBackLabel` | `accessibility-back-label` | public | `\| string \| undefined` | | This will be forwarded as aria-label to the back button element. |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `\| string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `accessibilityBackLabel` | `accessibility-back-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the back button element. |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `backButton` | `back-button` | public | `boolean` | `false` | Whether a back button is displayed next to the title. |
| `hideOnScroll` | `hide-on-scroll` | public | `Breakpoint \| boolean` | `false` | Whether to hide the title up to a certain breakpoint. |
| `level` | `level` | public | `SbbTitleLevel` | `'2'` | Title level |
Expand Down
40 changes: 20 additions & 20 deletions src/elements/image/readme.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/elements/navigation/navigation-section/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Similarly, if a navigation action is marked to indicate a selected option (e.g.,

| Name | Attribute | Privacy | Type | Default | Description |
| ------------------------ | -------------------------- | ------- | ------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------ |
| `accessibilityBackLabel` | `accessibility-back-label` | public | `\| string \| undefined` | | This will be forwarded as aria-label to the back button element. |
| `accessibilityBackLabel` | `accessibility-back-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the back button element. |
| `accessibilityLabel` | `accessibility-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the nav element and is read as a title of the navigation-section. |
| `titleContent` | `title-content` | public | `string \| undefined` | | The label to be shown before the action list. |
| `trigger` | `trigger` | public | `string \| HTMLElement \| null` | `null` | The element that will trigger the navigation section. Accepts both a string (id of an element) or an HTML element. |
Expand Down
2 changes: 1 addition & 1 deletion src/elements/navigation/navigation/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Similarly, if a navigation action is marked to indicate a selected option (e.g.,

| Name | Attribute | Privacy | Type | Default | Description |
| ------------------------- | --------------------------- | ------- | ------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `\| string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `activeNavigationSection` | - | public | `HTMLElement \| null` | `null` | |
| `isOpen` | - | public | `boolean` | | Whether the element is open. |
| `trigger` | `trigger` | public | `string \| HTMLElement \| null` | `null` | The element that will trigger the navigation. Accepts both a string (id of an element) or an HTML element. |
Expand Down
18 changes: 9 additions & 9 deletions src/elements/overlay/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ When using a button to trigger the overlay, ensure to manage the appropriate ARI

## Properties

| Name | Attribute | Privacy | Type | Default | Description |
| ------------------------- | --------------------------- | ------- | ---------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
| `accessibilityBackLabel` | `accessibility-back-label` | public | `\| string \| undefined` | | This will be forwarded as aria-label to the back button element. |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `\| string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `accessibilityLabel` | `accessibility-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the relevant nested element to describe the purpose of the overlay. |
| `backButton` | `back-button` | public | `boolean` | `false` | Whether a back button is displayed next to the title. |
| `expanded` | `expanded` | public | `boolean` | `false` | Whether to allow the overlay content to stretch to full width. By default, the content has the appropriate page size. |
| `isOpen` | - | public | `boolean` | | Whether the element is open. |
| `negative` | `negative` | public | `boolean` | `false` | Negative coloring variant flag. |
| Name | Attribute | Privacy | Type | Default | Description |
| ------------------------- | --------------------------- | ------- | --------------------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
| `accessibilityBackLabel` | `accessibility-back-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the back button element. |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `accessibilityLabel` | `accessibility-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the relevant nested element to describe the purpose of the overlay. |
| `backButton` | `back-button` | public | `boolean` | `false` | Whether a back button is displayed next to the title. |
| `expanded` | `expanded` | public | `boolean` | `false` | Whether to allow the overlay content to stretch to full width. By default, the content has the appropriate page size. |
| `isOpen` | - | public | `boolean` | | Whether the element is open. |
| `negative` | `negative` | public | `boolean` | `false` | Negative coloring variant flag. |

## Methods

Expand Down
2 changes: 1 addition & 1 deletion src/elements/popover/popover/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Overlays should always contain a heading level 2 title. It can be visually hidde

| Name | Attribute | Privacy | Type | Default | Description |
| ------------------------- | --------------------------- | ------- | ------------------------------------ | ------- | --------------------------------------------------------------------------------------------------------------- |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `\| string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `accessibilityCloseLabel` | `accessibility-close-label` | public | `string \| undefined` | | This will be forwarded as aria-label to the close button element. |
| `closeDelay` | `close-delay` | public | `number` | `0` | Close the popover after a certain delay. |
| `hideCloseButton` | `hide-close-button` | public | `boolean \| undefined` | `false` | Whether the close button should be hidden. |
| `hoverTrigger` | `hover-trigger` | public | `boolean` | `false` | Whether the popover should be triggered on hover. |
Expand Down
8 changes: 7 additions & 1 deletion tools/docs/docs_generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ function updateFieldsTable(
}

// Create a matrix 'table[row][column]' structure for the fields table
const fieldsSection = newDocs.original.substring(startIndex!, endIndex);
const fieldsSection = newDocs.original
.substring(startIndex!, endIndex)
// Remove leading pipes (prettier artifacts in ts files)
.replaceAll('`\\| ', '`')
// Remove doubled spaces (unwanted artifacts)
.replace(/ +/g, ' ');

const tableRows = Array.from(fieldsSection.matchAll(/^\|.*\|$/gm))
.map((match) => match[0])
.map((row) => row.split(/(?<!\\)\|/g)); // Split by not escaped '|'
Expand Down

0 comments on commit efd2e46

Please sign in to comment.