from bec_widgets.widgets.control.scan_control.scan_docstring import ( render_scan_docstring_html, render_scan_tooltip_html, ) def test_render_scan_docstring_html_formats_google_sections(): docstring = """Run a line scan over one motor. The motor is moved through evenly spaced positions. Args: device (DeviceBase | str): Device to move. start (float): Initial position. Expressed in the device's configured engineering units. Constraint: must be below the stop position. Returns: ScanReport: Handle for the submitted scan. Raises: ValueError: If the requested range is invalid. Examples: >>> scans.line_scan(samx, -1, 1, steps=11) """ rendered = render_scan_docstring_html("line_scan", docstring) assert "
device" in rendered
assert "DeviceBase | str" in rendered
assert "configured engineering units" in rendered
assert "Constraint: must be below" in rendered
assert "Constraint" not in rendered
assert ">>> scans.line_scan" in rendered
def test_render_scan_tooltip_html_is_compact_and_informative():
docstring = """Run a line scan.
Args:
device (DeviceBase | str): Device to move.
start (float): Initial position.
Examples:
>>> scans.line_scan(samx, 0, 1)
"""
rendered = render_scan_tooltip_html("line_scan", docstring)
assert "line_scan" in rendered
assert "Run a line scan." in rendered
assert "device: DeviceBase | str" in rendered
assert "start: float" in rendered
assert "Examples" not in rendered
assert "full documentation" in rendered
def test_scan_docstring_renderers_escape_untrusted_content():
docstring = "Use safely."
full = render_scan_docstring_html("", docstring)
tooltip = render_scan_tooltip_html("", docstring)
for rendered in (full, tooltip):
assert "<scan>" in rendered
assert "<script>" in rendered
assert "