| 843 | // Type categories like `baseSpacing` are emitted as aliases; their full value sets |
| 844 | // are documented once in the Value Sets section at the top of the page. |
| 845 | const buildTokens = propertyName => { |
| 846 | const def = definitions[propertyName] || {}; |
| 847 | const values = Array.isArray(def.values) ? def.values : []; |
| 848 | const additionalTypes = Array.isArray(def.additionalTypes) ? def.additionalTypes : []; |
| 849 | const tokens = []; |
| 850 | const seen = new Set(); |
| 851 | |
| 852 | const addToken = token => { |
| 853 | if (!token || seen.has(token)) { |
| 854 | return; |
| 855 | } |
| 856 | seen.add(token); |
| 857 | tokens.push(token); |
| 858 | }; |
| 859 | |
| 860 | const formatValue = value => { |
| 861 | if (typeof value === 'number') { |
| 862 | return `\`${value}\``; |
| 863 | } |
| 864 | const str = String(value); |
| 865 | if (BARE_VALUE_TOKENS.has(str) || str.includes('${')) { |
| 866 | return `\`${str}\``; |
| 867 | } |
| 868 | return `\`'${str}'\``; |
| 869 | }; |
| 870 | |
| 871 | values.forEach(value => { |
| 872 | if (value === undefined || value === null) { |
| 873 | return; |
| 874 | } |
| 875 | addToken(formatValue(value)); |
| 876 | }); |
| 877 | |
| 878 | additionalTypes.forEach(typeName => { |
| 879 | if (!typeName) { |
| 880 | return; |
| 881 | } |
| 882 | addToken(`\`${String(typeName)}\``); |
| 883 | }); |
| 884 | |
| 885 | return tokens; |
| 886 | }; |
| 887 | |
| 888 | // Group properties by identical token signatures so shared value sets collapse into one row. |
| 889 | // Example: margin/marginTop/marginBottom/... all share the same tokens and merge to one row. |
no test coverage detected