diff --git a/ldoc.lua b/ldoc.lua index ac2a022..b92d919 100644 --- a/ldoc.lua +++ b/ldoc.lua @@ -1,3 +1,4 @@ +#!/usr/bin/env lua --------------- -- ## ldoc, a Lua documentation generator. -- @@ -26,7 +27,7 @@ app.require_here() --- @usage local usage = [[ -ldoc, a documentation generator for Lua, vs 1.1.0 +ldoc, a documentation generator for Lua, vs 1.2.0 -d,--dir (default docs) output directory -o,--output (default 'index') output name -v,--verbose verbose diff --git a/ldoc/builtin/globals.lua b/ldoc/builtin/globals.lua index 7ccdf0e..06dbdd5 100644 --- a/ldoc/builtin/globals.lua +++ b/ldoc/builtin/globals.lua @@ -2,14 +2,13 @@ -- global functions and tables local tools = require 'ldoc.tools' local globals = {} +local lua52 = _VERSION:match '5.2' globals.functions = { assert = true, collectgarbage = true, dofile = true, - setfenv = true, - getfenv = true, getmetatable = true, setmetatable = true, pairs = true, @@ -27,32 +26,54 @@ globals.functions = { tonumber = true, tostring = true, type = true, - unpack = true, xpcall = true, module = true, require = true, } local functions = globals.functions -globals.tables = { - io = '5.7', - package = '5.3', - math = '5.6', - os = '5.8', - string = '5.4', - table = '5.5', - coroutine = '5.2', - debug = '5.9' -} -local tables = globals.tables +if not lua52 then + functions.setfenv = true + functions.getfenv = true + functions.unpack = true +else + functions.rawlen = true +end local manual, fun_ref function globals.set_manual_url(url) - manual = url .. '#' - fun_ref = manual..'pdf-' + manual = url .. '#' + fun_ref = manual..'pdf-' end -globals.set_manual_url 'http://www.lua.org/manual/5.1/manual.html' + +if lua52 then + globals.tables = { + io = '6.8', + package = '6.3', + math = '6.6', + os = '6.9', + string = '6.4', + table = '6.5', + coroutine = '6.2', + debug = '6.10' + } + globals.set_manual_url 'http://www.lua.org/manual/5.2/manual.html' +else + globals.tables = { + io = '5.7', + package = '5.3', + math = '5.6', + os = '5.8', + string = '5.4', + table = '5.5', + coroutine = '5.2', + debug = '5.9' + } + globals.set_manual_url 'http://www.lua.org/manual/5.1/manual.html' +end + +local tables = globals.tables local function function_ref (name) return {href = fun_ref..name, label = name} diff --git a/ldoc/html/ldoc_ltp.lua b/ldoc/html/ldoc_ltp.lua index 86b35c8..7e7e1db 100644 --- a/ldoc/html/ldoc_ltp.lua +++ b/ldoc/html/ldoc_ltp.lua @@ -212,7 +212,7 @@ return [==[