From 97fd4b884c4989cdac61bd9feb13e727d16e7e11 Mon Sep 17 00:00:00 2001 From: Tobias <tobias.gabriel@sap.com> Date: Thu, 19 May 2022 09:06:22 +0200 Subject: [PATCH] docs: render default objects and arrays in config (#15637) --- tools/docs/config.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/docs/config.ts b/tools/docs/config.ts index ff93ea7ae7..7d1dc26bc7 100644 --- a/tools/docs/config.ts +++ b/tools/docs/config.ts @@ -28,7 +28,12 @@ function genTable(obj: [string, string][], type: string, def: any): string { } if ( !ignoredKeys.includes(el[0]) || - (el[0] === 'default' && typeof el[1] !== 'object' && name !== 'prBody') + (el[0] === 'default' && typeof el[1] !== 'object' && name !== 'prBody') || + // only show array and object defaults if they are not null and are not empty + (el[0] === 'default' && + (type === 'array' || type === 'object') && + el[1] !== null && + Object.keys(el[1]).length > 0) ) { if (type === 'string' && el[0] === 'default') { el[1] = `\`"${el[1]}"\``; @@ -43,6 +48,10 @@ function genTable(obj: [string, string][], type: string, def: any): string { if (type === 'string' && el[0] === 'default' && el[1].length > 200) { el[1] = `[template]`; } + // objects and arrays should be printed in JSON notation + if ((type === 'object' || type === 'array') && el[0] === 'default') { + el[1] = `\`${JSON.stringify(el[1])}\``; + } data.push(el); } }); -- GitLab