Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions doc/_stdlib_gen/stdlib-content.jsonnet
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
local html = import 'html.libsonnet';

local exampleDocMultiline(mid, ex) =
html.spaceless([
html.p({}, 'Example:'),
html.pre({}, ex.input),
html.p({}, mid),
html.pre({}, ex.output),
])
;

{
intro: html.paragraphs([
|||
Expand Down Expand Up @@ -772,7 +781,7 @@ local html = import 'html.libsonnet';
|||),
],
examples: [
{
exampleDocMultiline('Yields a string containing this JSON:', {
input: |||
std.manifestJsonEx(
{
Expand All @@ -796,8 +805,8 @@ local html = import 'html.libsonnet';
y: { a: 1, b: 2, c: [1, 2] },
}, ' '
),
},
{
}),
exampleDocMultiline('Yields a string containing this JSON:', {
input: |||
std.manifestJsonEx(
{
Expand All @@ -812,7 +821,7 @@ local html = import 'html.libsonnet';
y: { a: 1, b: [1, 2] },
}, '', ' ', ' : '
),
},
}),
],
},
{
Expand All @@ -824,7 +833,7 @@ local html = import 'html.libsonnet';
it calls <code>std.manifestJsonEx</code> with a 4-space indent:
|||,
examples: [
{
exampleDocMultiline('Yields a string containing this JSON:', {
input: |||
std.manifestJson(
{
Expand All @@ -848,7 +857,7 @@ local html = import 'html.libsonnet';
y: { a: 1, b: 2, c: [1, 2] },
}
),
},
}),
],
},
{
Expand All @@ -860,7 +869,7 @@ local html = import 'html.libsonnet';
it calls <code>std.manifestJsonEx</code>:
|||,
examples: [
{
exampleDocMultiline('Yields a string containing this JSON:', {
input: |||
std.manifestJsonMinified(
{
Expand All @@ -884,7 +893,7 @@ local html = import 'html.libsonnet';
y: { a: 1, b: 2, c: [1, 2] },
}
),
},
}),
],
},
{
Expand Down Expand Up @@ -1055,7 +1064,7 @@ local html = import 'html.libsonnet';
one or more whitespaces that are used for indentation:
|||,
examples: [
{
exampleDocMultiline('Yields a string containing this TOML file:', {
input: |||
std.manifestTomlEx({
key1: "value",
Expand Down Expand Up @@ -1094,7 +1103,7 @@ local html = import 'html.libsonnet';
],
}, ' ')
),
},
}),
],
},
],
Expand Down Expand Up @@ -1602,7 +1611,7 @@ local html = import 'html.libsonnet';
params: ['o'],
availableSince: '0.20.0',
description: |||
Returns an array of objects from the given object, each object having two fields:
Returns an array of objects from the given object, each object having two fields:
<code>key</code> (string) and <code>value</code> (object). Does not include hidden fields.
|||,
},
Expand Down
7 changes: 5 additions & 2 deletions doc/_stdlib_gen/stdlib.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ local exampleDoc(ex) =
else
html.spaceless([html.code({}, ex.input), ' yields ', html.code({}, manifestJsonSingleLine(ex.output))])
;
html.p({}, html.spaceless(['Example: ', exRep, '.']))
if std.objectHas(ex, 'type') then
ex
else
html.p({}, html.spaceless(['Example: ', exRep, '.']))
;

local hgroup(body) = html.div({ class: 'hgroup' }, body);
Expand Down Expand Up @@ -73,7 +76,7 @@ local group(group_spec, prefix) =
];

