Added recursion option for displaying every table even if already displayed.
This commit is contained in:
parent
1f20c29f68
commit
39dc9ce84e
|
@ -412,13 +412,12 @@ local function format_table (t, depth, l)
|
||||||
l.visited[t] = true
|
l.visited[t] = true
|
||||||
|
|
||||||
-- If empty, visited or above max-depth, give a small represetation: `{...}`
|
-- If empty, visited or above max-depth, give a small represetation: `{...}`
|
||||||
if table_info.type == TABLE_TYPE.EMPTY or depth >= l.options.max_depth or already_visited then
|
if table_info.type == TABLE_TYPE.EMPTY or depth >= l.options.max_depth or (already_visited and l.options.recursion ~= 'revisit') then
|
||||||
l '{'
|
l '{'
|
||||||
if l.options._table_addr_comment then l[#l+1] = ' --[[' .. table_info.address .. ']] ' end
|
if l.options._table_addr_comment then l[#l+1] = ' --[[' .. table_info.address .. ']] ' end
|
||||||
if table_info.type ~= TABLE_TYPE.EMPTY then l[#l+1] = '...' end
|
if table_info.type ~= TABLE_TYPE.EMPTY then l[#l+1] = '...' end
|
||||||
return l '}'
|
return l '}'
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get key-value pairs, and possibly fill holes.
|
-- Get key-value pairs, and possibly fill holes.
|
||||||
local key_value_pairs = get_key_value_pairs_in_proper_order(t)
|
local key_value_pairs = get_key_value_pairs_in_proper_order(t)
|
||||||
if table_info.type == TABLE_TYPE.SEQUENCE and l.info[t].has_holes then
|
if table_info.type == TABLE_TYPE.SEQUENCE and l.info[t].has_holes then
|
||||||
|
@ -525,7 +524,7 @@ local KNOWN_OPTIONS = {
|
||||||
indent = { type = 'string', default = ' ' },
|
indent = { type = 'string', default = ' ' },
|
||||||
max_depth = { type = 'number', default = math.huge },
|
max_depth = { type = 'number', default = math.huge },
|
||||||
short_builtins = { type = 'boolean', default = false }, -- TODO: Outphase this. Rather automatically use the short versions in places where it would be strange to find the function, like keys, etc.
|
short_builtins = { type = 'boolean', default = false }, -- TODO: Outphase this. Rather automatically use the short versions in places where it would be strange to find the function, like keys, etc.
|
||||||
recursion = { type = 'string', default = 'ignore', accepted = {['ignore'] = true, ['marked'] = true} },
|
recursion = { type = 'string', default = 'ignore', accepted = {['ignore'] = true, ['marked'] = true, ['revisit'] = true} },
|
||||||
}
|
}
|
||||||
|
|
||||||
local function ensure_that_all_options_are_known (input_options)
|
local function ensure_that_all_options_are_known (input_options)
|
||||||
|
@ -543,7 +542,7 @@ local function ensure_that_all_options_are_known (input_options)
|
||||||
elseif type(option_value) ~= KNOWN_OPTIONS[option_name].type then
|
elseif type(option_value) ~= KNOWN_OPTIONS[option_name].type then
|
||||||
error(('[pretty]: Bad value given to option %s: %s (%s). Expected value of type %s'):format(option_name, option_value, type(option_value), KNOWN_OPTIONS[option_name].type), 2)
|
error(('[pretty]: Bad value given to option %s: %s (%s). Expected value of type %s'):format(option_name, option_value, type(option_value), KNOWN_OPTIONS[option_name].type), 2)
|
||||||
elseif KNOWN_OPTIONS[option_name].accepted and not KNOWN_OPTIONS[option_name].accepted[option_value] then
|
elseif KNOWN_OPTIONS[option_name].accepted and not KNOWN_OPTIONS[option_name].accepted[option_value] then
|
||||||
error(('[pretty]: Bad value given to option %s: %s (%s). Expected one of: %s'):format(option_name, option_value, type(option_value), table.concat(KNOWN_OPTIONS[option_name].accepted, ', ')), 2)
|
error(('[pretty]: Bad value given to option %s: %s (%s).'):format(option_name, option_value, type(option_value)), 2)
|
||||||
elseif KNOWN_OPTIONS[option_name].debug and not DEBUG_OPTION_USED[option_name] then
|
elseif KNOWN_OPTIONS[option_name].debug and not DEBUG_OPTION_USED[option_name] then
|
||||||
DEBUG_OPTION_USED[option_name] = true
|
DEBUG_OPTION_USED[option_name] = true
|
||||||
print(('[pretty]: Using %s option "%s".\n Please note that this option may change at any time. It is not stable,\n not tested, and may indeed break or be removed without warning.'):format(KNOWN_OPTIONS[option_name].debug, option_name))
|
print(('[pretty]: Using %s option "%s".\n Please note that this option may change at any time. It is not stable,\n not tested, and may indeed break or be removed without warning.'):format(KNOWN_OPTIONS[option_name].debug, option_name))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user