1
- import React , { useState , useEffect , useRef , ReactNode } from "react" ;
1
+ import React , { useState , useEffect , useRef , ReactNode } from "react" ;
2
2
import ReactMarkdown from "react-markdown" ;
3
3
import style from "@site/src/css/markdown-styles.module.css" ;
4
4
import yaml from "js-yaml" ;
@@ -8,11 +8,11 @@ import useBrokenLinks from "@docusaurus/core/lib/client/exports/useBrokenLinks";
8
8
import Admonition from "@theme/Admonition" ;
9
9
import clsx from "clsx" ;
10
10
11
- const createUrlHash = ( parent : string | number , name : any ) : string => {
11
+ const createUrlHash = ( parent : string | number , name : any ) : string => {
12
12
return parent + ( parent ? "_" : "" ) + parseUrlHash ( name ) ;
13
13
} ;
14
14
15
- const parseUrlHash = ( name : string ) : string => {
15
+ const parseUrlHash = ( name : string ) : string => {
16
16
return name . replace ( / - / g, "_" ) ;
17
17
} ;
18
18
@@ -48,14 +48,21 @@ const copyAndScroll = (parentKey: string, name: string): void => {
48
48
console . error ( "Failed to copy to clipboard: " , error ) ;
49
49
} ) ;
50
50
scrollIntoView ( hash ) ;
51
- }
51
+ } ;
52
52
53
- const parseDefault = ( value : string , collapse : boolean , parentKey : string , name : string , handleHashLinkClick , separator : string ) : ReactNode => {
53
+ const parseDefault = (
54
+ value : string ,
55
+ collapse : boolean ,
56
+ parentKey : string ,
57
+ name : string ,
58
+ handleHashLinkClick ,
59
+ separator : string
60
+ ) : ReactNode => {
54
61
const hash = createUrlHash ( parentKey , name ) ;
55
62
useBrokenLinks ( ) . collectAnchor ( hash ) ;
56
63
57
64
if ( value [ 0 ] === "[" && value [ value . length - 1 ] === "]" ) {
58
- const items : ( string | ReactNode ) [ ] = value
65
+ const items : ( string | ReactNode ) [ ] = value
59
66
. replace ( "[" , "" )
60
67
. replace ( "]" , "" )
61
68
. split ( "," )
@@ -100,7 +107,7 @@ const parseDefault = (value: string, collapse: boolean, parentKey: string, name:
100
107
) ;
101
108
} ;
102
109
103
- const parseItalics = ( key : string ) => {
110
+ const parseItalics = ( key : string ) => {
104
111
if ( key . startsWith ( "<" ) && key . endsWith ( ">" ) ) {
105
112
return (
106
113
< >
@@ -116,14 +123,14 @@ const parseDescriptionForVersioning = (description: String) => {
116
123
} ;
117
124
118
125
const YamlNodeWithDescription = ( {
119
- name,
120
- node,
121
- parentKey,
122
- root,
123
- separator,
124
- showAllDescriptions,
125
- defaultValue,
126
- } ) => {
126
+ name,
127
+ node,
128
+ parentKey,
129
+ root,
130
+ separator,
131
+ showAllDescriptions,
132
+ defaultValue,
133
+ } ) => {
127
134
const ignoreInitialRenderRef = useRef ( false ) ;
128
135
const [ showDescription , setShowDescription ] = useState ( showAllDescriptions ) ;
129
136
@@ -204,15 +211,15 @@ const YamlNodeWithDescription = ({
204
211
} ;
205
212
206
213
const YamlTreeNode = ( {
207
- root,
208
- name,
209
- parentKey,
210
- value,
211
- separator,
212
- showAllDescriptions,
213
- defaultValue,
214
- warning,
215
- } ) : ReactNode => {
214
+ root,
215
+ name,
216
+ parentKey,
217
+ value,
218
+ separator,
219
+ showAllDescriptions,
220
+ defaultValue,
221
+ warning,
222
+ } ) : ReactNode => {
216
223
if ( name === "inline-docs-warning" ) return null ;
217
224
218
225
const handleClick = ( event ) => {
@@ -280,7 +287,7 @@ const renderYamlData = (
280
287
separator : string ,
281
288
showAllDescriptions : boolean ,
282
289
defaultValue : string
283
- ) : ReactNode => {
290
+ ) : ReactNode => {
284
291
const renderedNodes : JSX . Element [ ] = [ ] ;
285
292
286
293
for ( const [ key , value ] of Object . entries ( data ) ) {
@@ -323,11 +330,11 @@ const renderYamlData = (
323
330
} ;
324
331
325
332
export default function Config ( {
326
- data,
327
- separator = ": " ,
328
- showDescriptions = false ,
329
- defaultValue = "N/A" ,
330
- } ) : ReactNode {
333
+ data,
334
+ separator = ": " ,
335
+ showDescriptions = false ,
336
+ defaultValue = "N/A" ,
337
+ } ) : ReactNode {
331
338
const [ showAllDescriptions , setShowAllExpanded ] = useState ( showDescriptions ) ;
332
339
let ymlData = yaml . load ( data ) ;
333
340
return (
0 commit comments