@@ -33,9 +33,9 @@ export const parseListIntoProperties = (node, prefix = '') => {
3333 const [ { children } , ...otherChildren ] = item . children ;
3434
3535 if ( children [ 0 ] . type === 'inlineCode' ) {
36- name = prefix
37- ? `${ prefix } .${ children . shift ( ) . value } `
38- : children . shift ( ) . value ;
36+ name = (
37+ prefix ? `${ prefix } .${ children . shift ( ) . value } ` : children . shift ( ) . value
38+ ) . trimEnd ( ) ;
3939 } else if ( children [ 0 ] . value && children [ 0 ] . value . startsWith ( 'Returns' ) ) {
4040 children . shift ( ) ;
4141 name = 'Returns' ;
@@ -68,7 +68,9 @@ export const parseListIntoProperties = (node, prefix = '') => {
6868
6969 const sublist = otherChildren . find ( createQueries . UNIST . isTypedList ) ;
7070 if ( sublist ) {
71- properties . push ( ...parseListIntoProperties ( sublist , name ) ) ;
71+ properties . push (
72+ ...parseListIntoProperties ( sublist , name === 'Returns' ? '_' : name )
73+ ) ;
7274 }
7375 }
7476
@@ -223,34 +225,29 @@ export const getFullName = ({ name, text }, fallback = name) => {
223225/**
224226 * Creates documentation from API metadata entries
225227 * @param {import('@types/mdast').Parent } parent - The parent node
226- * @param {ApiDocMetadataEntry[] } entries - Array of API documentation metadata entries
228+ * @param {import('@types/mdast').Heading } heading - The heading
227229 * @param {number } backupIndex - If there isn't a list, use this index
228230 * @param {boolean } addSignatureCodebox - Is this a method?
229231 */
230- export default ( parent , entries , backupIndex , addSignatureCodebox ) => {
231- // Find the list index in the parent for later replacement
232+ export default ( parent , heading , backupIndex , addSignatureCodebox ) => {
233+ // Find the list index in the parent
232234 const listIdx = parent . children . findIndex ( createQueries . UNIST . isTypedList ) ;
235+ const list = parent . children [ listIdx ] ;
233236 const elements = [ ] ;
234237
235- // Process all entries
236- for ( const entry of entries ) {
237- // Find the list in the container
238- const list = entry . content . children . find ( createQueries . UNIST . isTypedList ) ;
238+ // Create a signature code box, if this is a method/ctor.
239+ if ( addSignatureCodebox ) {
240+ const params = list ? list . children . map ( parseListItem ) : [ ] ;
239241
240- // Create a signature code box, if this is a method/ctor.
241- if ( addSignatureCodebox ) {
242- const params = list ? list . children . map ( parseListItem ) : [ ] ;
242+ const signature = parseSignature ( heading . data . text , params ) ;
243+ const displayName = getFullName ( heading . data ) ;
243244
244- const signature = parseSignature ( entry . heading . data . text , params ) ;
245- const displayName = getFullName ( entry . heading . data ) ;
246-
247- elements . push ( createSignatureCodeBlock ( displayName , signature ) ) ;
248- }
245+ elements . push ( createSignatureCodeBlock ( displayName , signature ) ) ;
246+ }
249247
250- // Create property table if a list exists
251- if ( list ) {
252- elements . push ( createPropertyTable ( list ) ) ;
253- }
248+ // Create property table if a list exists
249+ if ( list ) {
250+ elements . push ( createPropertyTable ( list ) ) ;
254251 }
255252
256253 // Replace the list in the parent with all collected elements
0 commit comments