INNER CODE UNIT · Python

pretty

fralau/mkdocs-macros-plugin · mkdocs_macros/context.py:342

    def pretty(var_list):
        """
        *Default Mkdocs-Macro*: Prettify a dictionary or object 
        (used for environment documentation, or debugging).

        Note: it will work only on the product of the `context()` macro

        To prettify any object `obj`, thus use: `context(obj) | pretty`
        """
        if not var_list:
            return ''
        else:
            try:
                rows = [("<b>%s</b>" % var, "<i>%s</i>" % var_type,
                        content.replace('\n', '<br/>'))
                        for var, var_type, content in var_list]
                header = ['Variable', 'Type', 'Content']
                return make_html(rows, header)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…