Skip to content

Commit

Permalink
Documentation: PostTaxonomies, PostTaxonomiesCheck, PostTaxonomiesFla…
Browse files Browse the repository at this point in the history
…tTermSelector, PostTaxonomiesPanel related editor components (#62384)

* Add JSDoc block for PostTaxonomiesPanel component

* Add JSDoc block for PostTaxonomies component

* Add JSDoc block for PostTaxonomiesFlatTermSelector

* Add JSDoc block for ostTaxonomiesCheck component

* Auto-generate editor docs for PostTaxonomies** related components
  • Loading branch information
colorful-tones authored Jun 7, 2024
1 parent e348235 commit 6757521
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
45 changes: 41 additions & 4 deletions packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1296,15 +1296,42 @@ _Returns_

### PostTaxonomies

Undocumented declaration.
Renders the taxonomies associated with a post.

_Parameters_

- _props_ `Object`: The component props.
- _props.taxonomyWrapper_ `Function`: The wrapper function for each taxonomy component.

_Returns_

- `Array`: An array of JSX elements representing the visible taxonomies.

### PostTaxonomiesCheck

Undocumented declaration.
Renders the children components only if the current post type has taxonomies.

_Parameters_

- _props_ `Object`: The component props.
- _props.children_ `Element`: The children components to render.

_Returns_

- `Component|null`: The rendered children components or null if the current post type has no taxonomies.

### PostTaxonomiesFlatTermSelector

Undocumented declaration.
Renders a flat term selector component.

_Parameters_

- _props_ `Object`: The component props.
- _props.slug_ `string`: The slug of the taxonomy.

_Returns_

- `JSX.Element`: The rendered flat term selector component.

### PostTaxonomiesHierarchicalTermSelector

Expand All @@ -1321,7 +1348,17 @@ _Returns_

### PostTaxonomiesPanel

Undocumented declaration.
Renders a panel for a specific taxonomy.

_Parameters_

- _props_ `Object`: The component props.
- _props.taxonomy_ `Object`: The taxonomy object.
- _props.children_ `Element`: The child components.

_Returns_

- `Component`: The rendered taxonomy panel.

### PostTemplatePanel

Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-taxonomies/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import { store as coreStore } from '@wordpress/core-data';
*/
import { store as editorStore } from '../../store';

/**
* Renders the children components only if the current post type has taxonomies.
*
* @param {Object} props The component props.
* @param {Element} props.children The children components to render.
*
* @return {Component|null} The rendered children components or null if the current post type has no taxonomies.
*/
export default function PostTaxonomiesCheck( { children } ) {
const hasTaxonomies = useSelect( ( select ) => {
const postType = select( editorStore ).getCurrentPostType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ const termNamesToIds = ( names, terms ) => {
.filter( ( id ) => id !== undefined );
};

/**
* Renders a flat term selector component.
*
* @param {Object} props The component props.
* @param {string} props.slug The slug of the taxonomy.
*
* @return {JSX.Element} The rendered flat term selector component.
*/
export function FlatTermSelector( { slug } ) {
const [ values, setValues ] = useState( [] );
const [ search, setSearch ] = useState( '' );
Expand Down
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-taxonomies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,12 @@ export function PostTaxonomies( { taxonomyWrapper = identity } ) {
} );
}

/**
* Renders the taxonomies associated with a post.
*
* @param {Object} props The component props.
* @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.
*
* @return {Array} An array of JSX elements representing the visible taxonomies.
*/
export default PostTaxonomies;
9 changes: 9 additions & 0 deletions packages/editor/src/components/post-taxonomies/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,13 @@ function PostTaxonomies() {
);
}

/**
* Renders a panel for a specific taxonomy.
*
* @param {Object} props The component props.
* @param {Object} props.taxonomy The taxonomy object.
* @param {Element} props.children The child components.
*
* @return {Component} The rendered taxonomy panel.
*/
export default PostTaxonomies;

1 comment on commit 6757521

@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 6757521.
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/9414027919
📝 Reported issues:

Please sign in to comment.