mirror of
https://github.com/mipmip/home-manager-option-search.git
synced 2024-08-17 02:50:28 +03:00
add parser for 22.11
This commit is contained in:
parent
d3cf4e7988
commit
fea3a76ddf
@ -13,24 +13,41 @@ p ENV['HM_RELEASE']
|
||||
in_file = File.read("./result/share/doc/home-manager/options.json")
|
||||
parsed = JSON.parse(in_file)
|
||||
|
||||
def isLiteralExpression(val, key)
|
||||
if val.key? key and val[key].instance_of? Hash and val[key].key? "_type" and val[key]['_type'] == 'literalExpression'
|
||||
true
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
def getValFor(val, key)
|
||||
if isLiteralExpression(val, key)
|
||||
val[key]['text']
|
||||
elsif val.key? key
|
||||
val[key]
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def parseVal2211(val)
|
||||
val['example'] = getValFor(val, 'example')
|
||||
val['default'] = getValFor(val, 'default')
|
||||
|
||||
val
|
||||
end
|
||||
|
||||
def parseVal2305(val)
|
||||
end
|
||||
|
||||
options_arr = []
|
||||
parsed.each do | name, val |
|
||||
|
||||
next if name == '_module.args'
|
||||
|
||||
val['title'] = name
|
||||
|
||||
if val.key? "example"
|
||||
val['example'] = val['example']['text']
|
||||
else
|
||||
val['example'] = ""
|
||||
end
|
||||
|
||||
if val.key? "default"
|
||||
val['default'] = val['default']['text']
|
||||
else
|
||||
val['default'] = ""
|
||||
end
|
||||
val = parseVal2211(val)
|
||||
|
||||
options_arr << val
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user