local stdlibPage = [
in_panel(html.h1({id: 'standard_library'}, 'Standard Library')),
in_panel(html.h1({ id: 'standard_library' }, 'Standard Library')),
'',
in_panel(content.intro),
'',
Expand Down
164 changes: 118 additions & 46 deletions doc/ref/stdlib.html
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,16 @@ <h3 id="math">
<ul><code>std.atan2(y, x)</code></ul>
<ul><code>std.deg2rad(x)</code></ul>
<ul><code>std.rad2deg(x)</code></ul>
<ul><code>std.hypot(a, b)</code></ul>
<ul><code>std.round(x)</code></ul>
<ul><code>std.isEven(x)</code></ul>
<ul><code>std.isOdd(x)</code></ul>
<ul><code>std.isInteger(x)</code></ul>
<ul><code>std.isDecimal(x)</code></ul>
</ul>
<p>
The constant <code>std.pi</code> is also available.
</p>
<p>
The function <code>std.mod(a, b)</code> is what the % operator is desugared to. It performs
modulo arithmetic if the left hand side is a number, or if the left hand side is a string,
Expand Down Expand Up @@ -1545,20 +1549,42 @@ <h4 id="manifestJsonEx">
of an object field:
</p>
<p>
Example: <code>std.manifestJsonEx(
{
x: [1, 2, 3, true, false, null,
"string\nstring"],
y: { a: 1, b: 2, c: [1, 2] },
}, " ")</code> yields <code>"{\n \"x\": [\n 1,\n 2,\n 3,\n true,\n false,\n null,\n \"string\\nstring\"\n ],\n \"y\": {\n \"a\": 1,\n \"b\": 2,\n \"c\": [\n 1,\n 2\n ]\n }\n}"</code>.
</p>
Example:
</p><pre>std.manifestJsonEx(
{
x: [1, 2, 3, true, false, null,
"string\nstring"],
y: { a: 1, b: 2, c: [1, 2] },
}, " ")</pre><p>
Yields a string containing this JSON:
</p><pre>{
"x": [
1,
2,
3,
true,
false,
null,
"string\nstring"
],
"y": {
"a": 1,
"b": 2,
"c": [
1,
2
]
}
}</pre>
<p>
Example: <code>std.manifestJsonEx(
{
x: [1, 2, "string\nstring"],
y: { a: 1, b: [1, 2] },
}, "", " ", " : ")</code> yields <code>"{ \"x\" : [ 1, 2, \"string\\nstring\" ], \"y\" : { \"a\" : 1, \"b\" : [ 1, 2 ] } }"</code>.
</p>
Example:
</p><pre>std.manifestJsonEx(
{
x: [1, 2, "string\nstring"],
y: { a: 1, b: [1, 2] },
}, "", " ", " : ")</pre><p>
Yields a string containing this JSON:
</p><pre>{ "x" : [ 1, 2, "string\nstring" ], "y" : { "a" : 1, "b" : [ 1, 2 ] } }</pre>
</div>
<div style="clear: both"></div>
</div>
Expand Down Expand Up @@ -1587,13 +1613,33 @@ <h4 id="manifestJson">
it calls <code>std.manifestJsonEx</code> with a 4-space indent:
</p>
<p>
Example: <code>std.manifestJson(
{
x: [1, 2, 3, true, false, null,
"string\nstring"],
y: { a: 1, b: 2, c: [1, 2] },
})</code> yields <code>"{\n \"x\": [\n 1,\n 2,\n 3,\n true,\n false,\n null,\n \"string\\nstring\"\n ],\n \"y\": {\n \"a\": 1,\n \"b\": 2,\n \"c\": [\n 1,\n 2\n ]\n }\n}"</code>.
</p>
Example:
</p><pre>std.manifestJson(
{
x: [1, 2, 3, true, false, null,
"string\nstring"],
y: { a: 1, b: 2, c: [1, 2] },
})</pre><p>
Yields a string containing this JSON:
</p><pre>{
"x": [
1,
2,
3,
true,
false,
null,
"string\nstring"
],
"y": {
"a": 1,
"b": 2,
"c": [
1,
2
]
}
}</pre>
</div>
<div style="clear: both"></div>
</div>
Expand Down Expand Up @@ -1622,13 +1668,15 @@ <h4 id="manifestJsonMinified">
it calls <code>std.manifestJsonEx</code>:
</p>
<p>
Example: <code>std.manifestJsonMinified(
{
x: [1, 2, 3, true, false, null,
"string\nstring"],
y: { a: 1, b: 2, c: [1, 2] },
})</code> yields <code>"{\"x\":[1,2,3,true,false,null,\"string\\nstring\"],\"y\":{\"a\":1,\"b\":2,\"c\":[1,2]}}"</code>.
</p>
Example:
</p><pre>std.manifestJsonMinified(
{
x: [1, 2, 3, true, false, null,
"string\nstring"],
y: { a: 1, b: 2, c: [1, 2] },
})</pre><p>
Yields a string containing this JSON:
</p><pre>{"x":[1,2,3,true,false,null,"string\nstring"],"y":{"a":1,"b":2,"c":[1,2]}}</pre>
</div>
<div style="clear: both"></div>
</div>
Expand Down Expand Up @@ -1840,24 +1888,48 @@ <h4 id="manifestTomlEx">
one or more whitespaces that are used for indentation:
</p>
<p>
Example: <code>std.manifestTomlEx({
key1: "value",
key2: 1,
section: {
a: 1,
b: "str",
c: false,
d: [1, "s", [2, 3]],
subsection: {
k: "v",
},
},
sectionArray: [
{ k: "v1", v: 123 },
{ k: "v2", c: "value2" },
],
}, " ")</code> yields <code>"key1 = \"value\"\nkey2 = 1\n\n[section]\n a = 1\n b = \"str\"\n c = false\n d = [\n 1,\n \"s\",\n [ 2, 3 ]\n ]\n\n [section.subsection]\n k = \"v\"\n\n[[sectionArray]]\n k = \"v1\"\n v = 123\n\n[[sectionArray]]\n c = \"value2\"\n k = \"v2\""</code>.
</p>
Example:
</p><pre>std.manifestTomlEx({
key1: "value",
key2: 1,
section: {
a: 1,
b: "str",
c: false,
d: [1, "s", [2, 3]],
subsection: {
k: "v",
},
},
sectionArray: [
{ k: "v1", v: 123 },
{ k: "v2", c: "value2" },
],
}, " ")</pre><p>
Yields a string containing this TOML file:
</p><pre>key1 = "value"
key2 = 1

[section]
a = 1
b = "str"
c = false
d = [
1,
"s",
[ 2, 3 ]
]

[section.subsection]
k = "v"

[[sectionArray]]
k = "v1"
v = 123

[[sectionArray]]
c = "value2"
k = "v2"</pre>
</div>
<div style="clear: both"></div>
</div>
Expand Down Expand Up @@ -3079,7 +3151,7 @@ <h4 id="objectKeysValues">
</em>
</p>
<p>
Returns an array of objects from the given object, each object having two fields:
Returns an array of objects from the given object, each object having two fields:
<code>key</code> (string) and <code>value</code> (object). Does not include hidden fields.
</p>

Expand Down
Loading