Skip to content

Commit

Permalink
[docs-infra] Tweak buildReference script (#1062)
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert authored Dec 12, 2024
1 parent 4087bb1 commit 7f3021a
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/reference/generated/menu-checkbox-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"description": "A text representation of the menu item's content.\nUsed for keyboard text navigation matching."
},
"onCheckedChange": {
"type": "function",
"type": "(checked, event) => void",
"description": "Event handler called when the checkbox item is ticked or unticked."
},
"onClick": {
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/generated/menu-radio-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
"name": "MenuRadioItem",
"description": "A menu item that works like a radio button in a given group.\nRenders a `<div>` element.",
"props": {
"value": {
"type": "any",
"required": true,
"description": "Value of the radio item.\nThis is the value that will be set in the MenuRadioGroup when the item is selected."
},
"closeOnClick": {
"type": "boolean",
"default": "true",
Expand All @@ -28,6 +23,11 @@
"onClick": {
"type": "(event) => void",
"description": "The click handler for the menu item."
},
"value": {
"type": "any",
"required": true,
"description": "Value of the radio item.\nThis is the value that will be set in the MenuRadioGroup when the item is selected."
}
},
"dataAttributes": {
Expand Down
10 changes: 5 additions & 5 deletions docs/reference/generated/radio-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
"name": "RadioRoot",
"description": "Represents the radio button itself.\nRenders a `<button>` element and a hidden `<input>` beside.",
"props": {
"value": {
"type": "any",
"required": true,
"description": "The unique identifying value of the radio in a group."
},
"className": {
"type": "string | (state) => string",
"description": "CSS class applied to the element, or a function that\nreturns a class based on the component’s state."
Expand All @@ -29,6 +24,11 @@
"type": "boolean",
"default": "false",
"description": "Whether the user must choose a value before submitting a form."
},
"value": {
"type": "any",
"required": true,
"description": "The unique identifying value of the radio in a group."
}
}
}
4 changes: 2 additions & 2 deletions docs/reference/generated/select-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"description": "Identifies the field when a form is submitted."
},
"onOpenChange": {
"type": "function",
"type": "(open, event) => void",
"description": "Event handler called when the select menu is opened or closed."
},
"onValueChange": {
"type": "function",
"type": "(value, event) => void",
"description": "Callback fired when the value of the select changes. Use when controlled."
},
"open": {
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/generated/select-value.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "SelectValue",
"description": "A text label of the currently selected item.\nRenders a `<span>` element.",
"props": {
"children": {
"type": "React.ReactNode | (value) => React.ReactNode",
"description": "Override children if you need to customize how the value is displayed.\nBy default, renders the current value as is.\n\nAccepts a `ReactNode` or a function that returns the node to render."
},
"className": {
"type": "string | (state) => string",
"description": "CSS class applied to the element, or a function that\nreturns a class based on the component’s state."
Expand Down
4 changes: 4 additions & 0 deletions docs/reference/generated/slider-value.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"name": "SliderValue",
"description": "Displays the current value of the slider as text.\nRenders an `<output>` element.",
"props": {
"children": {
"type": "React.ReactNode | (formattedValue, value) => React.ReactNode",
"description": "Override children if you need to customize how the value is displayed.\nBy default, renders the current value as is.\n\nAccepts a `ReactNode` or a function that returns the node to render."
},
"className": {
"type": "string | (state) => string",
"description": "CSS class applied to the element, or a function that\nreturns a class based on the component’s state."
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/overrides/menu-checkbox-item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "MenuCheckboxItem",
"props": {
"onCheckedChange": {
"type": "(checked, event) => void"
}
}
}
11 changes: 11 additions & 0 deletions docs/reference/overrides/select-root.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "SelectRoot",
"props": {
"onOpenChange": {
"type": "(open, event) => void"
},
"onValueChange": {
"type": "(value, event) => void"
}
}
}
9 changes: 9 additions & 0 deletions docs/reference/overrides/select-value.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "SelectValue",
"props": {
"children": {
"type": "React.ReactNode | (value) => React.ReactNode",
"description": "Override children if you need to customize how the value is displayed.\nBy default, renders the current value as is.\n\nAccepts a `ReactNode` or a function that returns the node to render."
}
}
}
9 changes: 9 additions & 0 deletions docs/reference/overrides/slider-value.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "SliderValue",
"props": {
"children": {
"type": "React.ReactNode | (formattedValue, value) => React.ReactNode",
"description": "Override children if you need to customize how the value is displayed.\nBy default, renders the current value as is.\n\nAccepts a `ReactNode` or a function that returns the node to render."
}
}
}
5 changes: 3 additions & 2 deletions scripts/buildApiDocs/buildReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function buildReference() {
const descriptionData: PropsTranslations = JSON.parse(descriptionJsonContents);

for (const prop in props) {
props[prop].description = descriptionData.propDescriptions[prop]?.description;
props[prop].description ??= descriptionData.propDescriptions[prop]?.description;

if (!descriptionData.propDescriptions[prop]?.description) {
console.warn(`Missing prop description: ${componentData.name} / ${prop}`);
Expand All @@ -93,7 +93,8 @@ export async function buildReference() {
const json: ComponentDef = {
name: componentData.name,
description: descriptionData.componentDescription,
props,
// manually sort since overrides may interrupt alphabetical order
props: Object.fromEntries(Object.entries(props).sort()),
dataAttributes,
cssVariables,
};
Expand Down

0 comments on commit 7f3021a

Please sign in to comment.