conandeps: colour tree tags in HTML and text

The tree builder now emits typed tags (path, override, missing, ...) and
both renderers colour by kind: <span class> in the HTML <pre> block, ANSI
in the terminal (path dim, override yellow, missing red). Previously the
HTML tree was one escaped string and only MISSING was coloured in text.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYNdaGDrpaqDyT8QtrTQbM
This commit is contained in:
Ole-Morten Duesund 2026-08-25 15:49:59 +02:00
commit f018b4c8aa
3 changed files with 59 additions and 22 deletions

View file

@ -344,6 +344,7 @@ def test_text_and_html_render(report, tmp_path):
coloured = conandeps.render_text(report, color=True)
assert "\033[1;31mMISSING\033[0m" in coloured and "\033[32mtest\033[0m" in coloured
assert "\033[2mlibfoo -> libbar -> libdeep\033[0m" in coloured # tree path tag, dim
# Colour codes must not break column alignment: same visible layout.
strip = conandeps._ANSI_RE.sub
assert strip("", coloured) == text
@ -351,8 +352,10 @@ def test_text_and_html_render(report, tmp_path):
page = conandeps.render_html(report)
assert page.startswith("<!DOCTYPE html>") and 'class="missing"' in page
assert page.count("<table>") == 3 # dependencies, missing binaries, overrides
# The HTML tree is the text tree verbatim, paths included.
assert "[libfoo -&gt; libbar -&gt; libdeep]" in page
# The HTML tree carries the same tags as the text tree, coloured by kind.
assert '[<span class="path">libfoo -&gt; libbar -&gt; libdeep</span>]' in page
assert '<span class="new">overrides libbar/1.0 (explicit by your conanfile)</span>' in page
assert '<span class="missing">MISSING: Debug,RelWithDebInfo</span>' in page
assert 'class="explicit"' in page and 'class="implicit"' in page
assert "<script" not in page # self-contained, static