Skip to content

Commit

Permalink
fix(docs): better type for Array & typo
Browse files Browse the repository at this point in the history
  • Loading branch information
aesteves60 committed Oct 2, 2023
1 parent 144c697 commit a2c99a4
Show file tree
Hide file tree
Showing 45 changed files with 157 additions and 123 deletions.
36 changes: 26 additions & 10 deletions packages/common/core/src/utils/typedoc/typedoc-json-to-md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
IntrinsicType,
ReflectionType,
ReferenceType,
Type,
} from 'typedoc';

const tableSeparator = '|';
Expand Down Expand Up @@ -41,8 +42,9 @@ export function convertJsonToMarkdown(jsonItems: DeclarationReflection[]): strin
function getInterfaces(filteredJSON: DeclarationReflection[]): string[] {
const res: string[] = [];

filteredJSON.filter(({ kindString: filteredString, children: filteredChildren }) => filteredString === 'Interface'
&& typeof filteredChildren !== 'undefined').forEach(({ name, children }) => {
filteredJSON
.filter(({ kindString, children, indexSignature }) => kindString === 'Interface' && (!children || !indexSignature))
.forEach(({ name, children, indexSignature }) => {
res.push(`\n### ${name}`);

// Find default values
Expand All @@ -54,8 +56,18 @@ function getInterfaces(filteredJSON: DeclarationReflection[]): string[] {
defaultValues[name] = defaultValue?.toString() || '';
});

if (indexSignature) {
res.push(tableSeparator + ['Key', 'Type', 'Description'].join(` ${tableSeparator} `) + tableSeparator);
res.push(tableSeparator + ['---', ':---:', '---'].join(`${tableSeparator}`) + tableSeparator);
res.push(tableSeparator + [
printType(indexSignature.parameters?.[0]?.type),
printType(indexSignature.type),
indexSignature.comment?.shortText,
].join(` ${tableSeparator} `) + tableSeparator);
return;
}
res.push(
tableSeparator + ['name', 'Type', 'Required', 'Default', 'Description'].join(` ${tableSeparator} `) + tableSeparator
tableSeparator + ['Name', 'Type', 'Required', 'Default', 'Description'].join(` ${tableSeparator} `) + tableSeparator
);
res.push(
tableSeparator + ['---', '---', ':---:', '---', '---'].join(`${tableSeparator}`) + tableSeparator
Expand All @@ -70,6 +82,7 @@ function getInterfaces(filteredJSON: DeclarationReflection[]): string[] {
commentString.replace(/\n/g, '')
].join(` ${tableSeparator} `) + tableSeparator);
});
return;
});

