Skip to content

Migrate kit/ components to Svelte 5 runes (fixes broken docstring tooltips) - #795

Merged
mishig25 merged 1 commit into
mainfrom
runes-migration
Jul 3, 2026
Merged

Migrate kit/ components to Svelte 5 runes (fixes broken docstring tooltips)#795
mishig25 merged 1 commit into
mainfrom
runes-migration

Conversation

@mishig25

@mishig25 mishig25 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Migrates all kit/src components (110 files) from Svelte 4 legacy syntax to runes ($props/$state/$derived, event attributes, snippets), using migrate() from svelte/compiler plus manual finishing. Follow-up to #792.

⚠️ Includes a production fix

Docstring parameter tooltips have been silently broken since #792: src/lib/tooltip.ts used the Svelte 4 class API (new Tooltip({...}), $set, $destroy), which throws on Svelte 5 components — the error was swallowed by the hover handler, so nothing surfaced in builds. Rewritten as a .svelte.ts action using mount/unmount with reactive $state props. Verified in a browser against the Svelte 4 baseline: tooltips mount on hover and unmount on leave, exactly like before the upgrade.

Notable decisions

  • 3 components intentionally stay legacy (FrameworkContent, InferenceApi, TokenizersLanguageContent): they expose named slots (pytorch, python, …) that collide with same-named props, which snippet props cannot express. Their slot API is consumed by the generated doc pages (also legacy syntax); mixing legacy and runes components is fully supported by Svelte 5. Each carries a comment explaining this.
  • Generated doc pages (mdx → +page.svelte) remain legacy syntax by design — they're emitted by the Python/mdsvex pipeline; legacy pages rendering runes components (children snippets) is standard interop.
  • svelte/legacy shims the migrator inserted (preventDefault, stopPropagation, handlers) were replaced with plain event handlers — zero svelte/legacy imports remain.
  • Icon/component props are now typed Component<{ classNames?: string }> instead of constructor signatures.
  • state_referenced_locally warnings are silenced in onwarn: the flagged initial-value captures have identical semantics to the previous Svelte 4 code (doc pages pass static props), and they would flood every downstream doc build log. They remain visible in svelte-check.

Verification

🤖 Generated with Claude Code

Migrated all 110 src/ components with `migrate()` from svelte/compiler
($props/$state/$derived, event attributes, snippets), then hand-finished:

- tooltip action rewritten from the removed class API (new Component/$set/
  $destroy) to mount/unmount with reactive $state props, in a .svelte.ts
  module. This FIXES docstring parameter tooltips, which have been silently
  broken since #792 (`new Tooltip()` throws on Svelte 5 components; hover
  handlers swallowed the error). Verified against the Svelte 4 baseline.
- FrameworkContent, InferenceApi, TokenizersLanguageContent intentionally
  stay in legacy syntax: their named slots collide with same-named props,
  which snippets cannot express; mixing legacy and runes is supported.
- svelte/legacy shims (preventDefault/stopPropagation/handlers) replaced
  with plain event handlers; component prop types moved from constructor
  signatures to `Component<...>`.
- `state_referenced_locally` warnings silenced in onwarn: initial-value
  capture matches the previous Svelte 4 semantics (doc pages pass static
  props), and they'd flood every downstream doc build log.

Verified: svelte-check 0 errors; accelerate e2e output equivalent to the
Svelte 4 baseline (identical metadata/links/ids, known whitespace-only
diffs); hub-docs build (268 pages) byte-identical on all compared
dimensions vs pre-migration; browser tests pass (hydration, SPA nav,
shorthand URLs, HfOptions tabs, docstring tooltips mount/unmount).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mishig25
mishig25 merged commit 7241b19 into main Jul 3, 2026
5 checks passed
@mishig25
mishig25 deleted the runes-migration branch July 3, 2026 22:23
mishig25 added a commit that referenced this pull request Jul 4, 2026
…irectly (#797)

* refactor: emit the <Docstring> svelte component directly from python

autodoc.py previously serialized docstring metadata into a zoo of custom
tags (<docstring><name>...<paramgroups>N) that kit/preprocessors/
docstring.js regex-parsed back into a <Docstring .../> component. Python
now emits the component open tag with all metadata props inline
(name/anchor/source/parameters/isGetSetDescriptor as final JSON values,
MDX escaping undone since JS strings need none); the component body
carries only the markdown-bearing sections, which the kit preprocessor
renders with mdsvex into the remaining props and closes the component.

- parameter groups become nested <paramsgroup> blocks instead of numbered
  tags + a count
- the rendered-<ul> parsing stays (documented): parameter lists must be
  rendered as one markdown list to keep exact tight/loose list semantics
- fixes a long-standing tag mismatch: python emits <yielddesc> but the
  old regex matched <yieldesc>, silently dropping yield descriptions

Verified byte-identical output (48/48 pages, modulo hashed asset names
and nondeterministic python object addresses) on the accelerate e2e
build; python test suite updated and passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(kit): silence state_referenced_locally warnings (runes follow-up)

This hunk was part of the runes migration verification but was left out
of #795 (staged with `git add kit/src`, which misses kit/svelte.config.js).
The flagged initial-value captures have the same semantics as the
pre-runes svelte 4 code — doc pages pass static props — and the warning
floods every downstream doc build log otherwise.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant