diff options
Diffstat (limited to 'script-beta/vm/getDocs.lua')
-rw-r--r-- | script-beta/vm/getDocs.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/script-beta/vm/getDocs.lua b/script-beta/vm/getDocs.lua index 75f74028..ef29dcdb 100644 --- a/script-beta/vm/getDocs.lua +++ b/script-beta/vm/getDocs.lua @@ -133,3 +133,41 @@ function vm.isMetaFile(uri) end return false end + +function vm.getValidVersions(doc) + if doc.type ~= 'doc.version' then + return + end + local valids = { + ['Lua 5.1'] = false, + ['Lua 5.2'] = false, + ['Lua 5.3'] = false, + ['Lua 5.4'] = false, + ['LuaJIT'] = false, + } + for _, version in ipairs(doc.versions) do + if version.ge and type(version.version) == 'number' then + for ver in pairs(valids) do + local verNumber = tonumber(ver:sub(-3)) + if verNumber and verNumber >= version.version then + valids[ver] = true + end + end + elseif version.le and type(version.version) == 'number' then + for ver in pairs(valids) do + local verNumber = tonumber(ver:sub(-3)) + if verNumber and verNumber <= version.version then + valids[ver] = true + end + end + elseif type(version.version) == 'number' then + valids[('Lua %.1f'):format(version.version)] = true + elseif 'JIT' == version.version then + valids['LuaJIT'] = true + end + end + if valids['Lua 5.1'] then + valids['LuaJIT'] = true + end + return valids +end |