return res;
Expand Down Expand Up @@ -112,7 +125,7 @@ function getClass(filteredJSON: DeclarationReflection[]): string[] {
const parameterSection: string[] = [];
if (parameters && parameters.length) {
parameterSection.push(`Name | Type | Description \n---|---|---`);
parameters?.map(({name: paramName, type: paramType, comment: paramComment }) => {
parameters?.map(({ name: paramName, type: paramType, comment: paramComment }) => {
params.push(`\`${paramName}\`: ${printType(paramType)}`);
parameterSection.push(`**${paramName}** | ${printType(paramType)} | ${paramComment?.shortText || ' '} |`);
});
Expand All @@ -129,15 +142,15 @@ function getClass(filteredJSON: DeclarationReflection[]): string[] {
return res;
}

function printType(typeObject?: SomeType | unknown) {
const getTypeValue = (tObj: SomeType | LiteralType | IntrinsicType) => {
function printType(typeObject?: SomeType | unknown): string {
const getTypeValue = (tObj: SomeType | LiteralType | IntrinsicType | Type) => {
if ('name' in tObj) {
return tObj.name.toString();
}
}
if ('value' in tObj) {
return tObj.value?.toString();
}
return tObj.type
}
return tObj.type;
};
const someType = typeObject as SomeType;
if (someType && someType.type) {
Expand All @@ -151,8 +164,11 @@ function printType(typeObject?: SomeType | unknown) {
}
return `\`${someType.name}\``;
}
case 'array':
return `${printType(someType.elementType).replace(/^(_|`)|(_|`)$/g, '')}[]`
case 'union':
return someType.types.map((tObj) => `\`${getTypeValue(tObj)}\``).join(' \\| ');
return someType.types.map((tObj) => `\`${printType(tObj).replace(/^(_|`)|(_|`)$/g, '')}\``).join(' \\| ')
;
}
}
return '_unknown_';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Interfaces

### OdsAccordionGroupMethod
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`registerAccordion`** | _void_ | ✴️ | | |
|**`unRegisterAccordion`** | _void_ | ✴️ | | |
Expand All @@ -17,9 +17,9 @@
Name | Type | Description
---|---|---
**accordion** | `OsdsAccordion` |
**accordion** | `OsdsAccordion` | |
> **unRegisterAccordion**(`accordion`: `OsdsAccordion`) => `Promise<void>`
Name | Type | Description
---|---|---
**accordion** | `OsdsAccordion` |
**accordion** | `OsdsAccordion` | |
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Interfaces

### OdsAccordionAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`color`** | `ODS_THEME_COLOR_INTENT` | | | main color: see component principles|
|**`contrasted`** | _boolean_ | | | contrasted or not: see component principles|
Expand All @@ -14,7 +14,7 @@
|**`size`** | `md` | | | size: see component principles|

### OdsAccordionEvent
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`odsAccordionToggle`** | `EventEmitter<boolean>` | ✴️ | | Event triggered on accordion toggle|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
## Interfaces

### OdsBreadcrumbAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`contrasted`** | _boolean_ | | | contrasted or not: see component principles|
|**`items`** | `string` \| `array` | ✴️ | | List of breadcrumb items to display|
|**`items`** | `string` \| `OdsBreadcrumbAttributeItem[]` | ✴️ | | List of breadcrumb items to display|

### OdsBreadcrumbAttributeItem
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`href`** | _string_ | ✴️ | | Item link to redirect to|
|**`icon`** | `ODS_ICON_NAME` | | | Icon to display|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Interfaces

### OdsButtonAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`circle`** | _boolean_ | | | use a circle shape|
|**`color`** | `ODS_THEME_COLOR_INTENT` | | | main color: see component principles|
Expand Down
22 changes: 11 additions & 11 deletions packages/components/cart/documentation/specifications/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Interfaces

### OdsCartAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`collapsed`** | _boolean_ | | | is the cart is collapsed (if collapsible)|
|**`collapsible`** | _boolean_ | | | is the cart can be collapsed in a smaller view|
Expand All @@ -14,45 +14,45 @@
|**`size`** | `sm` | | | size: see component principles|

### OdsCartHeaderAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`headerTitle`** | _string_ | | | |

### OdsCartHeaderMethod
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`refresh`** | _void_ | ✴️ | | Render manually the cart header in order to refresh the component.|

### OdsCartManagerAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`footer`** | `OdsCartManagerFooter` | | | describe what the footer is made of|
|**`i18n`** | `OdsI18nHook` | | | internationalisation system connector|
|**`inline`** | _boolean_ | | | full width or not: see component principles|
|**`period`** | `ODS_PERIOD_ISO_CODE` | | | ISO period code that describe the duration of a periodical payment|
|**`sections`** | _unknown_ | ✴️ | | Sections made of one item and multiple options|
|**`sections`** | OdsCartManagerSection[] | ✴️ | | Sections made of one item and multiple options|
|**`size`** | `sm` | | | size: see component principles|
|**`vatMode`** | _boolean_ | | | is the cart display the Value Added Tax|

### OdsCartManagerFooter
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`items`** | _unknown_ | ✴️ | | |
|**`items`** | OdsCartManagerFooterItem` \| `OdsCartManagerTotal[] | ✴️ | | |

### OdsCartManagerMethod
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`getProductQuantity`** | `Promise<number>` | ✴️ | | get the number of item flagged as product|
|**`getTotalAmount`** | `Promise<number>` | ✴️ | | get the total amount of the cart|

### OdsCartManagerSection
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`item`** | `OdsCartManagerItem` | ✴️ | | |
|**`options`** | _unknown_ | ✴️ | | |
|**`options`** | OdsCartManagerItem[] | ✴️ | | |

### OdsCartMethod
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`getItemQuantity`** | `Promise<number>` | ✴️ | | get the number of cart items detected in the DOM|
|**`refresh`** | `Promise<void>` | ✴️ | | Render manually the cart in order to refresh the component.|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Interfaces

### OdsCheckboxButtonAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`checked`** | _boolean_ | | | The checked status of the checkbox button|
|**`checking`** | _boolean_ | | | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Interfaces

### OdsCheckboxAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`afterSave`** | `OdsCheckboxAttributeCbk` | | | afterSave input allows to set a function that returns a promise.It is called after each time an update was performed and allowing to manage pessimistic update strategy|
|**`ariaLabel`** | `undefined` \| `string` | ✴️ | | The corresponding aria-label describing its content|
Expand All @@ -20,33 +20,33 @@
|**`value`** | _string_ | ✴️ | | Its corresponding value|

### OdsCheckboxCheckedChangeEventDetail
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`checked`** | _boolean_ | ✴️ | | |
|**`value`** | _string_ | ✴️ | | |

### OdsCheckboxEvent
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`odsBlur`** | `EventEmitter<OdsCheckboxFocusChangeEventDetail>` | ✴️ | | Event triggered on checkbox blur|
|**`odsCheckedChange`** | `EventEmitter<OdsCheckboxCheckedChangeEventDetail>` | ✴️ | | the checked state changed|
|**`odsFocus`** | `EventEmitter<OdsCheckboxFocusChangeEventDetail>` | ✴️ | | Event triggered on checkbox focus|
|**`odsUpdatingChange`** | `EventEmitter<OdsCheckboxUpdatingChangeEventDetail>` | ✴️ | | the checked state is being changed|

### OdsCheckboxFocusChangeEventDetail
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`focus`** | _boolean_ | ✴️ | | |
|**`value`** | _string_ | ✴️ | | |

### OdsCheckboxMethod
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`setFocus`** | `Promise<void>` | ✴️ | | programmatically set the focus on the checkbox.this method has to call OdsCheckboxController.setFocus|
|**`setTabindex`** | `Promise<void>` | ✴️ | | set the tab index.this method has to call OdsCheckboxController.setTabindex|

### OdsCheckboxUpdatingChangeEventDetail
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`updating`** | _boolean_ | ✴️ | | |
|**`value`** | _string_ | ✴️ | | |
Expand All @@ -62,4 +62,4 @@
Name | Type | Description
---|---|---
**index** | _number_ |
**index** | _number_ | |
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Interfaces

### OdsChipAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`color`** | `ODS_THEME_COLOR_INTENT` | | | Chip color theme|
|**`contrasted`** | _boolean_ | | | Chip is in contrasterd mode or not|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
## Interfaces

### OdsClipboardAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`disabled`** | _boolean_ | | | Disabled the input, the focus, and the tooltip|
|**`inline`** | _boolean_ | | | Indicates if the input is full width or not: see component principles|
|**`value`** | _string_ | ✴️ | | Input text value|

### OdsClipboardEvent
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`odsClipboardCopied`** | `EventEmitter<string>` | ✴️ | | |

Expand Down
4 changes: 2 additions & 2 deletions packages/components/code/documentation/specifications/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
## Interfaces

### OdsCodeAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`color`** | `ODS_THEME_COLOR_INTENT` | | | main color: see component principles|
|**`contrasted`** | _boolean_ | | | contrasted or not: see component principles|
|**`size`** | `md` | | | size: see component principles|

### OdsCodeEvent
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`odsCodeCopy`** | `EventEmitter<void>` | ✴️ | | Event triggered on code content copy|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
## Interfaces

### OdsCollapsibleAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`opened`** | _boolean_ | | | opened or not|

### OdsCollapsibleEvent
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`odsCollapsibleToggle`** | `EventEmitter<boolean>` | ✴️ | | Event triggered on collapsible toggle|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Interfaces

### OdsDividerAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`color`** | `ODS_THEME_COLOR_INTENT` | | | Divider color theme|
|**`contrasted`** | _boolean_ | | | Divider design as contrasted version|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Interfaces

### OdsFlagAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`assetPath`** | _string_ | | | override the `ODS` directory path of the assets.if not set, the configured path in `ODS` will be used.|
|**`iso`** | `ODS_FLAG_ISO_CODE_UNION` | | | Flag ISO country code|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Interfaces

### OdsFormFieldAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`error`** | _string_ | | | Indicates if the Form Field shows error or not|
|**`inline`** | _boolean_ | | | Indicates if the Form Field is full width or not: see component principles|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Interfaces

### OdsIconAttribute
|name | Type | Required | Default | Description|
|Name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`ariaName`** | _string_ | ✴️ | | Icon ARIA name|
|**`color`** | `ODS_THEME_COLOR_INTENT` | | | Icon color theme|
Expand Down
Loading

0 comments on commit a2c99a4

Please sign in to comment.