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
|
# Jsonnet - The data templating language
[](https://travis-ci.org/google/jsonnet)
For an introduction to Jsonnet and documentation,
[visit our website](https://jsonnet.org).
This repository contains the original implementation. You can also try [go-jsonnet](https://github.com/google/go-jsonnet), a newer implementation which in some cases is orders of magnitude faster.
Visit our [discussion forum](https://groups.google.com/g/jsonnet).
## Packages
Jsonnet is available on Homebrew:
```
brew install jsonnet
```
The Python binding is on pypi:
```
pip install jsonnet
```
You can also download and install Jsonnet using the [vcpkg](https://github.com/Microsoft/vcpkg/)
dependency manager:
```
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
vcpkg install jsonnet
```
The Jsonnet port in vcpkg is kept up to date by Microsoft team members and community contributors.
If the version is out of date, please [create an issue or pull
request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
## Building Jsonnet
You can use either GCC or Clang to build Jsonnet. Note that on recent versions
of macOS, `/usr/bin/gcc` and `/usr/bin/g++` are actually Clang, so there is no
difference.
### Makefile
To build Jsonnet with GCC, run:
```
make
```
To build Jsonnet with Clang, run:
```
make CC=clang CXX=clang++
```
To run the output binary, run:
```
./jsonnet
```
To run the reformatter, run:
```
./jsonnetfmt
```
### Bazel
Bazel builds are also supported.
Install [Bazel](https://www.bazel.io/versions/master/docs/install.html) if it is
not installed already. Then, run the following command to build with GCC:
```
bazel build -c opt //cmd:all
```
To build with Clang, use one of these two options:
```
env CC=clang CXX=clang++ bazel build -c opt //cmd:all
# OR
bazel build -c opt --action_env=CC=clang --action_env=CXX=clang++ //cmd:all
```
This builds the `jsonnet` and `jsonnetfmt` targets defined in [`cmd/BUILD`](./cmd/BUILD). To launch
the output binaries, run:
```
bazel-bin/cmd/jsonnet
bazel-bin/cmd/jsonnetfmt
```
### Cmake
```
cmake . -Bbuild
```
```
cmake --build build --target run_tests
```
## Contributing
See the [contributing page](https://jsonnet.org/learning/community.html#license) on our website.
## Developing Jsonnet
### Running tests
To run the comprehensive suite:
```
make test
```
### Locally serving the website
You need a `doc/js/libjsonnet.wasm` which can either be downloaded from the
production website:
```
wget https://jsonnet.org/js/libjsonnet.wasm -O doc/js/libjsonnet.wasm
```
Or you can build it yourself, which requires checking out
[go-jsonnet](https://github.com/google/go-jsonnet). See the README.md in
that repo for instructions.
Then, from the root of the repository you can generate and serve the website using
[Jekyll](https://jekyllrb.com/):
```
tools/scripts/serve_docs.sh
```
This should the website on localhost:8200, automatically rebuild when you change any underlying
files, and automatically refresh your browser when that happens.
The standard library is documented in a structured format in `doc/_stdlib_gen/stdlib-content.jsonnet`.
The HTML (input for Jekyll) is regenerated using the following command:
```
tools/scripts/update_web_content.sh
```
|