Skip to content

docs(cypress-commands): show deprecation notice in docs #7396

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion .storybook/components/CommandsAndQueries.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Heading, Markdown } from '@storybook/blocks';
import { Tag as WCRTag } from '@ui5/webcomponents-react';
import dedent from 'dedent';
import { Fragment } from 'react';

Expand Down Expand Up @@ -87,11 +88,11 @@
}

interface Members {
global: any[];

Check warning on line 91 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
inner: any[];

Check warning on line 92 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
instance: any[];

Check warning on line 93 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
events: any[];

Check warning on line 94 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
static: any[];

Check warning on line 95 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
}

interface FunctionMetadata {
Expand All @@ -99,14 +100,14 @@
tags: Tag[];
loc: Loc;
context: Context;
augments: any[];

Check warning on line 103 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
examples: Example[];
implements: any[];

Check warning on line 105 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
params: Param[];
properties: any[];

Check warning on line 107 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
returns: Return[];
sees: any[];

Check warning on line 109 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
throws: any[];

Check warning on line 110 in .storybook/components/CommandsAndQueries.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
todos: any[];
yields: any[];
name: string;
Expand All @@ -116,6 +117,7 @@
members: Members;
path: Path[];
namespace: string;
deprecated: Record<string, any>;
}

function generateMdCodeBlock(codeStr: string) {
Expand Down Expand Up @@ -196,13 +198,37 @@
}, '');
}

function formatHtmlFromNode(node: any): string {
if (!node) return '';

switch (node.type) {
case 'root':
return node.children.map(formatHtmlFromNode).join('');
case 'paragraph':
return `<p>${node.children.map(formatHtmlFromNode).join('')}</p>`;
case 'text':
return node.value;
case 'inlineCode':
return `<code>${node.value}</code>`;
default:
return '';
}
}

export const CommandsAndQueries = ({ api }: { api: FunctionMetadata[] }) => {
return api
.sort((a, b) => a.name.localeCompare(b.name))
.map((item) => {
return (
<Fragment key={item.name}>
<Heading>{item.name}</Heading>
<Heading>
{item.name}
{!!item.deprecated && (
<WCRTag style={{ marginInlineStart: '1rem' }} design="Critical">
deprecated
</WCRTag>
)}
</Heading>
<code>
{item.name}(
{item.params
Expand All @@ -215,6 +241,12 @@
return generateGenericType(type);
})}
</code>
{!!item.deprecated && (
<>
<br />
{<b dangerouslySetInnerHTML={{ __html: formatHtmlFromNode(item.deprecated) }} />}
</>
)}
<Markdown>{generateDescription(item.description)}</Markdown>
{generateExample(item.tags)}
{!!item.params.length && (
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress-commands/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ declare global {
*
* __Note:__ The select popover must be visible, otherwise it can lead to unwanted side effects.
*
* @deprecated: This command is deprecated. Please use `clickDropdownMenuItem` instead.
* @deprecated This command is deprecated. Please use `clickDropdownMenuItem` instead.
*
* @example cy.get('[ui5-option]').clickUi5SelectOption();
*/
Expand Down
Loading