Skip to content

Commit a5c6a5a

Browse files
committed
feat: add doc for std.parseCsv and std.manifestCsv
1 parent 5a9d395 commit a5c6a5a

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

doc/_stdlib_gen/stdlib-content.jsonnet

+53
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,20 @@ local html = import 'html.libsonnet';
618618
},
619619
],
620620
},
621+
{
622+
name: 'parseCsv',
623+
params: ['str', 'delimiter=","'],
624+
availableSince: 'upcoming',
625+
description: |||
626+
Parses a CSV string into JSON.
627+
|||,
628+
examples: [
629+
{
630+
input: "std.parseCsv('id,name\n1,foo\n2,bar')",
631+
output: std.parseCsv('id,name\n1,foo\n2,bar'),
632+
},
633+
],
634+
},
621635
{
622636
name: 'encodeUTF8',
623637
params: ['str'],
@@ -932,6 +946,45 @@ local html = import 'html.libsonnet';
932946
|||),
933947
],
934948
},
949+
{
950+
name: 'manifestCsv',
951+
params: ['json', 'headers=null'],
952+
availableSince: 'upcoming',
953+
description: [
954+
html.p({}, |||
955+
Convert the given csv compatible json to a CSV.
956+
|||),
957+
html.pre({}, |||
958+
std.manifestCsv(
959+
[
960+
{
961+
"id": 1,
962+
"name": "foo",
963+
"x": "baz",
964+
},
965+
{
966+
"id": 2,
967+
"name": "bar",
968+
},
969+
],
970+
["id", "name"],
971+
|||),
972+
html.p({}, |||
973+
Yields a string containing this CSV:
974+
|||),
975+
html.pre({}, |||
976+
id,name
977+
1,foo
978+
2,bar
979+
|||),
980+
html.p({}, |||
981+
If <code>json</code> param is not a valid csv compatible object, it would be an error.
982+
|||),
983+
html.p({}, |||
984+
The <code>headers</code> param adds is an optional which would default to all fields in the object.
985+
|||),
986+
],
987+
},
935988
{
936989
name: 'manifestXmlJsonml',
937990
params: ['value'],

0 commit comments

Comments
 (0)