Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## Version 2.6.0

Unreleased

- Remove local workaround to display `^D` in `CliRunner`. Requires
Click >= 8.6.0.
[pallets/click#3878](https://github.com/pallets/click/pull/3878)

## Version 2.5.0

Released 2026-02-25
Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jinja = "pallets_sphinx_themes.themes.jinja:JinjaStyle"

[dependency-groups]
dev = [
"click>=8.3.1",
"click>=8.6.0.dev",
"ruff",
"tox",
"tox-uv",
Expand All @@ -58,7 +58,7 @@ tests = [
"pytest",
]
typing = [
"click>=8.3.1",
"click>=8.6.0.dev",
"mypy",
"pyright",
"types-pygments>=2.19.0.20251121",
Expand All @@ -83,6 +83,11 @@ exclude = [
[tool.uv]
default-groups = ["dev", "pre-commit", "tests", "typing"]

# XXX Temporary, until the `^D` echo reaches a Click release: drop this
# source and pin `click>=8.6.0`. https://github.com/pallets/click/pull/3878
[tool.uv.sources]
click = { git = "https://github.com/kdeldycke/click", rev = "f8c5a8efc17d01a9fb10bba961def4c3215ce369" }

[tool.pytest]
testpaths = ["tests"]
filterwarnings = [
Expand Down
42 changes: 0 additions & 42 deletions src/pallets_sphinx_themes/themes/click/domain.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
import contextlib
import shlex
import subprocess
import sys
import tempfile
from functools import partial

import click
from click.testing import CliRunner
from click.testing import EchoingStdin
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.statemachine import ViewList
from sphinx.domains import Domain


class EofEchoingStdin(EchoingStdin):
"""Like :class:`click.testing.EchoingStdin` but adds a visible
``^D`` in place of the EOT character (``\x04``).

:meth:`ExampleRunner.invoke` adds ``\x04`` when
``terminate_input=True``.
"""

def _echo(self, rv):
eof = rv[-1] == b"\x04"[0]

if eof:
rv = rv[:-1]

if not self._paused:
self._output.write(rv)

if eof:
self._output.write(b"^D\n")

return rv


@contextlib.contextmanager
def patch_modules():
"""Patch modules to work better with :meth:`ExampleRunner.invoke`.
Expand Down Expand Up @@ -68,23 +43,6 @@ def __init__(self):
super().__init__(echo_stdin=True)
self.namespace = {"click": click, "__file__": "dummy.py"}

@contextlib.contextmanager
def isolation(self, *args, **kwargs):
iso = super().isolation(*args, **kwargs)

with iso as streams:
try:
buffer = sys.stdin.buffer
except AttributeError:
buffer = sys.stdin

# FIXME: We need to replace EchoingStdin with our custom
# class that outputs "^D". At this point we know sys.stdin
# has been patched so it's safe to reassign the class.
# Remove this once EchoingStdin is overridable.
buffer.__class__ = EofEchoingStdin
yield streams

def invoke(
self,
cli,
Expand Down
15 changes: 4 additions & 11 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading