Skip to content

Commit

Permalink
feat: add doc for std.parseCsv and std.manifestCsv
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitjangid committed Jun 7, 2023
1 parent 8ea27ab commit 384db39
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions doc/_stdlib_gen/stdlib-content.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,20 @@ local html = import 'html.libsonnet';
},
],
},
{
name: 'parseCsv',
params: ['str', 'delimiter=","'],
availableSince: 'upcoming',
description: |||
Parses a CSV string into JSON.
|||,
examples: [
{
input: "std.parseCsv('id,name\n1,foo\n2,bar')",
output: std.parseCsv('id,name\n1,foo\n2,bar'),
},
],
},
{
name: 'encodeUTF8',
params: ['str'],
Expand Down Expand Up @@ -995,6 +1009,45 @@ local html = import 'html.libsonnet';
|||),
],
},
{
name: 'manifestCsv',
params: ['json', 'headers=null'],
availableSince: 'upcoming',
description: [
html.p({}, |||
Convert the given csv compatible json to a CSV.
|||),
html.pre({}, |||
std.manifestCsv(
[
{
"id": 1,
"name": "foo",
"x": "baz",
},
{
"id": 2,
"name": "bar",
},
],
["id", "name"],
|||),
html.p({}, |||
Yields a string containing this CSV:
|||),
html.pre({}, |||
id,name
1,foo
2,bar
|||),
html.p({}, |||
If <code>json</code> param is not a valid csv compatible object, it would be an error.
|||),
html.p({}, |||
The <code>headers</code> param adds is an optional which would default to all fields in the object.
|||),
],
},
{
name: 'manifestXmlJsonml',
params: ['value'],
Expand Down

0 comments on commit 384db39

Please sign in to comment.