Skip to content

Commit

Permalink
Components: Normalize newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Dec 20, 2024
1 parent d9f18e5 commit 869d26b
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/api-docs/gen-components-docs/markdown/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import json2md from 'json2md';
*/
import { generateMarkdownPropsJson } from './props.mjs';

function normalizeTrailingNewline( str ) {
return str?.length ? str.replace( /\n*$/, '\n' ) : undefined;
}

export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
const mainDocsJson = [
{ h1: typeDocs.displayName },
'<!-- This file is generated automatically and cannot be edited directly. Make edits via TypeScript types and TSDocs. -->',
{
p: `<p class="callout callout-info">See the <a href="https://wordpress.github.io/gutenberg/?path=/docs/components-${ typeDocs.displayName.toLowerCase() }--docs">WordPress Storybook</a> for more detailed, interactive documentation.</p>`,
},
typeDocs.description,
normalizeTrailingNewline( typeDocs.description ),
...generateMarkdownPropsJson( typeDocs.props ),
];

Expand All @@ -26,7 +30,7 @@ export function generateMarkdownDocs( { typeDocs, subcomponentTypeDocs } ) {
{
h3: subcomponentTypeDoc.displayName,
},
subcomponentTypeDoc.description,
normalizeTrailingNewline( subcomponentTypeDoc.description ),
...generateMarkdownPropsJson( subcomponentTypeDoc.props, {
headingLevel: 4,
} ),
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/alignment-matrix-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Example = () => {
);
};
```

## Props

### `defaultValue`
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/angle-picker-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function Example() {
);
}
```

## Props

### `as`
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/base-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const MyCustomTextareaControl = ({ children, ...baseProps }) => (
);
);
```

## Props

### `__nextHasNoMarginBottom`
Expand Down Expand Up @@ -113,6 +114,7 @@ const MyBaseControl = () => (
</BaseControl>
);
```

#### Props

##### `as`
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/box-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function Example() {
);
};
```

## Props

### `__next40pxDefaultSize`
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Mybutton = () => (
</Button>
);
```

## Props

### `__next40pxDefaultSize`
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/form-file-upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const MyFormFileUpload = () => (
</FormFileUpload>
);
```

## Props

### `__next40pxDefaultSize`
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/gradient-picker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const MyGradientPicker = () => {
);
};
```

## Props

### `__experimentalIsRenderedInSidebar`
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { wordpress } from '@wordpress/icons';

<Icon icon={ wordpress } />
```

## Props

### `icon`
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/tree-select/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const MyTreeSelect = () => {
);
}
```

## Props

### `__next40pxDefaultSize`
Expand Down

0 comments on commit 869d26b

Please sign in to comment.