Skip to content

Preserve single-line code spans in fallback docstrings - #731

Open
SAY-5 wants to merge 1 commit into
python-lsp:developfrom
SAY-5:codex/fix-docstring-code-span-escaping-20261005
Open

SAY-5 wants to merge 1 commit into
python-lsp:developfrom
SAY-5:codex/fix-docstring-code-span-escaping-20261005

Conversation

@SAY-5

@SAY-5 SAY-5 commented Oct 5, 2026

Copy link
Copy Markdown

When a docstring falls back to escape_markdown, backslashes are added inside inline code spans. For example, object_hook becomes object\_hook, which displays a literal backslash in hover and completion documentation.

Preserve the contents of same-line code spans with matching backtick delimiters, while keeping the existing escaping and whitespace handling outside them. If a matched pair crosses a line, retain the previous escaping for the entire input so this change does not alter ambiguous multiline Markdown parsing.

Refs #606. This addresses the extra backslashes in code spans; signature wrapping is outside this change.

Validation on Python 3.13 / Jedi 0.20.0:

  • The new regression matrix produces 14 assertion failures and 11 passing controls before the fix.
  • All 47 tests in test_utils.py, test_hover.py, and test_signature.py pass after the fix.
  • A separate real Document/Jedi completion-and-resolve smoke check verifies nonempty Markdown and plaintext documentation.
  • Ruff 0.9.4 lint and formatting pass across pylsp and test.

The full platform/plugin suite was not run locally. The completion test module requires optional packages absent from this environment; the separate smoke check does not replace that suite.

OpenAI Codex assisted with the code, regression tests, and this description. The final patch received an independent AI review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant