[react] feat: Added docs for components/Yaml
This commit is contained in:
parent
0a345b3347
commit
54fe6275af
4 changed files with 52 additions and 4 deletions
|
@ -3,6 +3,18 @@ import { Highlight } from '@freesewing/react/components/Highlight'
|
||||||
import hljs from 'highlight.js/lib/common'
|
import hljs from 'highlight.js/lib/common'
|
||||||
import yaml from 'js-yaml'
|
import yaml from 'js-yaml'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A component to code-highlight YAML data
|
||||||
|
*
|
||||||
|
* @component
|
||||||
|
* @param {object} props - All component props
|
||||||
|
* @param {JSX.Element} props.children - Use this if you are not using props.json or props.js to pass the YAML data
|
||||||
|
* @param {object} [props.js = undefined] - Use this to pass the YAML data as Javascript Object
|
||||||
|
* @param {string} [props.json = undefined] - Use this to pass the YAML data as JSON
|
||||||
|
* @param {bool} [props.noCopy = false] - Set this to true to not add the copy to clipboard button
|
||||||
|
* @param {string} [props.title = "YAML"] - Title for the highlight
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
export const Yaml = (props) => {
|
export const Yaml = (props) => {
|
||||||
let code
|
let code
|
||||||
if (props.json) code = yaml.dump(JSON.parse(props.json))
|
if (props.json) code = yaml.dump(JSON.parse(props.json))
|
||||||
|
@ -11,8 +23,8 @@ export const Yaml = (props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Highlight
|
<Highlight
|
||||||
{...props}
|
|
||||||
language="yaml"
|
language="yaml"
|
||||||
|
{...props}
|
||||||
raw={hljs.highlight(code, { language: 'yaml' }).value}
|
raw={hljs.highlight(code, { language: 'yaml' }).value}
|
||||||
copy={code}
|
copy={code}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -42,3 +42,4 @@ jsdoc -c jsdoc.json components/Time/* > ../../sites/dev/prebuild/jsdoc/react/com
|
||||||
jsdoc -c jsdoc.json components/Uuid/* > ../../sites/dev/prebuild/jsdoc/react/components/uuid.json
|
jsdoc -c jsdoc.json components/Uuid/* > ../../sites/dev/prebuild/jsdoc/react/components/uuid.json
|
||||||
jsdoc -c jsdoc.json components/Ux/* > ../../sites/dev/prebuild/jsdoc/react/components/ux.json
|
jsdoc -c jsdoc.json components/Ux/* > ../../sites/dev/prebuild/jsdoc/react/components/ux.json
|
||||||
jsdoc -c jsdoc.json components/Xray/* > ../../sites/dev/prebuild/jsdoc/react/components/xray.json
|
jsdoc -c jsdoc.json components/Xray/* > ../../sites/dev/prebuild/jsdoc/react/components/xray.json
|
||||||
|
jsdoc -c jsdoc.json components/Yaml/* > ../../sites/dev/prebuild/jsdoc/react/components/yaml.json
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import React from 'react'
|
||||||
|
import { Yaml } from '@freesewing/react/components/Yaml'
|
||||||
|
|
||||||
|
export const YamlExample = () => <Yaml js={{
|
||||||
|
some: 'yaml',
|
||||||
|
data: 'here',
|
||||||
|
more: {
|
||||||
|
things: {
|
||||||
|
like: ['an', 'array'],
|
||||||
|
or: {
|
||||||
|
a: {
|
||||||
|
number: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}} />
|
||||||
|
|
|
@ -2,6 +2,23 @@
|
||||||
title: Yaml
|
title: Yaml
|
||||||
---
|
---
|
||||||
|
|
||||||
:::note
|
import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus'
|
||||||
This page is yet to be created
|
import { ComponentDocs } from '@site/src/components/component-docs.js'
|
||||||
:::
|
import * as jsdoc from '@site/prebuild/jsdoc/components.yaml.mjs'
|
||||||
|
import { YamlExample } from './_examples.js'
|
||||||
|
|
||||||
|
<DocusaurusDoc>
|
||||||
|
|
||||||
|
- [Components](#components)
|
||||||
|
|
||||||
|
## Components
|
||||||
|
|
||||||
|
The **Yaml** component family provides the following components:
|
||||||
|
|
||||||
|
- [Yaml](#yaml)
|
||||||
|
|
||||||
|
### Yaml
|
||||||
|
|
||||||
|
<ComponentDocs docs={jsdoc.jsdocYaml} example={YamlExample} />
|
||||||
|
|
||||||
|
</DocusaurusDoc>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue