Skip to content

Commit

Permalink
Merge pull request scikit-learn#1 from GaelVaroquaux/rcap
Browse files Browse the repository at this point in the history
Add a hover label
  • Loading branch information
rcap107 committed Jun 19, 2023
2 parents 20dd782 + bbe9c25 commit 2691211
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
41 changes: 41 additions & 0 deletions sklearn/utils/_estimator_html_repr.css
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,44 @@
#$id div.sk-text-repr-fallback {
display: none;
}

/* For the docs link */
a.sk-estimator-doc-link {
float: right;
font-size: smaller;
line-height: 1em;
font-family: monospace;
background-color: white;
border: cornflowerblue 1pt solid;
border-radius: 1em;
height: 1em;
width: 1em;
color: cornflowerblue;
text-decoration: none;
}

a.sk-estimator-doc-link:hover {
background-color: cornflowerblue;
color: white;
text-decoration: none;
}

a.sk-estimator-doc-link span {
display: none;
z-index: 2;
position: absolute;
background: #eff5ff;
color: black;
font-weight: normal;
padding: .5ex;
margin: .5ex;
border: .5pt solid cornflowerblue;
right: .2ex;
box-shadow: 2pt 2pt 4pt #999;
max-width: 17ex;
}

a.sk-estimator-doc-link:hover span {
display: block;
}

5 changes: 4 additions & 1 deletion sklearn/utils/_estimator_html_repr.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ def _write_label_html(
est_id = _ESTIMATOR_ID_COUNTER.get_id()

if True: # check if estimator is sklearn or not
doc_link = f'<a class="estimator_doc_link" href="{url_link}">?</a>'
doc_label = '<span>Online documentation</span>'
if name is not None:
doc_label = f'<span>Documentation for {name}</span>'
doc_link = f'<a class="sk-estimator-doc-link" href="{url_link}">?{doc_label}</a>'
else: # not sklearn, do not add link to doc
doc_link = ""

Expand Down

0 comments on commit 2691211

Please sign in to comment.