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
5 changes: 4 additions & 1 deletion content/en/history/bibliography/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ title: Bibliography
heading: Interlisp Bibliography
type: bibliography
robots: "noindex, follow"
# Keep this section visible in the sidebar. Hugo merges a section's own
# cascade into its own Params, so cascade.toc_hide alone would hide it.
toc_hide: false
cascade:
type: bibliography
toc_hide: false
toc_hide: true
weight: 5
aliases:
- /bibliography/
Expand Down
4 changes: 4 additions & 0 deletions content/en/history/bibliography/intake/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
title: Interlisp Bibliography Intake Guide
weight: 1
type: docs
# Explicitly visible in the sidebar: the parent bibliography section's
# cascade sets toc_hide:true (to keep generated entries out of the nav),
# and Hugo merges cascade into children's Params too.
toc_hide: false
---

## I have something I think belongs in the Interlisp Bibliography!
Expand Down
69 changes: 69 additions & 0 deletions tests/test_hugo_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,75 @@ def test_bibliography_section_present(self):
)


class TestHistorySidebarNavigation:
"""The Bibliography section must be reachable from History navigation.

Regression tests for PR #347: setting only ``cascade.toc_hide`` hid the
Bibliography entry itself from the History sidebar (Hugo merges a
section's own cascade into its own Params). The empty
``layouts/_partials/section-index.html`` override is intentional and
must keep suppressing the subpage cards. Either deviation must break
the build tests.
"""

@pytest.fixture(autouse=True)
def history_page(self, production_build):
self.build_result = production_build
path = PROD_PUBLIC / "history" / "index.html"
if not path.exists():
pytest.skip("history/index.html not found — run a production build first")
self.content = path.read_text(encoding="utf-8", errors="ignore")

def test_bibliography_in_sidebar_nav(self) -> None:
"""The sidebar nav on /history/ must link to /history/bibliography/."""
nav = re.search(
r'<nav[^>]*id="td-section-nav".*?</nav>',
self.content,
re.DOTALL,
)
assert nav, "sidebar nav #td-section-nav not found on history page"
assert "/history/bibliography/" in nav.group(0), (
"Bibliography entry missing from the History sidebar navigation"
)

def test_intake_guide_in_sidebar_nav(self) -> None:
"""The Intake Guide must be listed under Bibliography, while the
hundreds of generated entries must stay out of the nav."""
nav = re.search(
r'<nav[^>]*id="td-section-nav".*?</nav>',
self.content,
re.DOTALL,
)
assert nav, "sidebar nav #td-section-nav not found on history page"
nav_html = nav.group(0)
assert "/history/bibliography/intake/" in nav_html, (
"Intake Guide entry missing from the sidebar navigation"
)
stray_entries = re.findall(
r'href="/history/bibliography/(?!intake/)[a-z0-9]+/"', nav_html
)
assert not stray_entries, (
"Generated bibliography entries leaking into sidebar navigation:\n"
+ "\n".join(stray_entries[:10])
)

def test_no_subpage_cards(self) -> None:
"""The History page must not render section-index subpage cards;
subpage navigation lives in the sidebar. The empty
``layouts/_partials/section-index.html`` override suppresses them."""
assert '<div class="section-index">' not in self.content, (
"section-index subpage list should be suppressed on the History page"
)

def test_no_sidebar_truncation_warning(self) -> None:
"""Hugo must not truncate sidebar entries — a flood of unhidden
bibliography entries (e.g. from a stale Zotero cache without
``toc_hide``) would trigger this Docsy warning."""
assert "sidebar entries have been truncated" not in (
self.build_result.stderr or ""
), "Sidebar entries were truncated — bibliography entries may be leaking into navigation"


class TestInternalLinks:
"""All internal href links in the built HTML must resolve to existing pages."""

Expand Down
Loading