WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.3k stars 4.11k forks source link

Add code examples for actions/selectors in Data Module packages. #42125

Open ryanwelcher opened 2 years ago

ryanwelcher commented 2 years ago

What problem does this address?

Working with any of the data modules provided by WordPress can be very confusing. When looking at the Data Modules section in the handbook, there are almost no code examples for developers to use as reference.

I would love to see an example for each action or selector that is exposed for use.

Packages:

What is your proposed solution?

Add an @example tag to each docblock. This will be picked up by the documentation generator and added to the handbook.

ryanwelcher commented 2 years ago

42023 introduced one example and makes usage much clearer for getNotices

Notices_Data___Block_Editor_Handbook___WordPress_Developer_Resources

skorasaurus commented 2 years ago

In case you weren't aware, some resources that you may want to draw off of, for core/data:

https://github.com/WordPress/gutenberg/blob/bd06705979ad63ace26d15de47144c253c3b0fc8/docs/getting-started/data.md https://wordpress.stackexchange.com/questions/390985/how-do-i-access-site-and-block-editor-state-data-and-use-useselect-or-withs/390986#390986

t-hamano commented 2 years ago

@ryanwelcher

I have added missing data module references by #42651. Could you please add it to the task list as well?

And I would love to help add code examples too 😊

ryanwelcher commented 2 years ago

I have added missing data module references by #42651. Could you please add it to the task list as well?

This is fantastic! Thanks for putting that together. I've updated the list.

t-hamano commented 2 years ago

@ryanwelcher I have created PR #42831 about core/keyboard-shortcuts.

t-hamano commented 2 years ago

I have created PR #42921 about core/viewport.

t-hamano commented 2 years ago

I noticed that of the references I added in #42651, the selector and actions in the reusable-blocks package are all experimental. Should this package be excluded from the documentation?

t-hamano commented 1 year ago

I noticed that the selector and actions in the annotations package are all experimental too.

ryanwelcher commented 1 year ago

It probably makes sense to exclude packages that are fully experimental.

ryanwelcher commented 1 year ago

Some package are not exporting their stores. To keep the DX consistent, I have created the following PRs to to export the store:

ryanwelcher commented 1 month ago

@troychaplin you might be interested in this issue.

troychaplin commented 1 month ago

I have added a few examples in core/editor in https://github.com/WordPress/gutenberg/pull/63768, need a label added