Skip to content
Snippets Groups Projects
Unverified Commit 97fd4b88 authored by Tobias's avatar Tobias Committed by GitHub
Browse files

docs: render default objects and arrays in config (#15637)

parent 9afdb739
No related merge requests found
......@@ -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);
}
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment