1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205
|
---
layout: default
title: Tooling
---
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<h1 id="tooling">Tooling</h1>
</div>
<div style="clear: both"></div>
</div>
</div>
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<p>
Aside from the Jsonnet interpreters (which execute the Jsonnet code) these additional
software tools allow you to get the most out of Jsonnet:
</p>
<ul>
<li>Formatter, for automatically fixing stylistic problems</li>
<li>Linter, for drawing attention to red flags that cannot be fixed automatically</li>
<li>Bazel rules, for config generation as part of your build system</li>
<li>
Editor integration for syntax highlighting and other features
<ul>
<li>
<a href="https://heptio.com">Heptio</a> maintain a <a
href="https://github.com/heptio/vscode-jsonnet">vscode</a> extension with quite
sophisticated program analysis
</li>
<li>
<a href="https://github.com/google/vim-jsonnet">Vim</a>
</li>
<li>
<a href="https://github.com/google/codemirror-mode-jsonnet">Codemirror,</a> the editor
widget used by this website
</li>
<li>
<a href="https://github.com/google/language-jsonnet">Atom</a>
</li>
<li>
<a href="https://github.com/gburiola/sublime-jsonnet-syntax">Sublime</a>
</li>
<li>
<a href="https://databricks.com/">Databricks</a> maintain an <a
href="https://github.com/databricks/intellij-jsonnet">IntelliJ</a> plugin with jump to
imported files and local variables.
</li>
<li>
An <a href="https://github.com/tminor/jsonnet-mode">Emacs mode</a> is also available.
</li>
</ul>
</li>
</ul>
</div>
<div style="clear: both"></div>
</div>
</div>
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<h2 id="formatter">Formatter Demo</h2>
</div>
<div style="clear: both"></div>
</div>
</div>
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<p>
The formatter is a command-line utility bundled with the C++ build of Jsonnet. You can
reformat files in place as so:
</p>
<pre>jsonnetfmt -i *.jsonnet</pre>
<p>
It will manage indenting and horizontal spacing within a line and remove excess vertical
spacing. It will convert string literals, comments, fields and some operators into
canonical forms as well as enforcing trailing commas. It will sort imports and remove
excess nesting of parentheses. It will break lines in certain places.
</p>
</div>
<div style="clear: both"></div>
</div>
</div>
<div class="inverse hgroup">
<div class=hgroup-inline>
<div class="tab-window-input" id="formatter-input">
<div class="tab-header">
</div>
<textarea id=input-jsonnet>
# Edit me!
local b = import "b.libsonnet"; # comment
local a = import "a.libsonnet";
local f(x,y)=x+y;
local Template = {z: "foo"};
Template + {
"f": ((3)) ,
"g g":
f(4,2),
arr: [[
1, 2,
],
3,
]
}
</textarea>
</div>
<div class="bigarrow">➡</div>
<div class="tab-window-output" id="formatter-output">
<div class="tab-header">
<div class=selected onclick="tab_click(this, 'formatter-output')">output.jsonnet</div>
</div>
<textarea readonly class="selected code-json" id="formatter-output">
// Edit me!
local a = import 'a.libsonnet';
local b = import 'b.libsonnet'; // comment
local f(x, y) = x + y;
local Template = { z: 'foo' };
Template {
f: (3),
'g g':
f(4, 2),
arr: [
[
1,
2,
],
3,
],
}
</textarea>
</div>
<script>
fmt_demo(
'formatter-input',
'input-jsonnet',
'input.jsonnet',
'formatter-output',
);
</script>
<div style="clear: both"></div>
</div>
</div>
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<h2 id="formatter">Linter</h2>
</div>
<div style="clear: both"></div>
</div>
</div>
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<p>
The linter is another command-line utility bundled with the Go build of Jsonnet. You can
check files as so:
</p>
<pre>jsonnet-lint file.jsonnet</pre>
<p>
Currently it is rudimentary and only checks for unused variables.
</p>
</div>
<div style="clear: both"></div>
</div>
</div>
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<h2 id="formatter">Bazel Jsonnet Rules</h2>
</div>
<div style="clear: both"></div>
</div>
</div>
<div class="hgroup">
<div class="hgroup-inline">
<div class="panel">
<p>
<a href="https://github.com/bazelbuild/rules_jsonnet">Jsonnet rules</a>, provides the following rules to your Babel build:
</p>
<pre>jsonnet_library</pre>
<pre>jsonnet_to_json</pre>
<pre>jsonnet_to_json_test</pre>
<div style="clear: both"></div>
</div>
</div>
|