From 0b5b0f5b8bca882c16181c6bd085a948c3513774 Mon Sep 17 00:00:00 2001 From: almostSouji Date: Sun, 10 Nov 2024 17:01:10 +0100 Subject: [PATCH] feat(docs): add default values for field members * Not implementing signatures as some option types are very convoluted which introduces a lot of visual noise in Discord channels resolves #226 --- src/functions/docs.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/functions/docs.ts b/src/functions/docs.ts index 50aa71c..750e0b0 100644 --- a/src/functions/docs.ts +++ b/src/functions/docs.ts @@ -259,8 +259,10 @@ function formatItem(_item: any, _package: string, version: string, member?: stri const lines: string[] = [[head, middlePart, tail].join(' ')]; const summary = item.summary?.summarySection; + const defaultValueBlock = item.summary?.defaultValueBlock; const deprecationNote = item.summary?.deprecatedBlock; const example = formatExample(item.summary?.exampleBlocks); + const defaultValue = defaultValueBlock ? formatSummary(defaultValueBlock, _package, version) : null; if (deprecationNote?.length) { lines.push(`${bold('[DEPRECATED]')} ${formatSummary(deprecationNote, _package, version)}`); @@ -274,6 +276,10 @@ function formatItem(_item: any, _package: string, version: string, member?: stri } } + if (defaultValue?.length) { + lines.push(`Default value: ${inlineCode(defaultValue)}`); + } + return lines.join('\n'); }