Skip to content

Commit 6ac6c69

Browse files
authored
fix(render): manifest parameters on a single line (#58)
* fix(render): manifest parameters on a single line * fix(render): only show a certain type once
1 parent 503e5c8 commit 6ac6c69

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

doc-util/render.libsonnet

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@
295295
then std.get(arg.schema, 'type', '')
296296
else std.get(arg, 'type', '');
297297
if std.isArray(type)
298-
then std.join(',', [t for t in type])
299-
else type,
298+
then std.join(',', ['`%s`' % t for t in std.set(type)])
299+
else '`%s`' % type,
300300

301301
// Use BelRune as default can be 'null' as a value. Only supported for arg.schema, arg.default didn't support this, not sure how to support without breaking asssumptions downstream.
302302
local BelRune = std.char(7),
@@ -318,13 +318,16 @@
318318
then []
319319
else d,
320320

321+
local manifest(value) =
322+
std.manifestJsonEx(value, '', '', ': '),
323+
321324
args:
322325
std.join(', ', [
323326
local default = getDefault(arg);
324327
if default != BelRune
325328
then std.join('=', [
326329
arg.name,
327-
std.manifestJson(default),
330+
manifest(default),
328331
])
329332
else arg.name
330333
for arg in doc['function'].args
@@ -336,11 +339,11 @@
336339
then
337340
'\nPARAMETERS:\n\n'
338341
+ std.join('\n', [
339-
'* **%s** (`%s`)' % [arg.name, getType(arg)]
342+
'* **%s** (%s)' % [arg.name, getType(arg)]
340343
+ (
341344
local default = getDefault(arg);
342345
if default != BelRune
343-
then '\n - default value: `%s`' % std.manifestJson(default)
346+
then '\n - default value: `%s`' % manifest(default)
344347
else ''
345348
)
346349
+ (
@@ -349,7 +352,7 @@
349352
then
350353
'\n - valid values: %s' %
351354
std.join(', ', [
352-
'`%s`' % std.manifestJson(item)
355+
'`%s`' % manifest(item)
353356
for item in enum
354357
])
355358
else ''

0 commit comments

Comments
 (0)