INNER CODE UNIT · Python
format_value
fralau/mkdocs-macros-plugin · mkdocs_macros/context.py:75
def format_value(value):
"Properly format the value, to make it descriptive"
# those classes will be processed as "dictionary type"
# NOTE: using the name does nto force us to import them
LISTED_CLASSES = 'Config', 'File', 'Section'
# those types will be printed without question
SHORT_TYPES = int, float, str, list
if callable(value):
# for functions
docstring = get_first_para(value.__doc__)
# we interpret the markdown in the docstring,
# since both jinja2 and ourselves use markdown,
# and we need to produce a HTML table:
docstring = markdown(docstring)
try:
varnames = ', '.join(value.__code__.co_varnames)
return "(<i>%s</i>)<br/> %s" % (varnames, docstring)
except AttributeError: