diff --git a/bin/api-docs/gen-theme-reference.js b/bin/api-docs/gen-theme-reference.js index 45edecf6bd1a2..f638bb708890a 100644 --- a/bin/api-docs/gen-theme-reference.js +++ b/bin/api-docs/gen-theme-reference.js @@ -211,6 +211,35 @@ styleSections.forEach( ( section ) => { autogen += getSectionMarkup( section, styles[ section ], 'styles' ); } ); +const templateTableGeneration = ( themeJson, context ) => { + let content = ''; + content += '## ' + context + '\n\n'; + content += themeJson.properties[ context ].description + '\n\n'; + content += + 'Type: `' + themeJson.properties[ context ].items.type + '`.\n\n'; + content += '| Property | Description | Type |\n'; + content += '| --- | --- | --- |\n'; + keys( themeJson.properties[ context ].items.properties ).forEach( + ( key ) => { + content += `| ${ key } | ${ themeJson.properties[ context ].items.properties[ key ].description } | ${ themeJson.properties[ context ].items.properties[ key ].type } |\n`; + } + ); + content += '\n\n'; + + return content; +}; + +// customTemplates +autogen += templateTableGeneration( themejson, 'customTemplates' ); + +// templateParts +autogen += templateTableGeneration( themejson, 'templateParts' ); + +// Patterns +autogen += '## Patterns' + '\n\n'; +autogen += themejson.properties.patterns.description + '\n'; +autogen += 'Type: `' + themejson.properties.patterns.type + '`.\n\n'; + // Read existing file to wrap auto generated content. let docsContent = fs.readFileSync( THEME_JSON_REF_DOC, { encoding: 'utf8', diff --git a/docs/reference-guides/theme-json-reference/theme-json-living.md b/docs/reference-guides/theme-json-reference/theme-json-living.md index acc0a499ec61b..f3b0ea636d091 100644 --- a/docs/reference-guides/theme-json-reference/theme-json-living.md +++ b/docs/reference-guides/theme-json-reference/theme-json-living.md @@ -245,5 +245,36 @@ Sets custom CSS to apply styling not covered by other theme.json properties. --- +## customTemplates + +Additional metadata for custom templates defined in the templates folder. + +Type: `object`. + +| Property | Description | Type | +| --- | --- | --- | +| name | Filename, without extension, of the template in the templates folder. | string | +| title | Title of the template, translatable. | string | +| postTypes | List of post types that can use this custom template. | array | + + +## templateParts + +Additional metadata for template parts defined in the parts folder. + +Type: `object`. + +| Property | Description | Type | +| --- | --- | --- | +| name | Filename, without extension, of the template in the parts folder. | string | +| title | Title of the template, translatable. | string | +| area | The area the template part is used for. Block variations for `header` and `footer` values exist and will be used when the area is set to one of those. | string | + + +## Patterns + +An array of pattern slugs to be registered from the Pattern Directory. +Type: `array`. +