8000 Merge pull request #1 from GaelVaroquaux/rcap · LilianBoulard/scikit-learn@2691211 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2691211

Browse files
authored
Merge pull request scikit-learn#1 from GaelVaroquaux/rcap
Add a hover label
2 parents 20dd782 + bbe9c25 commit 2691211

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

sklearn/utils/_estimator_html_repr.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,44 @@
197197
#$id div.sk-text-repr-fallback {
198198
display: none;
199199
}
200+
201+
/* For the docs link */
202+
a.sk-estimator-doc-link {
203+
float: right;
204+
font-size: smaller;
205+
line-height: 1em;
206+
font-family: monospace;
207+
background-color: white;
208+
border: cornflowerblue 1pt solid;
209+
border-radius: 1em;
210+
height: 1em;
211+
width: 1em;
212+
color: cornflowerblue;
213+
text-decoration: none;
214+
}
215+
216+
a.sk-estimator-doc-link:hover {
217+
background-color: cornflowerblue;
218+
color: white;
219+
text-decoration: none;
220+
}
221+
222+
a.sk-estimator-doc-link span {
223+
display: none;
224+
z-index: 2;
225+
position: absolute;
226+
background: #eff5ff;
227+
color: black;
228+
font-weight: normal;
229+
padding: .5ex;
230+
margin: .5ex;
231+
border: .5pt solid cornflowerblue;
232+
right: .2ex;
233+
box-shadow: 2pt 2pt 4pt #999;
234+
max-width: 17ex;
235+
}
236+
237+
a.sk-estimator-doc-link:hover span {
238+
display: block;
239+
}
240+

sklearn/utils/_estimator_html_repr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ def _write_label_html(
9595
est_id = _ESTIMATOR_ID_COUNTER.get_id()
9696

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

0 commit comments

Comments
 (0)
0