on 448bfaf help sign in
88 lines 7.8 kB history raw
1local html = import 'html.libsonnet';
2local jekyll = import 'jekyll.libsonnet';
3local content = import 'stdlib-content.jsonnet';
5local
6 h1 = html.h1,
7 p = html.p;
9local manifestJsonSingleLine(val) = std.strReplace(std.manifestJsonEx(val, ''), '\n', ' ');
11local exampleDoc(ex) =
12 local exRep =
13 if std.isString(ex) then
14 ex
15 else
16 html.spaceless([html.code({}, ex.input), ' yields ', html.code({}, manifestJsonSingleLine(ex.output))])
17 ;
18 html.p({}, html.spaceless(['Example: ', exRep, '.']))
19;
21local hgroup(body) = html.div({ class: 'hgroup' }, body);
22local hgroup_inline(body) = html.div({ class: 'hgroup-inline' }, [body, '<div style="clear: both"></div>']);
23local panel(body) = html.div({ class: 'panel' }, body);
25local in_panel(body) = hgroup(hgroup_inline(panel(body)));
27local fieldParams(f) =
28 if std.objectHas(f, 'params') then
29 '(' + std.join(', ', f.params) + ')'
30 else
31 ''
32;
34local fieldDescription(f) =
35 if std.isString(f.description) then
36 html.p({}, f.description)
37 else
38 f.description
39;
41local fieldDoc(f, prefix) =
42 [
43 in_panel(html.h4({ id: f.name }, prefix + '.' + f.name + fieldParams(f))),
44 in_panel([
45 if std.objectHas(f, 'availableSince') then (
46 html.p(
47 {},
48 html.em(
49 {},
50 if f.availableSince == 'upcoming' then
51 'Available in upcoming release.'
52 else
53 'Available since version ' + f.availableSince + '.'
54 )
55 )
56 ),
57 fieldDescription(f),
58 if std.objectHas(f, 'examples') then [
59 exampleDoc(ex)
60 for ex in f.examples
61 ] else [],
62 ]),
63 '',
64 ];
66local group(group_spec, prefix) =
67 [
68 in_panel(html.h3({ id: group_spec.id }, group_spec.name)),
69 if std.objectHas(group_spec, 'intro') then in_panel(group_spec.intro),
70 '',
71 [fieldDoc(f, prefix) for f in group_spec.fields],
72 '',
73 ];
75local stdlibPage = [
76 in_panel(html.h1({id: 'standard_library'}, 'Standard Library')),
77 '',
78 in_panel(content.intro),
79 '',
80 [group(g, content.prefix) for g in content.groups],
81];
83local stdlibFrontMatter = {
84 layout: 'default',
85 title: 'Standard Library',
86};
88jekyll.renderWithFrontMatter(stdlibFrontMatter, stdlibPage)