-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Move entity-provider.js exports into hooks/index.ts so they are added to the docs #63528
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +190 B (+0.01%) Total Size: 1.75 MB
ℹ️ View Unchanged
|
Maybe we should move the entity hooks into the |
Do we know why the file is not pulled into the README? AFAIK docgen documents all public exports no? |
Doc gen only pulls in files that are referenced in the tokens in the readme. There is a reference to the hooks.ts file but none for the entity-provider.js file and the hooks that files contains are not exported in hooks.ts so they are missed |
@ryanwelcher makes sense, so why are we not updating the README.md file's tokens instead? |
@youknowriad I did that at first but thought we should keep all of the hooks together in the code base. I'm fine either way so if we're concerned about moving imports that would be the approach with the least amount of risk. |
I don't mind, I was just trying to understand why it was not working. For me, we shouldn't be adapting the code to the docs but If these things (hooks/intex.ts and entity-provider.js) are considered similar, it would make sense to group them in the code as well. That said, it seems EntityProvider exposes more than just hooks. It also exposes a component. |
i would say that they are related as they all work with entities. The useEntityRecord and useEntityRecord are in the hooks directory. |
I think @Mamaduka suggestion probably makes the most sense here. Unless you have any concerns with that @youknowriad , I'll update the PR |
I'm not sure I understand the suggestion. If it's about moving the hooks to Otherwise, I'm also ok with the current PR as it stands. |
Sounds good to me @youknowriad. To be clear, I was planning on moving the hooks in I'll get the PR updated now. |
9a385a7
to
43ab67e
Compare
import { updateFootnotesFromMeta } from './footnotes'; | ||
|
||
const EMPTY_ARRAY = []; | ||
import { createContext, useContext, useMemo } from '@wordpress/element'; | ||
|
||
const EntityContext = createContext( {} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mamaduka @youknowriad I just wanted to call this out as there was a single EntityContext
being used across the hooks and to move the useEntityId
hook into it's own file, I needed to create the same there.
I don't see any errors/failures but wanted to be sure that doing this won't cause any unexpected outcome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's a mistake, it should use the exact same EntityContext in all the files. You can do so by creating an entity-context
file and importing it in all the files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated with latest commit. Thanks for confirming, it felt like that was a bad idea :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @ryanwelcher!
… to the docs (WordPress#63528) * Reapply changes to fix bad rebase. * Update import for entity-provider.js tests. * Create a common EntityContext and import to appropriate places. Co-authored-by: ryanwelcher <welcher@git.wordpress.org> Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: Taigistal <silaskoehler@git.wordpress.org>
What?
The hooks defined in
core-data/entity-provider.js
are not documented because the file is not being pulled into the README.md for docgen to generate.Closes: #63475.
Why?
These hooks should be documented under https://developer.wordpress.org/block-editor/reference-guides/packages/packages-core-data/#hooks
How?
I have move all of the hooks in
entity-provider.js
into their own files inside thehooks
directory and exported them from there. This will have them be picked up by the docgen tool and add them to the documentation.Testing Instructions
useEntityProp
is still available on thewp.coreData
global and there are no errors in the block editor.