@@ -713,11 +713,12 @@ const isSpelledClass = (name) => {
713713/**
714714 * A stated class is stated because no dataset writes it out; once one does, the
715715 * derived spelling is the one to read.
716+ * @param {EXPECTED_ANY } syntaxTable the `syntaxes.json` to read
716717 * @returns {void }
717718 */
718- const checkStatedClassSpellings = ( ) => {
719+ const checkStatedClassSpellings = ( syntaxTable ) => {
719720 for ( const [ name ] of SUPPLEMENT . classSpellings ) {
720- if ( syntaxes [ name ] !== undefined ) {
721+ if ( syntaxTable [ name ] !== undefined ) {
721722 throw new Error ( `\`<${ name } >\` is spelled out by mdn-data now` ) ;
722723 }
723724 }
@@ -1343,26 +1344,28 @@ const RULE_HOLDING_BLOCKS = [
13431344 * The gradient functions, each with the last position its own stop list means:
13441345 * `<color-stop-length>` runs to `100%`, `<color-stop-angle>` to the same turn
13451346 * spelled either way. Read off `<gradient>`, so a seventh needs nothing here.
1347+ * @param {EXPECTED_ANY } syntaxTable the `syntaxes.json` to read
1348+ * @param {EXPECTED_ANY } functionTable the `functions.json` to read
13461349 * @returns {[string, string[]][] } `[function, last-position spellings]`, sorted
13471350 */
1348- const collectGradientFunctions = ( ) => {
1349- const entry = syntaxes . gradient ;
1351+ const collectGradientFunctions = ( syntaxTable , functionTable ) => {
1352+ const entry = syntaxTable . gradient ;
13501353 if ( entry === undefined ) {
13511354 throw new Error ( "`<gradient>` is gone from mdn-data" ) ;
13521355 }
13531356 /** @type {[string, string[]][] } */
13541357 const out = [ ] ;
13551358 for ( const name of entry . syntax . match ( / < ( [ a - z - ] + ) \( \) > / g) || [ ] ) {
13561359 const bare = name . slice ( 1 , - 3 ) ;
1357- const call = functions [ `${ bare } ()` ] ;
1360+ const call = functionTable [ `${ bare } ()` ] ;
13581361 if ( call === undefined || typeof call . syntax !== "string" ) {
13591362 throw new Error ( `\`${ bare } ()\` is gone from mdn-data` ) ;
13601363 }
13611364 // The stop list is reached through the `<x-gradient-syntax>` the call names.
13621365 const named = / < ( [ a - z - ] + ) > / . exec ( call . syntax ) ;
13631366 const body =
1364- named !== null && syntaxes [ named [ 1 ] ] !== undefined
1365- ? syntaxes [ named [ 1 ] ] . syntax
1367+ named !== null && syntaxTable [ named [ 1 ] ] !== undefined
1368+ ? syntaxTable [ named [ 1 ] ] . syntax
13661369 : call . syntax ;
13671370 const angular = body . includes ( "<angular-color-stop-list>" ) ;
13681371 out . push ( [ bare , angular ? [ "100%" , "360deg" , "1turn" ] : [ "100%" ] ] ) ;
@@ -1374,20 +1377,21 @@ const collectGradientFunctions = () => {
13741377 * The at-rules whose adjacent blocks merge into one: their block holds rules, and
13751378 * their prelude states a condition rather than naming the one thing the block
13761379 * belongs to (`@keyframes`, whose later block replaces the earlier).
1380+ * @param {EXPECTED_ANY } atRuleTable the `at-rules.json` to read
13771381 * @returns {string[] } the names without the `@`, sorted
13781382 */
1379- const collectMergeableAtRules = ( ) => {
1383+ const collectMergeableAtRules = ( atRuleTable ) => {
13801384 const replaced = new Set ( SUPPLEMENT . replacedByNameAtRules ) ;
13811385 const out = [ ] ;
1382- for ( const [ name , entry ] of Object . entries ( atRules ) ) {
1386+ for ( const [ name , entry ] of Object . entries ( atRuleTable ) ) {
13831387 const syntax = entry . syntax ;
13841388 if ( typeof syntax !== "string" ) continue ;
13851389 if ( ! RULE_HOLDING_BLOCKS . some ( ( one ) => syntax . includes ( one ) ) ) continue ;
13861390 const bare = name . slice ( 1 ) ;
13871391 if ( ! replaced . has ( bare ) ) out . push ( bare ) ;
13881392 }
13891393 for ( const one of replaced ) {
1390- const entry = atRules [ `@${ one } ` ] ;
1394+ const entry = atRuleTable [ `@${ one } ` ] ;
13911395 if ( entry === undefined ) {
13921396 throw new Error ( `\`@${ one } \` is gone from mdn-data` ) ;
13931397 }
@@ -3353,11 +3357,11 @@ const collectData = () => {
33533357 ] )
33543358 ] . sort ( ) ;
33553359 const [ positionXKeywords , positionYKeywords ] = collectPositionKeywordAxes ( ) ;
3356- checkStatedClassSpellings ( ) ;
3360+ checkStatedClassSpellings ( syntaxes ) ;
33573361 const shorthandInitialKeywords = collectShorthandInitialKeywords ( ) ;
33583362 const shadowProperties = collectShadowProperties ( ) ;
3359- const mergeableAtRules = collectMergeableAtRules ( ) ;
3360- const gradientFunctions = collectGradientFunctions ( ) ;
3363+ const mergeableAtRules = collectMergeableAtRules ( atRules ) ;
3364+ const gradientFunctions = collectGradientFunctions ( syntaxes , functions ) ;
33613365 const fontStretchPercentages = collectFontStretchPercentages ( ) ;
33623366 const filterFunctionOmitted = collectFilterFunctionOmitted ( ) ;
33633367 const shorterColorSpellings = collectShorterColorSpellings ( colorNames ) ;
@@ -3904,6 +3908,12 @@ if (require.main === module) generate();
39043908module . exports . DATA_TARGET = TARGET ;
39053909module . exports . acceptedValues = acceptedValues ;
39063910module . exports . assertClassesArePrintable = assertClassesArePrintable ;
3911+ module . exports . checkStatedClassSpellings = checkStatedClassSpellings ;
39073912module . exports . collectData = collectData ;
3913+ module . exports . collectGradientFunctions = collectGradientFunctions ;
3914+ module . exports . collectMergeableAtRules = collectMergeableAtRules ;
3915+ module . exports . isSpelledSyntax = isSpelledSyntax ;
39083916module . exports . parseValueSyntax = parseValueSyntax ;
3917+ module . exports . shorthandSlots = shorthandSlots ;
3918+ module . exports . slotSpellings = slotSpellings ;
39093919module . exports . walkValueSyntax = walkValueSyntax ;
0 commit comments