diff --git a/apps/docs/components/reference/CLICommandSection.tsx b/apps/docs/components/reference/CLICommandSection.tsx index f7e86190b4e..09eb13dc4b3 100644 --- a/apps/docs/components/reference/CLICommandSection.tsx +++ b/apps/docs/components/reference/CLICommandSection.tsx @@ -1,25 +1,12 @@ -import { IconChevronRight } from '~/../../packages/ui' +import ReactMarkdown from 'react-markdown' +import { IconChevronRight, Tabs } from '~/../../packages/ui' // @ts-expect-error import spec from '~/../../spec/cli_v1_commands.yaml' assert { type: 'yml' } import CodeBlock from '~/components/CodeBlock/CodeBlock' import Options from '~/components/Options' import Param from '~/components/Params' import RefSubLayout from '~/layouts/ref/RefSubLayout' - -interface ICommonFunc { - id: string - title: string - slug: string - product: string - libs: string - items: ICommonFunc[] -} - -interface IRefFunctionSection { - funcData: ICommonFunc - commonFuncData: ICommonFunc - spec: any -} +import RefDetailCollapse from './RefDetailCollapse' export type Flag = { id: string @@ -37,16 +24,25 @@ export type AcceptedValue = { description?: string } +export type Example = { + id: string + name: string + code: string + response: string + description?: string +} + export type Command = { id: string title: string description: string flags?: Flag[] summary: string - tags?: [] - links?: [] - subcommands?: [] + tags?: string[] + links?: string[] + subcommands?: string[] usage?: string + examples?: Example[] } const CliCommandSection = (props) => { @@ -75,12 +71,6 @@ const CliCommandSection = (props) => {

- {/* {command.usage && ( - - {command.usage} - - )} */} - {command.subcommands.length > 0 && (

Available Commands

@@ -126,13 +116,82 @@ const CliCommandSection = (props) => {
- - {command.usage && ( - - {command.usage} - - )} - + {(command.examples || command.usage) && ( + +
+ + {command.examples ? ( + command.examples.map((example) => { + const exampleId = `${command.id}-${example.id}` + return ( + + + {example.code} + + + + + {example.response} + + + + {example.description && ( + +
+ {example.description} +
+
+ )} +
+ ) + }) + ) : ( + // TODO: remove this block once all commands have examples + + + {command.usage} + + + )} +
+
+
+ )} ) }