Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 51cbf73

Browse files
authored
Introduction tooltip corresponds to the first paragraph (#1344)
1 parent 69007ef commit 51cbf73

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

sphinx_gallery/_static/sg_gallery.css

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,44 @@ thumbnail with its default link Background color */
178178
max-height: 112px;
179179
max-width: 160px;
180180
}
181-
.sphx-glr-thumbcontainer[tooltip]:hover:after {
182-
background: var(--sg-tooltip-background);
181+
182+
.sphx-glr-thumbcontainer[tooltip]::before {
183+
content: "";
184+
position: absolute;
185+
pointer-events: none;
186+
top: 0;
187+
left: 0;
188+
width: 100%;
189+
height: 100%;
190+
z-index: 97;
191+
background-color: var(--sg-tooltip-background);
192+
backdrop-filter: blur(3px);
193+
opacity: 0;
194+
transition: opacity 0.3s;
195+
}
196+
197+
.sphx-glr-thumbcontainer[tooltip]:hover::before {
198+
opacity: 1;
199+
}
200+
201+
.sphx-glr-thumbcontainer[tooltip]:hover::after {
183202
-webkit-border-radius: 4px;
184203
-moz-border-radius: 4px;
185204
border-radius: 4px;
186205
color: var(--sg-tooltip-foreground);
187206
content: attr(tooltip);
188-
padding: 10px;
207+
padding: 10px 10px 5px;
189208
z-index: 98;
190209
width: 100%;
191-
height: 100%;
210+
max-height: 100%;
192211
position: absolute;
193212
pointer-events: none;
194213
top: 0;
195214
box-sizing: border-box;
196215
overflow: hidden;
197-
backdrop-filter: blur(3px);
216+
display: -webkit-box;
217+
-webkit-box-orient: vertical;
218+
-webkit-line-clamp: 6;
198219
}
199220

200221
.sphx-glr-script-out {

sphinx_gallery/gen_rst.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,9 +331,6 @@ def extract_intro_and_title(filename, docstring):
331331
# Concatenate all lines of the first paragraph and truncate at 95 chars
332332
intro = re.sub("\n", " ", intro_paragraph)
333333
intro = _sanitize_rst(intro)
334-
if len(intro) > 95:
335-
intro = intro[:95] + "..."
336-
337334
title = _sanitize_rst(title)
338335

339336
return intro, title

sphinx_gallery/tests/test_gen_rst.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,14 @@ def test_extract_intro_and_title():
352352
) # noqa: E501
353353
assert title == '"-`Header"-with:; punct mark\'s'
354354

355-
# Long intro paragraph gets shortened
355+
# Long intro paragraph are preserved
356356
intro_paragraph = "\n".join(["this is one line" for _ in range(10)])
357357
intro, _ = sg.extract_intro_and_title(
358358
"filename", "Title\n-----\n\n" + intro_paragraph
359359
)
360360
assert len(intro_paragraph) > 100
361-
assert len(intro) < 100
362-
assert intro.endswith("...")
363-
assert intro_paragraph.replace("\n", " ")[:95] == intro[:95]
361+
assert len(intro) > 100
362+
assert intro_paragraph.replace("\n", " ") == intro
364363

365364
# Errors
366365
with pytest.raises(ExtensionError, match="should have a header"):

0 commit comments

Comments
 (0)