Skip to content
Closed
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
6 changes: 2 additions & 4 deletions src/generate_repo_overview/_html_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from pathlib import Path
from typing import TYPE_CHECKING

from ._icons import _bazel_svg
from .metrics_report import parse_version_key

if TYPE_CHECKING:
Expand All @@ -13,10 +14,7 @@

CSS = (_TEMPLATES / "styles.css").read_text(encoding="utf-8")

BAZEL_ICON = (
'<img src="https://bazel.build/_pwa/bazel/icons/icon-72x72.png"'
' alt="Bazel" class="icon-bazel">'
)
BAZEL_ICON = _bazel_svg('class="icon-bazel"')


GITHUB_ICON = (
Expand Down
19 changes: 19 additions & 0 deletions src/generate_repo_overview/_icons.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from __future__ import annotations

import re
from pathlib import Path

_TEMPLATES = Path(__file__).parent / "templates"

# Inner content of the official Bazel SVG (paths only, no outer <svg> tag).
# Source: https://blog.bazel.build/images/bazel-icon.svg (bazelbuild/bazel-blog)
_BAZEL_SVG_INNER = re.sub(
r"<svg[^>]*>|</svg>",
"",
(_TEMPLATES / "bazel-icon.svg").read_text(encoding="utf-8"),
).strip()


def _bazel_svg(extra_attrs: str) -> str:
"""Return the official Bazel SVG icon with caller-supplied attributes."""
return f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" {extra_attrs} aria-label="Bazel">{_BAZEL_SVG_INNER}</svg>'
4 changes: 2 additions & 2 deletions src/generate_repo_overview/metrics_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import re
from typing import TYPE_CHECKING

from ._icons import _bazel_svg
from ._text_utils import escape_markdown_table_cell

if TYPE_CHECKING:
Expand All @@ -12,7 +13,6 @@


HANDLE_PATTERN = re.compile(r"@[A-Za-z0-9_.-]+(?:/[A-Za-z0-9_.-]+)?")
BAZEL_ICON_URL = "https://bazel.build/_pwa/bazel/icons/icon-72x72.png"


def render_metrics_report(snapshot: RepoSnapshot) -> str:
Expand Down Expand Up @@ -306,7 +306,7 @@ def render_bazel_version_column_header() -> str:


def render_bazel_icon() -> str:
return f'<img src="{BAZEL_ICON_URL}" alt="Bazel" width="16" height="16">'
return _bazel_svg('width="16" height="16"')


def render_presence(value: bool, *, icon: str) -> str:
Expand Down
11 changes: 11 additions & 0 deletions src/generate_repo_overview/templates/bazel-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion tests/test_repo_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -1235,9 +1235,12 @@ def test_metrics_report_renders_summary_and_table() -> None:
assert "## Ownership With Versions" not in markdown
assert "## Delivery And Automation" in markdown
assert "### Infrastructure" in markdown
from generate_repo_overview.metrics_report import render_bazel_icon

assert (
"| [tools](https://github.com/eclipse-score/tools) "
'<img src="https://bazel.build/_pwa/bazel/icons/icon-72x72.png" alt="Bazel" width="16" height="16"> | '
+ render_bazel_icon()
+ " | "
"<small><sub><small>Codeowners: @docs-team, @platform-team, @infra-team, @qa-team<br><br>"
"Maintainers In Bazel Registry: @4og, @nradakovic, @pawelrutkaq</small></sub></small> | "
"🔥 11 | 2 / 1+1 | v1.2.3 + 🟡 7 | 3 / 4 |" in markdown
Expand Down