Skip to content
Merged
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
19 changes: 14 additions & 5 deletions src/generate_repo_overview/_html_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
)

DOCS_ICON = "📑"
DOCS_AS_CODE_MODULE = "score_docs_as_code"


def docs_url(org_name: str, repo_name: str) -> str:
Expand All @@ -48,6 +49,13 @@ def docs_url(org_name: str, repo_name: str) -> str:
return f"https://{org_name}.github.io/{repo_name}"


def uses_docs_as_code(entry: RepoEntry) -> bool:
return any(
module_name == DOCS_AS_CODE_MODULE
for module_name, _ in entry.content.bazel_deps
)



Comment thread
AlexanderLanin marked this conversation as resolved.
_LANGUAGE_COLORS: dict[str, str] = {
"Python": "#3572A5",
Expand Down Expand Up @@ -91,11 +99,12 @@ def repo_name_cell(entry: RepoEntry, org_name: str, *, bazel_icon: bool = True)
f' <a href="{e(github_url)}" class="gh-link" title="Open on GitHub ↗"'
f' target="_blank" rel="noopener">{GITHUB_ICON}</a>'
)
cell += (
f' <a href="{e(docs_link_str)}" class="docs-link" title="Documentation ↗"'
f' aria-label="Documentation ↗"'
f' target="_blank" rel="noopener">{DOCS_ICON}</a>'
)
if uses_docs_as_code(entry):
cell += (
f' <a href="{e(docs_link_str)}" class="docs-link" title="Documentation ↗"'
f' aria-label="Documentation ↗"'
f' target="_blank" rel="noopener">{DOCS_ICON}</a>'
)
if entry.description:
cell += f' <span class="repo-desc">{e(entry.description)}</span>'
return cell
Expand Down
12 changes: 9 additions & 3 deletions src/generate_repo_overview/_html_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
docs_url,
e,
language_badge,
uses_docs_as_code,
version_badge,
)
from .metrics_report import tracked_dep_label
Expand Down Expand Up @@ -64,6 +65,13 @@ def _render_hero(entry: RepoEntry, org_name: str) -> str:
desc = e(entry.description) if entry.description else ""

docs_url_str = docs_url(org_name, entry.name)
docs_link = (
f' <a href="{e(docs_url_str)}" class="docs-link" title="Documentation ↗"'
f' aria-label="Documentation ↗"'
f' target="_blank" rel="noopener">{DOCS_ICON}</a>'
if uses_docs_as_code(entry)
else ""
)
return (
"<header>\n"
' <nav class="breadcrumb">\n'
Expand All @@ -73,9 +81,7 @@ def _render_hero(entry: RepoEntry, org_name: str) -> str:
f" <h1>{name_html}"
f' <a href="{e(github_url)}" class="gh-link" title="Open on GitHub ↗"'
f' target="_blank" rel="noopener">{GITHUB_ICON}</a>'
f' <a href="{e(docs_url_str)}" class="docs-link" title="Documentation ↗"'
f' aria-label="Documentation ↗"'
f' target="_blank" rel="noopener">{DOCS_ICON}</a>'
f"{docs_link}"
f"</h1>\n"
f' <p class="subtitle">{desc}</p>\n'
f' <div class="meta-chips">{chips}</div>\n'
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cli_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ def test_render_detail_page_shows_tracked_dep_versions(tmp_path: Path) -> None:
assert detail.exists()
detail_content = detail.read_text(encoding="utf-8")
assert "Docs As Code Version" in detail_content
assert 'href="https://eclipse-score.github.io/my-dac-repo"' in detail_content

plain_detail_content = (output_dir / "plain-repo" / "index.html").read_text(
encoding="utf-8"
)
assert 'href="https://eclipse-score.github.io/plain-repo"' not in plain_detail_content

index_content = (output_dir / "index.html").read_text(encoding="utf-8")
assert 'href="https://eclipse-score.github.io/my-dac-repo"' in index_content
assert 'href="https://eclipse-score.github.io/plain-repo"' not in index_content


def _make_snapshot_with_dac() -> RepoSnapshot:
Expand Down