@@ -20,7 +20,8 @@ function formatCallbackType( callbackDoc, callbackMap ) {
2020 ? formatType ( callbackDoc . returns [ 0 ] . type , callbackMap )
2121 : 'void' ;
2222
23- return `( ${ params . join ( ', ' ) } ) => ${ ret } ` ;
23+ const sig = params . length > 0 ? ` ${ params . join ( ', ' ) } ` : '' ;
24+ return `(${ sig } ) => ${ ret } ` ;
2425
2526}
2627
@@ -63,12 +64,36 @@ export function renderConstructor( classDoc, callbackMap = {} ) {
6364 const topLevel = ( classDoc . params || [ ] ) . filter ( p => ! p . name . includes ( '.' ) ) ;
6465 const options = ( classDoc . params || [ ] ) . filter ( p => p . name . includes ( '.' ) ) ;
6566
66- const sig = topLevel . map ( p => formatParam ( p , callbackMap ) ) . join ( ', ' ) ;
67+ // When there is exactly one top-level param and nested option fields, render the
68+ // options inline as a destructured object rather than as a separate bullet list.
69+ const isOptionsObject = topLevel . length === 1 && options . length > 0 ;
6770
6871 lines . push ( '### .constructor' ) ;
6972 lines . push ( '' ) ;
7073 lines . push ( '```js' ) ;
71- lines . push ( `constructor( ${ sig } )` ) ;
74+
75+ if ( isOptionsObject ) {
76+
77+ lines . push ( 'constructor( {' ) ;
78+ for ( const param of options ) {
79+
80+ const name = param . name . split ( '.' ) . pop ( ) ;
81+ const type = formatType ( param . type , callbackMap ) ;
82+ const defStr = param . defaultvalue !== undefined ? ` = ${ param . defaultvalue } ` : '' ;
83+ const optional = param . optional && param . defaultvalue === undefined ? '?' : '' ;
84+ lines . push ( `\t${ name } ${ defStr } ${ optional } : ${ type } ,` ) ;
85+
86+ }
87+
88+ lines . push ( '} )' ) ;
89+
90+ } else {
91+
92+ const sig = topLevel . map ( p => formatParam ( p , callbackMap ) ) . join ( ', ' ) ;
93+ lines . push ( `constructor( ${ sig } )` ) ;
94+
95+ }
96+
7297 lines . push ( '```' ) ;
7398 lines . push ( '' ) ;
7499
@@ -80,8 +105,8 @@ export function renderConstructor( classDoc, callbackMap = {} ) {
80105
81106 }
82107
83- // Render nested options (e.g. options.layer, options.url) as a list
84- if ( options . length > 0 ) {
108+ // Bullet list only used for the non- options-object case (e.g. mixed positional + nested params)
109+ if ( ! isOptionsObject && options . length > 0 ) {
85110
86111 for ( const param of options ) {
87112
0 commit comments