Skip to content

fix(web): contain wide code examples on API reference pages - #4621

Merged
bpamiri merged 1 commit into
developfrom
peter/api-pre-overflow
Oct 19, 2026
Merged

bpamiri merged 1 commit into
developfrom
peter/api-pre-overflow

Conversation

@bpamiri

@bpamiri bpamiri commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

API reference examples are written by generate-api-docs.mjs (renderExtended()) as raw <pre><code>, not as fenced code blocks. So:

  • Expressive Code never wraps them;
  • its stylesheet, the only thing giving a <pre> overflow-x: auto on these sites, never loads on API pages;
  • base.css only contains .prose pre, which API pages don't use.

A long example line therefore widened the whole page on phones. This adds overflow-x: auto to .sl-markdown-content pre in starlight-theme.css, so each example scrolls inside its own box. No API content needs regenerating.

Guides code blocks are Expressive Code and already had the same value, so they're unchanged.

Fixes #4616. Separate content bug, not fixed here: #4620 (literal \n in two examples).

Testing (built api + guides sites, 390×844 and 1440×900)

Page Page-level horizontal overflow at 390px, before → after
v4-2-0/configuration/resources 441px → 0
v4-2-0/view-helpers/telfield 5,330px → 0
v4-2-0/model-class/deleteall 1,373px → 0
v1-4-5/miscellaneous/deletebykey (<pre> without <code>) 865px → 0
  • On every page above, the code block now scrolls internally.
  • Guides basics/associations: all 19 code blocks still scroll, with the copy button and frame intact and no double scrollbars.
  • The parameters table on resources still scrolls inside .wd-params-table.
  • Visual baselines: no change to api.png or guides.png.

🤖 Generated with Claude Code

The API generator writes each function's examples as raw <pre><code>
(renderExtended() in web/scripts/generate-api-docs.mjs), so Expressive
Code never wraps them and its stylesheet, which is the only thing giving
a <pre> overflow-x: auto on these sites, is never loaded on API pages.
base.css only contains `.prose pre`, which API pages don't use, so a long
example line widened the whole page at phone width (by about 441px on
configuration/resources and over 5,000px on view-helpers/telfield).

.sl-markdown-content pre now sets overflow-x: auto, so each example
scrolls inside its own box. Guides code blocks already had the same
value from Expressive Code and are unchanged.

Fixes #4616

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
@bpamiri
bpamiri merged commit 0eae7ff into develop Oct 19, 2026
22 checks passed
@bpamiri
bpamiri deleted the peter/api-pre-overflow branch October 19, 2026 23:29
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.

web/api: wide code examples make some API pages scroll sideways at phone width

1 participant