mirror of
https://github.com/TECHNOFAB11/docsonnet.git
synced 2025-12-11 22:10:13 +01:00
feat: ignore
Implements ignoring certain keys right in Jsonnet, by adding:
{
'#foo': "ignore",
foo: {}
}
This is especially useful for objects that include `self` references,
which might otherwise recurse infinitely
This commit is contained in:
parent
14e9fc8f3f
commit
66a158a8f2
7 changed files with 85 additions and 46 deletions
|
|
@ -12,6 +12,8 @@ local lib = {
|
|||
local aux(old, key) =
|
||||
if !std.isObject(pkg[key]) then
|
||||
old
|
||||
else if std.objectHasAll(pkg, '#' + key) && pkg['#' + key] == 'ignore' then
|
||||
old
|
||||
else if std.startsWith(key, '#') then
|
||||
old { [key]: pkg[key] }
|
||||
else if self.scan(pkg[key]) then
|
||||
|
|
@ -21,4 +23,5 @@ local lib = {
|
|||
std.foldl(aux, std.objectFieldsAll(pkg), {}),
|
||||
};
|
||||
|
||||
|
||||
lib.load(std.extVar('main'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue