@@ -16,8 +16,57 @@ import {
1616} from '@elastic/eui-docgen' ;
1717import { useCallback , useMemo } from 'react' ;
1818import { css } from '@emotion/react' ;
19- import { PropTableExtendedTypes } from './extended_types' ;
2019import Heading from '@theme/Heading' ;
20+ import types from '@elastic/eui-docgen/dist/types.json' ;
21+
22+ import { PropTableExtendedTypes } from './extended_types' ;
23+
24+ export interface Source {
25+ fileName : string ;
26+ line : number ;
27+ character : number ;
28+ url : string ;
29+ }
30+
31+ export interface Child {
32+ id : number ;
33+ name : string ;
34+ variant : string ;
35+ kind : number ;
36+ flags : Record < string , unknown > ;
37+ children ?: Child [ ] ;
38+ groups ?: Group [ ] ;
39+ sources ?: Source [ ] ;
40+ type ?: {
41+ type : string ;
42+ types ?: { type : string ; value ?: string } [ ] ;
43+ declaration ?: Record < string , unknown > ;
44+ target ?: { qualifiedName : string } ;
45+ name ?: string ;
46+ package ?: string ;
47+ } ;
48+ defaultValue ?: string ;
49+ }
50+
51+ export interface Group {
52+ title : string ;
53+ children : number [ ] ;
54+ }
55+
56+ export interface Types {
57+ schemaVersion : string ;
58+ id : number ;
59+ name : string ;
60+ variant : string ;
61+ kind : number ;
62+ flags : Record < string , unknown > ;
63+ children : Child [ ] ;
64+ groups : Group [ ] ;
65+ packageName : string ;
66+ readme : unknown [ ] ;
67+ symbolIdMap : Record < string , unknown > ;
68+ files : Record < string , unknown > ;
69+ }
2170
2271export interface PropTableProps {
2372 definition : ProcessedComponent ;
@@ -136,15 +185,30 @@ export const PropTable = ({
136185 value : ProcessedComponentProp [ 'description' ] ,
137186 prop : ProcessedComponentProp
138187 ) {
188+ const result = value
189+ . replace ( / { @ l i n k ( \w + ) } / g, ( _ , componentName ) => {
190+ const componentSource = ( types as Types ) . children . find (
191+ ( item ) => item . name === componentName
192+ ) ?. sources ?. [ 0 ] ;
193+
194+ if ( componentSource ) {
195+ const { fileName, line } = componentSource ;
196+ return `[${ componentName } ](https://github.com/elastic/eui/tree/main/packages/${ fileName } #L${ line } )` ;
197+ } else {
198+ return `\`${ componentName } \`` ;
199+ }
200+ } )
201+ . trim ( ) ;
202+
139203 return (
140204 < EuiFlexGroup
141205 direction = "column"
142206 alignItems = "flexStart"
143207 gutterSize = "s"
144208 >
145- { value ?. trim ( ) && (
209+ { result && (
146210 < EuiMarkdownFormat css = { styles . description } >
147- { value }
211+ { result }
148212 </ EuiMarkdownFormat >
149213 ) }
150214 { prop . type && (
0 commit comments