mirror of
https://github.com/TECHNOFAB11/docsonnet.git
synced 2026-02-02 07:35:11 +01:00
* fix(load): support nested objects * feat: initial golang parser Moves most of load.libsonnet to a Golang app for hopefully much faster parsing (fingers crossed) * feat(fast): nested objects, subpackages * feat: incorporate fast mode into main binary Moves the work done in the fast directory into the main executable, removing the Jsonnet based parser in favor of the much faster Golang one.
24 lines
595 B
Jsonnet
24 lines
595 B
Jsonnet
local lib = {
|
|
scan(obj)::
|
|
local aux(old, key) =
|
|
if std.startsWith(key, '#') then
|
|
true
|
|
else if std.isObject(obj[key]) then
|
|
old || $.scan(obj[key])
|
|
else old;
|
|
std.foldl(aux, std.objectFieldsAll(obj), false),
|
|
|
|
load(pkg)::
|
|
local aux(old, key) =
|
|
if !std.isObject(pkg[key]) then
|
|
old
|
|
else if std.startsWith(key, '#') then
|
|
old { [key]: pkg[key] }
|
|
else if self.scan(pkg[key]) then
|
|
old { [key]: $.load(pkg[key]) }
|
|
else old;
|
|
|
|
std.foldl(aux, std.objectFieldsAll(pkg), {}),
|
|
};
|
|
|
|
lib.load(std.extVar('main'))
|