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

Skip to content

Introduction tooltip corresponds to the first paragraph #1344

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions sphinx_gallery/_static/sg_gallery.css
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,44 @@ thumbnail with its default link Background color */
max-height: 112px;
max-width: 160px;
}
.sphx-glr-thumbcontainer[tooltip]:hover:after {
background: var(--sg-tooltip-background);

.sphx-glr-thumbcontainer[tooltip]::before {
content: "";
position: absolute;
pointer-events: none;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 97;
background-color: var(--sg-tooltip-background);
backdrop-filter: blur(3px);
opacity: 0;
transition: opacity 0.3s;
}

.sphx-glr-thumbcontainer[tooltip]:hover::before {
opacity: 1;
}

.sphx-glr-thumbcontainer[tooltip]:hover::after {
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
color: var(--sg-tooltip-foreground);
content: attr(tooltip);
padding: 10px;
padding: 10px 10px 5px;
z-index: 98;
width: 100%;
height: 100%;
max-height: 100%;
position: absolute;
pointer-events: none;
top: 0;
box-sizing: border-box;
overflow: hidden;
backdrop-filter: blur(3px);
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 6;
}

.sphx-glr-script-out {
Expand Down
3 changes: 0 additions & 3 deletions sphinx_gallery/gen_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ def extract_intro_and_title(filename, docstring):
# Concatenate all lines of the first paragraph and truncate at 95 chars
intro = re.sub("\n", " ", intro_paragraph)
intro = _sanitize_rst(intro)
if len(intro) > 95:
intro = intro[:95] + "..."

title = _sanitize_rst(title)

return intro, title
Expand Down
7 changes: 3 additions & 4 deletions sphinx_gallery/tests/test_gen_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,14 @@ def test_extract_intro_and_title():
) # noqa: E501
assert title == '"-`Header"-with:; punct mark\'s'

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

# Errors
with pytest.raises(ExtensionError, match="should have a header"):
Expand Down
Loading