Skip to content

Commit

Permalink
Clarify helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Dec 20, 2024
1 parent 869d26b commit e5e4a65
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion bin/api-docs/gen-components-docs/markdown/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ import json2md from 'json2md';
*/
import { generateMarkdownPropsJson } from './props.mjs';

/**
* If the string is contentful, ensure that it ends with a single newline.
* Otherwise normalize to `undefined`.
*
* @param {string} [str]
*/
function normalizeTrailingNewline( str ) {
return str?.length ? str.replace( /\n*$/, '\n' ) : undefined;
if ( ! str?.trim() ) {
return undefined;
}
return str.replace( /\n*$/, '\n' );
}

export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
Expand Down

0 comments on commit e5e4a65

Please sign in to comment.