Fixed issue encounted when source contains a filename, but is missing '@' at the start.
This commit is contained in:
parent
6d56713627
commit
bb67701f8f
17
function.lua
17
function.lua
|
@ -78,6 +78,8 @@ local FUNCTION_DEFINITION_MATCH = '.-' .. -- Look for stuff before the functio
|
|||
'[ \t]*(.+)[ \t]*' .. -- Look for the function body
|
||||
'end' -- Look for the end keyword
|
||||
|
||||
local LUA_FILE_PATTERN = '^%s*[%w_]+.lua%s*$'
|
||||
|
||||
local NR_CHARS_IN_LONG_FUNCTION_BODY = 30
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -109,11 +111,11 @@ local function get_function_info (f)
|
|||
end
|
||||
end
|
||||
|
||||
if info.source:sub(1,1) == '=' then info.defined_how = 'C'
|
||||
elseif info.source:sub(1,1) == '@' then info.defined_how = 'file'
|
||||
elseif info.source:find'^%w+.lua$' then info.defined_how = 'file' -- Hotfix for Love2d boot.lua issue.
|
||||
else info.defined_how = 'string'
|
||||
end
|
||||
if info.source:sub(1,1) == '=' then info.defined_how = 'C'
|
||||
elseif info.source:sub(1,1) == '@' then info.defined_how = 'file'
|
||||
elseif info.source:find(LUA_FILE_PATTERN) then info.defined_how = 'file' -- Fix for when someone has misunderstood the source format is for.
|
||||
else info.defined_how = 'string'
|
||||
end
|
||||
|
||||
if info.builtin and LIBRARY[f] then
|
||||
info.name = LIBRARY[f].name
|
||||
|
@ -284,7 +286,10 @@ return function (value, depth, l, format_value)
|
|||
|
||||
local function_params, function_body = nil, '...'
|
||||
|
||||
if not info.docs and info.defined_how ~= 'C' then
|
||||
if not info.docs and info.defined_how ~= 'C' and (depth == 0 or info.defined_how == 'string') then
|
||||
-- Only look for documentation, when at depth 0, or when defined in
|
||||
-- string. We don't want to open a ton of files constantly when
|
||||
-- formatting a table.
|
||||
info = get_function_body_info(info)
|
||||
|
||||
if info.body and #info.body <= NR_CHARS_IN_LONG_FUNCTION_BODY and not info.body:find '\n' and not info.body:find(FUNCTION_KEYWORD_MATCH) then
|
||||
|
|
Loading…
Reference in New Issue
Block a user