Skip to content

Commit 24cdfbf

Browse files
Elizabeth Davisclaude
andcommitted
Fix sidebar clipping of long dotted identifiers
Adds sidebar-wrap.js (injects zero-width spaces after dots in FQNs so they wrap at segment boundaries) and CSS overrides to allow overflow and enable word-break in sidebar links. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 698f11a commit 24cdfbf

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

docs/_static/custom.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,18 @@ html.dark code.docutils {
9999
font-weight: 600;
100100
}
101101

102+
/* Allow long dotted FQNs to wrap in the sidebar instead of clipping */
103+
.sy-sidebar-toc,
104+
.sy-sidebar-toc ul,
105+
.sy-sidebar-toc li {
106+
overflow: visible;
107+
}
108+
109+
.sy-lside a {
110+
white-space: normal;
111+
word-break: break-word;
112+
}
113+
102114
/* Reset code font in sidebar nav — prevents identifier-titled pages
103115
* (e.g. generate_composite_decl) from rendering in monospace */
104116
.sy-lside a code {

docs/_static/sidebar-wrap.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2026 Apple Inc.
2+
//
3+
// Use of this source code is governed by a BSD-3-Clause license that can
4+
// be found in the LICENSE file or at https://opensource.org/licenses/BSD-3-Clause
5+
6+
7+
// Break sidebar entries at `.` boundaries so long dotted FQNs wrap cleanly
8+
// (e.g. `coreai_opt.quantization.QuantizerConfig.presets.w4` wraps between
9+
// segments rather than mid-word). Inserts a zero-width space (U+200B) after
10+
// each `.`, which the browser treats as a valid line-break opportunity when
11+
// combined with `white-space: normal` in the sidebar CSS.
12+
document.addEventListener("DOMContentLoaded", function () {
13+
document.querySelectorAll(".wy-menu-vertical li a").forEach(function (link) {
14+
// Only touch the text nodes — don't mangle any HTML inside (e.g. icons).
15+
link.childNodes.forEach(function (node) {
16+
if (node.nodeType === Node.TEXT_NODE && node.textContent.indexOf(".") !== -1) {
17+
node.textContent = node.textContent.replace(/\./g, ".​");
18+
}
19+
});
20+
});
21+
});

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
html_theme = "shibuya"
3838
html_static_path = ["_static"]
3939
html_css_files = ["custom.css"]
40-
html_js_files = ["copy-page-button.js"]
40+
html_js_files = ["sidebar-wrap.js", "copy-page-button.js"]
4141
templates_path = ["_templates"]
4242
html_show_sourcelink = False
4343

0 commit comments

Comments
 (0)