@@ -12,7 +12,7 @@ import {
1212 jsDocsToReferences ,
1313 jsDocsToReturnType
1414} from './jdocs/mapper' ;
15- import { inlineReferences } from './jdocs /render' ;
15+ import { emojiTitle , metadataToMarkdown , sourceCodeLink } from './render' ;
1616import type { Params , Row } from './types' ;
1717
1818const toParams = ( parameters ?: DocEntry [ ] ) : Params [ ] =>
@@ -180,12 +180,6 @@ const interfacesToMarkdown = ({
180180 return markdown . join ( '\n' ) ;
181181} ;
182182
183- const sourceCodeLink = ( {
184- url,
185- emoji
186- } : Pick < MarkdownOptions , 'emoji' > & Required < Pick < DocEntry , 'url' > > ) : string =>
187- `[${ emojiTitle ( { emoji, key : 'link' } ) . trim ( ) } ${ emoji !== null && emoji !== undefined ? ' ' : '' } Source](${ url } )\n` ;
188-
189183// Avoid issue if the Markdown table gets formatted with Prettier
190184const parseType = ( type : string ) : string =>
191185 type
@@ -248,26 +242,15 @@ const toMarkdown = ({
248242 markdown . push ( '\n' ) ;
249243 }
250244
251- if ( returnType !== undefined && returnType !== '' ) {
252- markdown . push ( `Returns:\n` ) ;
253- markdown . push ( `${ returnType } \n` ) ;
254- }
245+ const metadata = metadataToMarkdown ( {
246+ returnType,
247+ references,
248+ examples,
249+ url,
250+ emoji
251+ } ) ;
255252
256- if ( references ?. length ) {
257- markdown . push ( `References:\n` ) ;
258- markdown . push ( ...inlineReferences ( references ) ) ;
259- markdown . push ( '\n' ) ;
260- }
261-
262- if ( examples . length ) {
263- markdown . push ( 'Examples:\n' ) ;
264- markdown . push ( ...examples ) ;
265- markdown . push ( '\n' ) ;
266- }
267-
268- if ( url !== undefined ) {
269- markdown . push ( sourceCodeLink ( { emoji, url} ) ) ;
270- }
253+ markdown . push ( ...metadata ) ;
271254
272255 return markdown . join ( '\n' ) ;
273256 } ;
@@ -290,14 +273,6 @@ const tableOfContent = ({
290273 )
291274 . join ( '\n' ) ;
292275
293- const emojiTitle = ( {
294- emoji,
295- key
296- } : {
297- key : keyof MarkdownEmoji ;
298- } & Pick < MarkdownOptions , 'emoji' > ) : string =>
299- emoji === undefined || emoji === null ? '' : ` :${ emoji [ key ] } :` ;
300-
301276const DEFAULT_EMOJI : MarkdownEmoji = {
302277 classes : 'factory' ,
303278 functions : 'toolbox' ,
0 commit comments