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

Documentation for Template Block attributes #6190

Closed
1 task
grappler opened this issue Apr 16, 2018 · 9 comments
Closed
1 task

Documentation for Template Block attributes #6190

grappler opened this issue Apr 16, 2018 · 9 comments
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Type] Developer Documentation Documentation for developers

Comments

@grappler
Copy link
Member

Issue Overview

In the template documentation there is no information what attributes can be used for the different blocks.

'template' => array(
    array( 'core/image', array(
        'align' => 'left',
    ) ),
),

https://wordpress.org/gutenberg/handbook/templates/

Possible Solution

The attributes can be found in the index.js of the the single blocks which can be found in https://github.com/WordPress/gutenberg/blob/master/blocks/library/

The path for the index.js would https://github.com/WordPress/gutenberg/blob/{block-name}/index.js

The current attributes for the paragraph block currently are

const {
    align,
    content,
    dropCap,
    placeholder,
    backgroundColor,
    textColor,
    width,
} = attributes;

which can be found here: https://github.com/WordPress/gutenberg/blob/v2.6.0/blocks/library/paragraph/index.js#L139-L145

Todos

  • Documentation
@karmatosed karmatosed added the [Type] Developer Documentation Documentation for developers label Apr 16, 2018
@chrisvanpatten
Copy link
Contributor

One thing we'd like to see is if there's a way to use a parser to document block attributes, because the workload of keeping these up to date over time would be really challenging.

Any way we can explore that option?

@chrisvanpatten chrisvanpatten added the Needs Technical Feedback Needs testing from a developer perspective. label Nov 8, 2018
@ajitbohra
Copy link
Member

We can automate it the way we are doing for documenting wp.data

@youknowriad youknowriad added this to the Documentation & Handbook milestone Jan 9, 2019
@youknowriad youknowriad removed this from the Documentation & Handbook milestone Mar 18, 2019
@gziolo gziolo added Needs Dev Ready for, and needs developer efforts and removed Needs Technical Feedback Needs testing from a developer perspective. labels May 24, 2019
@gziolo
Copy link
Member

gziolo commented May 24, 2019

Now that almost all blocks contain block.json definition with attributes, it should be possible to auto-generate documentation with the list of available attributes, e.g.

https://github.com/WordPress/gutenberg/blob/master/packages/block-library/src/audio/block.json#L4-L37

@nosolosw, is that something @wordpress/docgen could cover as well?

@gziolo gziolo added the Good First Issue An issue that's suitable for someone looking to contribute for the first time label May 24, 2019
@oandregal
Copy link
Member

@gziolo There are parts of docgen that may be useful for this. However it is more of a JSDoc grammar processor, so perhaps relying directly on what docgen uses internally (espree) is a better route. With the existing settings and metadata info we already have for blocks it'd be doable to auto-generate documentation for them!

@jaschaio
Copy link

@gziolo is there a reason not all blocks contain a block.json yet? For some blocks I can get the possible attributes from the .json, for others I need to check within the index.js or edit.js – couldn't figure out why not all of them have a block.json

@gziolo
Copy link
Member

gziolo commented Aug 12, 2019

@gziolo is there a reason not all blocks contain a block.json yet? For some blocks I can get the possible attributes from the .json, for others I need to check within the index.js or edit.js – couldn't figure out why not all of them have a block.json

There is no support for loading block.json in PHP so all blocks which use render_callback still define attributes on using register_block_type directly. I think also embeds aren't converted as they are pretty unique in the way the are defined. We will refactor them later this year.

@carolinan
Copy link
Contributor

What can we do to move this forward?

@mtias
Copy link
Member

mtias commented Aug 30, 2020

@youknowriad's BlockBook is meant to cover the need of listing block attributes and their effect. There's a proposal to integrate it in the main project in #24152. Ideally we'd also run a public instance of it in the block directory or integrate this information there somehow.

@mtias mtias added the [Feature] Block Directory Related to the Block Directory, a repository of block plugins label Aug 30, 2020
@mkaz
Copy link
Member

mkaz commented Dec 21, 2021

Closed in #36183

@mkaz mkaz closed this as completed Dec 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins Good First Issue An issue that's suitable for someone looking to contribute for the first time Needs Dev Ready for, and needs developer efforts [Type] Developer Documentation Documentation for developers
Projects
None yet
Development

No branches or pull requests