INNER CODE UNIT · Python
context
fralau/mkdocs-macros-plugin · mkdocs_macros/context.py:325
def context(obj:dict=None):
"""
*Default Mkdocs-Macro*: List an object
(by default the variables)
"""
if not obj:
obj = env.variables
try:
return [(var, type(value).__name__, format_value(value))
for var, value in list_items(obj)]
except jinja2.exceptions.UndefinedError as e:
return [("<i>Error!</i>", type(e).__name__, str(e))]
except AttributeError:
# Not an object or dictionary (int, str, etc.)
return [(obj, type(obj).__name__, repr(obj))]
@env.filter
def pretty(var_list):