Skip to content

Commit a8bebc3

Browse files
committed
feat: add doc for std.parseCsv and std.manifestCsv
1 parent 8ea27ab commit a8bebc3

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
@@ -681,6 +681,20 @@ local html = import 'html.libsonnet';
681681
},
682682
],
683683
},
684+
{
685+
name: 'parseCsv',
686+
params: ['str'],
687+
availableSince: 'upcoming',
688+
description: |||
689+
Parses a CSV string into JSON.
690+
|||,
691+
examples: [
692+
{
693+
input: "std.parseCsv('id,name\n1,foo\n2,bar')",
694+
output: std.parseCsv('id,name\n1,foo\n2,bar'),
695+
},
696+
],
697+
},
684698
{
685699
name: 'encodeUTF8',
686700
params: ['str'],
@@ -995,6 +1009,45 @@ local html = import 'html.libsonnet';
9951009
|||),
9961010
],
9971011
},
1012+
{
1013+
name: 'manifestCsv',
1014+
params: ['json', 'headers=null'],
1015+
availableSince: 'upcoming',
1016+
description: [
1017+
html.p({}, |||
1018+
Convert the given csv compatible json to a CSV.
1019+
|||),
1020+
html.pre({}, |||
1021+
std.manifestCsv(
1022+
[
1023+
{
1024+
"id": 1,
1025+
"name": "foo",
1026+
"x": "baz",
1027+
},
1028+
{
1029+
"id": 2,
1030+
"name": "bar",
1031+
},
1032+
],
1033+
["id", "name"],
1034+
|||),
1035+
html.p({}, |||
1036+
Yields a string containing this CSV:
1037+
|||),
1038+
html.pre({}, |||
1039+
id,name
1040+
1,foo
1041+
2,bar
1042+
|||),
1043+
html.p({}, |||
1044+
If <code>json</code> param is not a valid csv compatible object, it would be an error.
1045+
|||),
1046+
html.p({}, |||
1047+
The <code>headers</code> param adds is an optional which would default to all fields in the object.
1048+
|||),
1049+
],
1050+
},
9981051
{
9991052
name: 'manifestXmlJsonml',
10001053
params: ['value'],

0 commit comments

Comments
 (0)