Skip to content

Commit

Permalink
Update theme.json reference docs to include more sections (#48250)
Browse files Browse the repository at this point in the history
* Update theme.json reference docs to include more sections
---------

Co-authored-by: Ari Stathopoulos <[email protected]>
  • Loading branch information
carolinan and aristath authored Apr 13, 2023
1 parent 595d774 commit 724f577
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
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 @@ -268,5 +268,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 -->

1 comment on commit 724f577

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 724f577.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4685085658
📝 Reported issues:

Please sign in to comment.