From a8bebc31ea286a98ff09209484a7737eb9f516d1 Mon Sep 17 00:00:00 2001 From: Rohit Jangid Date: Thu, 25 May 2023 11:29:17 +0530 Subject: [PATCH] feat: add doc for std.parseCsv and std.manifestCsv --- doc/_stdlib_gen/stdlib-content.jsonnet | 53 ++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/doc/_stdlib_gen/stdlib-content.jsonnet b/doc/_stdlib_gen/stdlib-content.jsonnet index 40de10df5..2570674f7 100644 --- a/doc/_stdlib_gen/stdlib-content.jsonnet +++ b/doc/_stdlib_gen/stdlib-content.jsonnet @@ -681,6 +681,20 @@ local html = import 'html.libsonnet'; }, ], }, + { + name: 'parseCsv', + params: ['str'], + 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'], @@ -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 json param is not a valid csv compatible object, it would be an error. + |||), + html.p({}, ||| + The headers param adds is an optional which would default to all fields in the object. + |||), + ], + }, { name: 'manifestXmlJsonml', params: ['value'],