Files
openide/python/helpersTests
Morgan Bartholomew 48d02b97bb PY-84818 quick-doc: render Markdown fenced code blocks
Markdown fenced code blocks (```lang ... ```) in docstrings were shown as a
row of broken inline tokens in the Quick Documentation popup, and got no
syntax highlighting while editing the docstring. docutils has no notion of
Markdown fences, so the backticks were parsed as inline literal markup; and
the docstring language injector only recognized reST `.. code-block::`.
Render path (docstring_formatter.py, runs in the user's interpreter):
rewrite each Markdown fence as an equivalent reST `.. code-block::`
directive before handing the text to docutils, so fenced code follows the
same path as native reST code blocks.
Editor path (PyDocstringLanguageInjector, runs in the IDE): detect Python
fences and inject the Python language into their content, mirroring the
existing reST code-block injection. Fence detection reuses the platform
Markdown parser (org.intellij.markdown) instead of a hand-rolled regex: it
is a single linear pass -- the previous scanner rescanned the tail once per
unterminated fence (O(n^2)), which matters because injection can run on the
EDT -- and it follows CommonMark for tilde fences, longer closing fences and
info strings. Content is dedented PEP 257-style only for parsing (the parser
is strict about fence indentation) and ranges are mapped back to the
original offsets so injected code keeps its indentation.
The two paths stay separate on purpose: the renderer is a standalone script
in the user's (possibly Python 2) interpreter, which has no Markdown parser,
while the injector lives in the JVM -- they cannot share an implementation.
The renderer keeps one precompiled opener regex and no longer compiles a
regex per fence.

(cherry picked from commit 8b216e7ffd2312e7bc0eb2bf7e183c13b9b38b68)

GitOrigin-RevId: 9f27715ae7f0581fbec2cddf5ae11be60f0c48af
2026-07-22 10:39:22 +00:00
..
…
…

helpersTests

  • tests for PyCharm helpers
  • to be able to run tests—install uv, e.g., ...
curl -LsSf https://astral.sh/uv/install.sh | sh
  • to run all tests ...
./run_tests.sh
  • to run a specific module, e.g., ...
uv run --python 3.14 __main__.py tests/pycharm_tests/test_jb_unittest_runner.py
  • the tests are executed on all supported Python versions using uv.lock for reproducible builds
  • no manual Python installation is required
  • to update the list of dependencies / supported Python versions - edit pyproject.toml
  • to update the lock file ...
uv lock