-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from easyops-cn/sailorshe/master/supportDocTyp…
…esShow feat(): support types show
- Loading branch information
Showing
15 changed files
with
551 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from "react"; | ||
import { EnumDeclaration } from "@next-core/brick-manifest"; | ||
import { GeneralType } from "../BrickDocTypes/generalType"; | ||
import styles from "./style.module.css"; | ||
|
||
export default function BrickDocTypeAlias({ | ||
enumDeclaration, | ||
}: { | ||
enumDeclaration: EnumDeclaration; | ||
}): JSX.Element { | ||
return ( | ||
<div> | ||
<h3 id={enumDeclaration.name}> | ||
{enumDeclaration.name} | ||
<span className={styles.tag}>enum</span> | ||
</h3> | ||
<div className={styles.enumWrapper}> | ||
{enumDeclaration.members.map((item, index) => ( | ||
<div key={index}> | ||
{GeneralType(item.name)} | ||
{" = "} | ||
{GeneralType(item.value)} | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.enumWrapper { | ||
padding: 10px; | ||
margin-bottom: 32px; | ||
background-color: var(--ifm-code-background); | ||
border: 0.1rem solid rgba(0, 0, 0, 0.1); | ||
border-radius: var(--ifm-code-border-radius); | ||
font-family: var(--ifm-font-family-monospace); | ||
font-size: var(--ifm-code-font-size); | ||
vertical-align: middle; | ||
} | ||
|
||
.tag { | ||
font-size: 12px; | ||
display: inline-block; | ||
vertical-align: top; | ||
margin-left: 8px; | ||
background: #2cd2d2; | ||
color: #fff; | ||
padding: 2px; | ||
border-radius: 8px; | ||
line-height: 12px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from "react"; | ||
import { Types } from "@next-core/brick-manifest"; | ||
import { initTypes } from "../BrickDocTypes/generalType"; | ||
|
||
export default function BrickDocInit({ | ||
types, | ||
}: { | ||
types: Types[]; | ||
}): JSX.Element { | ||
types && initTypes(types); | ||
|
||
return <></>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { useMemo } from "react"; | ||
import { InterfaceDeclaration } from "@next-core/brick-manifest"; | ||
import { GeneralType } from "../BrickDocTypes/generalType"; | ||
import MaybeEmptyCode from "../MaybeEmptyCode"; | ||
|
||
export default function BrickDocInterface({ | ||
interfaceDeclaration, | ||
}: { | ||
interfaceDeclaration: InterfaceDeclaration; | ||
}): JSX.Element { | ||
const body = useMemo(() => { | ||
return interfaceDeclaration.annotation.map((item) => { | ||
if (item.type === "propertySignature") { | ||
const { name, property, required, description } = item; | ||
return { | ||
name: name, | ||
type: GeneralType(property), | ||
required, | ||
description, | ||
}; | ||
} else if (item.type === "indexSignature") { | ||
const { parameters, property, required, description } = item; | ||
return { | ||
name: GeneralType(parameters), | ||
type: GeneralType(property), | ||
required, | ||
description, | ||
}; | ||
} | ||
}); | ||
}, [interfaceDeclaration]); | ||
|
||
return ( | ||
<> | ||
<h3 id={interfaceDeclaration.name}> | ||
{interfaceDeclaration.name} | ||
{interfaceDeclaration.typeParameters ? ( | ||
<> | ||
{"<"} | ||
{GeneralType(interfaceDeclaration.typeParameters)} | ||
{">"} | ||
</> | ||
) : null} | ||
</h3> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Type</th> | ||
<th>Required</th> | ||
<th>Description</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{body.map((prop) => ( | ||
<tr key={prop.name}> | ||
<td> | ||
<code>{prop.name}</code> | ||
</td> | ||
<td> | ||
<MaybeEmptyCode>{prop.type}</MaybeEmptyCode> | ||
</td> | ||
<td>{prop.required}</td> | ||
<td>{prop.description}</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.