Skip to content

Scaladoc: interactive toggle for capture checking content - #26877

Draft
bracevac wants to merge 1 commit into
scala:mainfrom
dotty-staging:ob/scaladoc-feature-toggle
Draft

Scaladoc: interactive toggle for capture checking content#26877
bracevac wants to merge 1 commit into
scala:mainfrom
dotty-staging:ob/scaladoc-feature-toggle

Conversation

@bracevac

@bracevac bracevac commented Aug 20, 2026

Copy link
Copy Markdown
Member

Implements the interactive feature toggle part of #23743.

Known limitation: the search index and inkuire database are flattened from the cc-on variants only, so searchbar results do not follow the toggle state.

Have you relied on LLM-based tools in this contribution?

Yes, pair programming.

How was the solution tested?

New automated tests (including the issue's reproducer, if applicable)

Manual testing in the browser of scaladoc/generateScalaDocumentation.

Untitled2

Implements the interactive feature toggle part of scala#23743.

Extend the signature IR with a Toggleable part that tags fragments
belonging to a toggleable language feature (currently capture checking)
with an 'on' rendering and an optional plain 'off' fallback (e.g. cc
arrows -> / ?-> fall back to => / ?=>). All cc generation sites now emit
tagged fragments: capture sets, carets on capture variables, cc arrows,
update/consume modifiers, consume parameter prefixes, and uses clauses.

The HTML renderer emits both variants wrapped in feature-cc/feature-on/
feature-off spans; CSS displays exactly one of them based on a cc-hidden
class on the root element, maintained by a new early-loaded script that
persists the choice in localStorage (mirroring the theme switcher). A cc
button in the header (and mobile menu) flips the state; it is only
rendered when at least one documented package opts into capture
checking. Toggling also re-renders an open inheritance diagram, whose
node sizes are measured at first render.

The signature test harness strips the hidden feature-off variants before
text comparison, so existing expectations are unchanged. New tests check
the toggle markup invariants, the presence/absence of the toggle button,
and that -suppressCC still suppresses all toggle machinery.

Known limitation: the search index and inkuire database are flattened
from the cc-on variants only, so searchbar results do not follow the
toggle state.
cls := "text-button",
titleAttr := "Show or hide capture checking annotations",
Attr("aria-label") := "Show or hide capture checking annotations",
)("cc")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be a tad more descriptive for the average beginner? 😇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants