77 summary ,
88} from '@/lib/versioned-docs'
99
10+ // matches: "name: desc" "name (type): desc" "name : type"
11+ const PARAM_RE = / ^ ( [ A - Z a - z _ ] \w * ) \s * (?: \( [ ^ ) ] * \) ) ? \s * : \s * ( .+ ) /
12+
1013function DocText ( { value } : { value : string } ) {
1114 if ( ! value ) return null
1215 const lines = value . split ( '\n' )
@@ -22,33 +25,42 @@ function DocText({ value }: { value: string }) {
2225 for ( let index = 0 ; index < lines . length ; index += 1 ) {
2326 const line = lines [ index ] . trim ( )
2427 const next = lines [ index + 1 ] ?. trim ( ) || ''
28+
2529 if ( line && / ^ - { 3 , } $ / . test ( next ) ) {
2630 flushParagraph ( )
27- blocks . push ( < h4 key = { `h-${ blocks . length } ` } > { line } </ h4 > )
31+ blocks . push ( < h4 key = { `h-${ blocks . length } ` } > { line . replace ( / : $ / , '' ) } </ h4 > )
2832 index += 1
2933 continue
3034 }
31- if ( ! line ) {
32- flushParagraph ( )
33- continue
34- }
35- if ( / ^ [ A - Z a - z _ ] [ \w , ] * \s * : \s * .+ / . test ( line ) ) {
35+ if ( ! line ) { flushParagraph ( ) ; continue }
36+
37+ // strip leading bullet (• or -) then try to match as a named parameter
38+ const isBullet = / ^ [ • \- ] / . test ( line )
39+ const inner = isBullet ? line . replace ( / ^ [ • \- ] \s * / , '' ) : line
40+ const m = PARAM_RE . exec ( inner )
41+
42+ if ( m ) {
3643 flushParagraph ( )
37- const [ name , ...typeParts ] = line . split ( ':' )
3844 blocks . push (
3945 < div className = "docParameter" key = { `d-${ blocks . length } ` } >
40- < code > { name . trim ( ) } </ code >
41- < span > { typeParts . join ( ':' ) . trim ( ) } </ span >
46+ < code > { m [ 1 ] } </ code >
47+ < span > { m [ 2 ] . trim ( ) } </ span >
4248 </ div > ,
4349 )
4450 continue
4551 }
52+
53+ // plain bullet with no name:desc pattern → list item
54+ if ( isBullet ) {
55+ flushParagraph ( )
56+ blocks . push ( < li key = { `li-${ blocks . length } ` } > { inner } </ li > )
57+ continue
58+ }
59+
4660 paragraph . push ( line )
4761 }
4862 flushParagraph ( )
49- return (
50- < div className = "docText" > { blocks . slice ( 0 , 80 ) } </ div >
51- )
63+ return < div className = "docText" > { blocks . slice ( 0 , 80 ) } </ div >
5264}
5365
5466export default async function ModuleReference ( {
0 commit comments