2011-06-19 17:52:02 +02:00
|
|
|
-------
|
|
|
|
-- global functions and tables
|
|
|
|
local tools = require 'ldoc.tools'
|
2011-09-19 14:42:54 +02:00
|
|
|
local globals = {}
|
2011-06-19 17:52:02 +02:00
|
|
|
|
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
globals.functions = {
|
2011-06-19 17:52:02 +02:00
|
|
|
assert = true,
|
|
|
|
collectgarbage = true,
|
|
|
|
dofile = true,
|
|
|
|
setfenv = true,
|
|
|
|
getfenv = true,
|
|
|
|
getmetatable = true,
|
|
|
|
setmetatable = true,
|
|
|
|
pairs = true,
|
|
|
|
ipairs = true,
|
|
|
|
load = true,
|
|
|
|
loadfile = true,
|
|
|
|
loadstring = true,
|
|
|
|
next = true,
|
|
|
|
pcall = true,
|
|
|
|
print = true,
|
|
|
|
rawequal = true,
|
|
|
|
rawget = true,
|
|
|
|
rawset = true,
|
|
|
|
select = true,
|
|
|
|
tonumber = true,
|
|
|
|
tostring = true,
|
|
|
|
type = true,
|
|
|
|
unpack = true,
|
|
|
|
xpcall = true,
|
|
|
|
module = true,
|
|
|
|
require = true,
|
|
|
|
}
|
2011-09-19 14:42:54 +02:00
|
|
|
local functions = globals.functions
|
2011-06-19 17:52:02 +02:00
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
globals.tables = {
|
2011-06-19 17:52:02 +02:00
|
|
|
io = '5.7',
|
|
|
|
package = '5.3',
|
|
|
|
math = '5.6',
|
|
|
|
os = '5.8',
|
|
|
|
string = '5.4',
|
|
|
|
table = '5.5',
|
|
|
|
coroutine = '5.2',
|
|
|
|
debug = '5.9'
|
|
|
|
}
|
2011-09-19 14:42:54 +02:00
|
|
|
local tables = globals.tables
|
|
|
|
|
|
|
|
local manual, fun_ref
|
2011-06-19 17:52:02 +02:00
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
function globals.set_manual_url(url)
|
|
|
|
manual = url .. '#'
|
|
|
|
fun_ref = manual..'pdf-'
|
|
|
|
end
|
|
|
|
globals.set_manual_url 'http://www.lua.org/manual/5.1/manual.html'
|
2011-06-19 17:52:02 +02:00
|
|
|
|
|
|
|
local function function_ref (name)
|
2011-07-05 18:19:49 +02:00
|
|
|
return {href = fun_ref..name, label = name}
|
2011-06-19 17:52:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function module_ref (name)
|
2011-07-05 18:19:49 +02:00
|
|
|
return {href = manual..tables[name], label = name}
|
2011-06-19 17:52:02 +02:00
|
|
|
end
|
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
function globals.lua_manual_ref (name)
|
2011-06-19 17:52:02 +02:00
|
|
|
local tbl,fname = tools.split_dotted_name(name)
|
|
|
|
if not tbl then -- plain symbol
|
|
|
|
if functions[name] then
|
|
|
|
return function_ref(name)
|
|
|
|
end
|
|
|
|
if tables[name] then
|
|
|
|
return module_ref(name)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if tables[tbl] then
|
|
|
|
return function_ref(name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return nil
|
|
|
|
end
|
|
|
|
|
2011-09-19 14:42:54 +02:00
|
|
|
return globals
|