diff --git a/tools/generate-block-palette-spec.php b/tools/generate-block-palette-spec.php new file mode 100644 index 000000000..f8365f86a --- /dev/null +++ b/tools/generate-block-palette-spec.php @@ -0,0 +1,70 @@ +getStates() as $state){ + $name = $state->getName(); + foreach($state->getStates() as $propertyName => $value){ + if($value instanceof IntTag || $value instanceof StringTag){ + $rawValue = $value->getValue(); + }elseif($value instanceof ByteTag){ + $rawValue = match($value->getValue()){ + 0 => false, + 1 => true, + default => throw new AssumptionFailedError("Unexpected ByteTag value for $name -> $propertyName ($value)") + }; + }else{ + throw new AssumptionFailedError("Unexpected tag type for $name -> $propertyName ($value)"); + } + $reportMap[$name][$propertyName][get_class($value) . ":" . $value->getValue()] = $rawValue; + } +} + +foreach($reportMap as $blockName => $propertyList){ + foreach($propertyList as $propertyName => $propertyValues){ + ksort($reportMap[$blockName][$propertyName]); + $reportMap[$blockName][$propertyName] = array_values($propertyValues); + } +} +ksort($reportMap, SORT_STRING); + +file_put_contents($argv[2], json_encode($reportMap, JSON_PRETTY_PRINT)); + +