Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update theme.json reference docs to include more sections #48250

Merged
merged 6 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions bin/api-docs/gen-theme-reference.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
31 changes: 31 additions & 0 deletions docs/reference-guides/theme-json-reference/theme-json-living.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.


<!-- END TOKEN Autogenerated - DO NOT EDIT -->