From 872ca9cddf7f674495ff8dfb8cbf5769aa6d9068 Mon Sep 17 00:00:00 2001 From: Kellen Mace Date: Thu, 16 May 2024 12:45:22 -0400 Subject: [PATCH 1/6] Add JSDoc dockblock for PostURL component --- packages/editor/README.md | 10 +++++++++- packages/editor/src/components/post-url/index.js | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index 48a5e52cc47aa..c00ebf04e660d 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -1138,7 +1138,15 @@ _Returns_ ### PostURL -Undocumented declaration. +Renders the Post URL. + +_Parameters_ + +- _onClose_ `Function`: Callback function to be executed when the popover is closed. + +_Returns_ + +- `Component`: The component to be rendered. ### PostURLCheck diff --git a/packages/editor/src/components/post-url/index.js b/packages/editor/src/components/post-url/index.js index cf55e30473329..40d4745c76682 100644 --- a/packages/editor/src/components/post-url/index.js +++ b/packages/editor/src/components/post-url/index.js @@ -24,6 +24,13 @@ import { useCopyToClipboard } from '@wordpress/compose'; import { usePostURLLabel } from './label'; import { store as editorStore } from '../../store'; +/** + * Renders the Post URL. + * + * @param {Function} onClose Callback function to be executed when the popover is closed. + * + * @return {Component} The component to be rendered. + */ export default function PostURL( { onClose } ) { const { isEditable, postSlug, postLink, permalinkPrefix, permalinkSuffix } = useSelect( ( select ) => { From a8573b030759d2632af2360094934a97618fb6e3 Mon Sep 17 00:00:00 2001 From: Damon Cook Date: Fri, 17 May 2024 19:04:15 -0400 Subject: [PATCH 2/6] Refine PostURL JSDocs --- packages/editor/src/components/post-url/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/editor/src/components/post-url/index.js b/packages/editor/src/components/post-url/index.js index 40d4745c76682..9453977a23bf0 100644 --- a/packages/editor/src/components/post-url/index.js +++ b/packages/editor/src/components/post-url/index.js @@ -25,11 +25,16 @@ import { usePostURLLabel } from './label'; import { store as editorStore } from '../../store'; /** - * Renders the Post URL. + * Renders the `PostURL` component. + * + * @example + * ```jsx + * + * ``` * * @param {Function} onClose Callback function to be executed when the popover is closed. * - * @return {Component} The component to be rendered. + * @return {Component} The rendered PostURL component. */ export default function PostURL( { onClose } ) { const { isEditable, postSlug, postLink, permalinkPrefix, permalinkSuffix } = From 68e1cfcb57b8316253201d2e7a489ec68c1b7d0a Mon Sep 17 00:00:00 2001 From: Damon Cook Date: Fri, 17 May 2024 19:04:41 -0400 Subject: [PATCH 3/6] Add PostURLPanel JSDocs --- packages/editor/src/components/post-url/panel.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/editor/src/components/post-url/panel.js b/packages/editor/src/components/post-url/panel.js index c4a1cbba935c7..fbf174cc28bf3 100644 --- a/packages/editor/src/components/post-url/panel.js +++ b/packages/editor/src/components/post-url/panel.js @@ -15,6 +15,11 @@ import PostURL from './index'; import PostPanelRow from '../post-panel-row'; import { store as editorStore } from '../../store'; +/** + * Renders the `PostURLPanel` component. + * + * @return {JSX.Element} The rendered PostURLPanel component. + */ export default function PostURLPanel() { // Use internal state instead of a ref to make sure that the component // re-renders when the popover's anchor updates. From 12f5e25fdf37508a177491595a274375ecf1af2e Mon Sep 17 00:00:00 2001 From: Damon Cook Date: Fri, 17 May 2024 19:04:57 -0400 Subject: [PATCH 4/6] Add PostURLLabel JSDocs --- packages/editor/src/components/post-url/label.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/editor/src/components/post-url/label.js b/packages/editor/src/components/post-url/label.js index 5c233dfd54946..4f03e2bce0d05 100644 --- a/packages/editor/src/components/post-url/label.js +++ b/packages/editor/src/components/post-url/label.js @@ -9,10 +9,20 @@ import { filterURLForDisplay, safeDecodeURIComponent } from '@wordpress/url'; */ import { store as editorStore } from '../../store'; +/** + * Represents a label component for a post URL. + * + * @return {Component} The PostURLLabel component. + */ export default function PostURLLabel() { return usePostURLLabel(); } +/** + * Custom hook to get the label for the post URL. + * + * @return {string} The filtered and decoded post URL label. + */ export function usePostURLLabel() { const postLink = useSelect( ( select ) => select( editorStore ).getPermalink(), From 44e60abec305df3e93f6d916c0d30f67070bceec Mon Sep 17 00:00:00 2001 From: Damon Cook Date: Fri, 17 May 2024 19:05:22 -0400 Subject: [PATCH 5/6] Add PostURLCheck JSDocs --- packages/editor/src/components/post-url/check.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/editor/src/components/post-url/check.js b/packages/editor/src/components/post-url/check.js index 65c54846a702b..7eb390472bdd7 100644 --- a/packages/editor/src/components/post-url/check.js +++ b/packages/editor/src/components/post-url/check.js @@ -9,6 +9,14 @@ import { store as coreStore } from '@wordpress/core-data'; */ import { store as editorStore } from '../../store'; +/** + * Check if the post URL is valid and visible. + * + * @param {Object} props The component props. + * @param {Element} props.children The child components. + * + * @return {Component|null} The child components if the post URL is valid and visible, otherwise null. + */ export default function PostURLCheck( { children } ) { const isVisible = useSelect( ( select ) => { const postTypeSlug = select( editorStore ).getCurrentPostType(); From 4b382de12dbd96aa359a09817ecc92421ce39a0b Mon Sep 17 00:00:00 2001 From: Damon Cook Date: Fri, 17 May 2024 19:05:39 -0400 Subject: [PATCH 6/6] Auto-generate editor docs for PostURL updates --- packages/editor/README.md | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/packages/editor/README.md b/packages/editor/README.md index c00ebf04e660d..60678a98dabc9 100644 --- a/packages/editor/README.md +++ b/packages/editor/README.md @@ -1138,7 +1138,13 @@ _Returns_ ### PostURL -Renders the Post URL. +Renders the `PostURL` component. + +_Usage_ + +```jsx + +``` _Parameters_ @@ -1146,19 +1152,36 @@ _Parameters_ _Returns_ -- `Component`: The component to be rendered. +- `Component`: The rendered PostURL component. ### PostURLCheck -Undocumented declaration. +Check if the post URL is valid and visible. + +_Parameters_ + +- _props_ `Object`: The component props. +- _props.children_ `Element`: The child components. + +_Returns_ + +- `Component|null`: The child components if the post URL is valid and visible, otherwise null. ### PostURLLabel -Undocumented declaration. +Represents a label component for a post URL. + +_Returns_ + +- `Component`: The PostURLLabel component. ### PostURLPanel -Undocumented declaration. +Renders the `PostURLPanel` component. + +_Returns_ + +- `JSX.Element`: The rendered PostURLPanel component. ### PostVisibility @@ -1270,7 +1293,11 @@ Undocumented declaration. ### usePostURLLabel -Undocumented declaration. +Custom hook to get the label for the post URL. + +_Returns_ + +- `string`: The filtered and decoded post URL label. ### usePostVisibilityLabel