style: change how optionals are displayed

This commit is contained in:
iCrawl
2022-08-22 14:19:02 +02:00
parent caeb66e150
commit 474eae0afc
2 changed files with 6 additions and 7 deletions

View File

@@ -11,10 +11,10 @@ type MethodResolvable = ApiMethodJSON | ApiMethodSignatureJSON;
function getShorthandName(data: MethodResolvable) {
return `${data.name}${data.optional ? '?' : ''}(${data.parameters.reduce((prev, cur, index) => {
if (index === 0) {
return `${prev}${cur.isOptional ? `[${cur.name}]` : cur.name}`;
return `${prev}${cur.isOptional ? `${cur.name}?` : cur.name}`;
}
return `${prev}, ${cur.isOptional ? `[${cur.name}]` : cur.name}`;
return `${prev}, ${cur.isOptional ? `${cur.name}?` : cur.name}`;
}, '')})`;
}

View File

@@ -43,15 +43,14 @@ export function ParametersSection({ data }: { data: ParameterDocumentation[] })
export function ConstructorSection({ data }: { data: ApiConstructorJSON }) {
const matches = useMediaQuery('(max-width: 768px)', true, { getInitialValueInEffect: false });
function getShorthandName(): string {
return `constructor(${data.parameters.reduce((prev, cur, index) => {
const getShorthandName = () =>
`constructor(${data.parameters.reduce((prev, cur, index) => {
if (index === 0) {
return `${prev}${cur.isOptional ? `[${cur.name}]` : cur.name}`;
return `${prev}${cur.isOptional ? `${cur.name}?` : cur.name}`;
}
return `${prev}, ${cur.isOptional ? `[${cur.name}]` : cur.name}`;
return `${prev}, ${cur.isOptional ? `${cur.name}?` : cur.name}`;
}, '')})`;
}
return data.parameters.length ? (
<Section title="Constructor" icon={<VscSymbolMethod />} padded dense={matches}>