Skip to content

Docstring example rendering

Renders doctests and fenced Python examples in Quick Documentation for Python docstrings, so runnable examples are easier to scan and copy.

How to invoke: F1 / Ctrl+Q on a documented function, class, or module.

def normalize_name(value: str) -> str:
    """
    Normalize a display name.

    Examples:
        >>> normalize_name(" Ada ")
        'ada'
    """
    return value.strip().lower()
>>> normalize_name(" Ada ")
'ada'

Notes

  • Doctest prompts and fenced Python blocks are rendered as Python code blocks.
  • The rendered example includes a copy link that copies only executable input for doctest snippets.
  • The feature is gated by the Docstring Example Rendering setting under Settings | BetterPy | Productivity Actions | Documentation.