Skip to content

Commit a84be23

Browse files
authored
Merge pull request #33 from JSv4/docs/html-previews-now-render
docs: HTML previews render now; stop saying they are skipped
2 parents b368d3d + bb9f821 commit a84be23

4 files changed

Lines changed: 57 additions & 6 deletions

File tree

.github/workflows/redline-action-test.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ jobs:
2727
original: tests/fixtures/original.docx
2828
modified: tests/fixtures/modified.docx
2929
author: Action Self-Test
30-
# 'auto' exercises the graceful-skip path until a Docx2Html release
31-
# with --track-changes support is on NuGet, then starts rendering.
32-
html-preview: auto
30+
# Docx2Html on NuGet now supports --track-changes, so previews are
31+
# required here: 'true' fails the run rather than skipping, which is
32+
# what keeps the README's claim that previews render honest.
33+
html-preview: true
3334
artifact-name: docx-redlines-explicit
3435

3536
- name: Assert outputs
@@ -49,8 +50,11 @@ jobs:
4950
# The exact count is pinned in tests/test_docxodus_engine.py, which runs
5051
# against the working tree.
5152
assert isinstance(record["revisions"], int) and record["revisions"] > 0, record
53+
# html-preview is 'true' above, so a preview is part of the contract now.
54+
assert record["html"], record
5255
'
5356
test -s "redlines/tests/fixtures/modified.redline.docx"
57+
test -s "redlines/tests/fixtures/modified.redline.html"
5458
5559
auto-detect:
5660
runs-on: ubuntu-latest

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ between two commits (PR base/head, push before/after, or explicit `base-ref`/`he
3939
or takes an explicit `original`/`modified` pair, runs an engine via pip-installed
4040
python-redlines (PyPI wheels, not the working tree), and optionally renders HTML previews
4141
by invoking the Docxodus `Docx2Html` dotnet tool with `--track-changes` (requires
42-
Docxodus ≥ 7.1.0; `html-preview: auto` skips gracefully below that). Script unit +
42+
Docxodus ≥ 7.1.0, satisfied by the current NuGet release, so `auto` renders; it still
43+
skips gracefully when the tool is absent or pinned older). Script unit +
4344
integration tests: `tests/test_action_script.py`; action-level self-test:
4445
`.github/workflows/redline-action-test.yml` (runs the action from the checkout in both
4546
modes and asserts on outputs).

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,11 @@ Notes:
138138
- Added and deleted `.docx` files are listed in the summary but not redlined — a redline
139139
needs both a base and a head version. Pure renames report zero revisions without
140140
invoking the engine.
141-
- HTML previews require a `Docx2Html` release with `--track-changes` support (Docxodus
142-
≥ 7.1.0); until that is on NuGet, the default `auto` mode skips previews with a warning.
141+
- HTML previews need the `Docx2Html` dotnet tool with `--track-changes` support (Docxodus
142+
≥ 7.1.0). That is now on NuGet, so the default `auto` mode renders previews rather than
143+
skipping them. `auto` still degrades to a warning-and-skip when the tool is missing or
144+
when `docx2html-version` pins it below 7.1.0; use `html-preview: true` to require a
145+
preview and fail the run if one cannot be produced.
143146
- The action installs python-redlines from PyPI with prebuilt engine binaries — it does
144147
not build anything from the repository, so runs are fast on `ubuntu-latest` runners.
145148

tests/test_action_script.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,49 @@ def test_comparison_rejection_explains_the_removal():
8383
assert 'DocxDiff' in message
8484

8585

86+
# ---------------------------------------------------------------------------
87+
# HTML preview mode resolution
88+
#
89+
# Docx2Html on NuGet now supports --track-changes, so the action self-test
90+
# requires a rendered preview. That leaves the tolerant 'auto' path — the
91+
# default, and the one most callers hit — without integration coverage, so its
92+
# behaviour is pinned here instead, without depending on what is installed.
93+
# ---------------------------------------------------------------------------
94+
95+
def test_resolve_previewer_returns_none_when_disabled(monkeypatch):
96+
"""'false' must not even look for the tool — that is what makes .NET optional."""
97+
def fail():
98+
raise AssertionError('find_docx2html() called despite html-preview: false')
99+
100+
monkeypatch.setattr(ra, 'find_docx2html', fail)
101+
inputs = ra.Inputs.from_env({'INPUT_HTML_PREVIEW': 'false'})
102+
assert ra.resolve_previewer(inputs) is None
103+
104+
105+
def test_resolve_previewer_auto_warns_and_skips_when_tool_is_missing(monkeypatch, capsys):
106+
monkeypatch.setattr(ra, 'find_docx2html', lambda: None)
107+
inputs = ra.Inputs.from_env({'INPUT_HTML_PREVIEW': 'auto'})
108+
109+
assert ra.resolve_previewer(inputs) is None
110+
assert '::warning::' in capsys.readouterr().out
111+
112+
113+
def test_resolve_previewer_true_fails_when_tool_is_missing(monkeypatch):
114+
monkeypatch.setattr(ra, 'find_docx2html', lambda: None)
115+
inputs = ra.Inputs.from_env({'INPUT_HTML_PREVIEW': 'true'})
116+
117+
with pytest.raises(ra.ConfigError, match='Docx2Html'):
118+
ra.resolve_previewer(inputs)
119+
120+
121+
@pytest.mark.parametrize('mode', ['auto', 'true'])
122+
def test_resolve_previewer_returns_the_tool_when_available(monkeypatch, mode):
123+
monkeypatch.setattr(ra, 'find_docx2html', lambda: '/usr/local/bin/docx2html')
124+
inputs = ra.Inputs.from_env({'INPUT_HTML_PREVIEW': mode})
125+
126+
assert ra.resolve_previewer(inputs) == '/usr/local/bin/docx2html'
127+
128+
86129
@pytest.mark.parametrize('env', [
87130
{'INPUT_ENGINE': 'wordperfect'},
88131
{'INPUT_HTML_PREVIEW': 'maybe'},

0 commit comments

Comments
 (0)