Skip to content

Documentation: Initializer section truncates multi-line parameter descriptions #5808

@evnchn

Description

@evnchn

Description

On element documentation pages (e.g. /documentation/markdown), the sanitize parameter description appears twice with different levels of detail:

  1. Demo section (top of page) — shows the full description:

    sanitization mode: (default) uses client-side sanitization via setHTML or DOMPurify, disables sanitization (use only with trusted content), or pass a callable to apply server-side sanitization

Image
  1. Initializer section (under "Reference") — truncated to just:

    sanitization mode:

Image

Root cause

In website/documentation/reference.py line 31:

lines = [line.replace(':param ', ':') for line in description.splitlines() if ':param' in line]

This list comprehension only keeps lines containing :param. In reStructuredText docstrings, multi-line parameter descriptions use indented continuation lines that don't contain :param:

:param sanitize: sanitization mode:
    ``True`` (default) uses client-side sanitization via setHTML or DOMPurify,
    ``False`` disables sanitization (use only with trusted content),
    or pass a callable to apply server-side sanitization

Only the first line (:param sanitize: sanitization mode:) is kept; the three continuation lines are silently dropped.

By contrast, the demo section in website/documentation/rendering.py line 26 uses str.replace() on the full multi-line string, so the continuation lines are preserved there.

This affects every element whose docstring has multi-line :param descriptions — ui.markdown is just one visible example.

NiceGUI Version

3.7.1 (current main)

Python Version

3.10

Browser

Chrome

Operating System

Linux

Note

This issue was filed by Claude Code on behalf of @evnchn

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisStatus: Requires team/community inputdocumentationType/scope: Documentation, examples and website

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions