From 083862f8679f2318618df7a2d0f69fe6f64d4c3a Mon Sep 17 00:00:00 2001 From: Misode Date: Tue, 29 Oct 2024 06:13:12 +0100 Subject: [PATCH] Improve key formatting and use enum identifiers --- src/app/components/generator/McdocRenderer.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/components/generator/McdocRenderer.tsx b/src/app/components/generator/McdocRenderer.tsx index c13a918f..77d28764 100644 --- a/src/app/components/generator/McdocRenderer.tsx +++ b/src/app/components/generator/McdocRenderer.tsx @@ -206,7 +206,7 @@ function EnumHead({ type, optional, node, makeEdit }: Props) { {(value === undefined || optional) && } {(value !== undefined && !type.values.map(v => v.value).includes(value)) && } {type.values.map(value => - + )} } @@ -414,11 +414,11 @@ function TupleHead({ type, optional, node, makeEdit, ctx }: Props) { if (optional) { if (node && JsonArrayNode.is(node)) { - return } else { - return } @@ -1029,7 +1029,10 @@ function formatIdentifier(id: string): string { if (id.startsWith('!')) { return '! ' + formatIdentifier(id.substring(1)) } - const text = id.replace(/^minecraft:/, '').replaceAll('_', ' ') + const text = id + .replace(/^minecraft:/, '') + .replaceAll('_', ' ') + .replace(/[a-z][A-Z]+/g, m => m.charAt(0) + ' ' + m.substring(1).toLowerCase()) return text.charAt(0).toUpperCase() + text.substring(1) }