-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REVIEW] Improve Documentation Examples and Source Linking (#2541)
* Source links working for python code * Missed copybutton.css * Bad commit. Do not use * Source links working for cython. Need to test cyfunction for benchmark performance regressions * Removing accidentally committed file * Adding PR to CHANGELOG * Fixing style issues * Large cleanup of sphinx documentation warnings * Style cleanup * More style cleanup * Fixing doc warnings * Moving the CHANGELOG PR from 0.15 to 0.16 * Adding copyright messages to new files from scikit-learn * Fixing style issues * Fixing lone sphinx warning Co-authored-by: John Zedlewski <[email protected]>
- Loading branch information
1 parent
bd65c15
commit 5300ce4
Showing
9 changed files
with
300 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* This contains code with copyright by the scikit-learn project, subject to | ||
the license in /thirdparty/LICENSES/LICENSE.scikit_learn */ | ||
|
||
/* copybutton */ | ||
/* Adds "Show/Hide Output" button to Examples */ | ||
|
||
.copybutton { | ||
cursor: pointer; | ||
position: absolute; | ||
top: 0px; | ||
right: 0px; | ||
border: 1px solid rgb(221, 221, 221); | ||
color: rgb(221, 221, 221); | ||
font-family: monospace; | ||
padding-left: 0.2rem; | ||
padding-right: 0.2rem; | ||
} | ||
|
||
div.highlight:hover span.copybutton::after { | ||
background: #3F556B; | ||
border-radius: 0.25rem; | ||
color: white; | ||
content: attr(title); | ||
padding: 0.25rem; | ||
position: absolute; | ||
z-index: 98; | ||
width: 100px; | ||
font-size: 0.7rem; | ||
top: 0; | ||
right: 0; | ||
} | ||
|
||
/* copy buttonn */ | ||
div.highlight:hover span.copybutton { | ||
background-color: #3F556B; | ||
color: white; | ||
} | ||
|
||
div.highlight:hover span.copybutton:hover { | ||
background-color: #20252B; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// This contains code with copyright by the scikit-learn project, subject to | ||
// the license in /thirdparty/LICENSES/LICENSE.scikit_learn | ||
|
||
$(document).ready(function () { | ||
/* Add a [>>>] button on the top-right corner of code samples to hide | ||
* the >>> and ... prompts and the output and thus make the code | ||
* copyable. */ | ||
var div = $('.highlight-python .highlight,' + | ||
'.highlight-python3 .highlight,' + | ||
'.highlight-pycon .highlight,' + | ||
'.highlight-default .highlight') | ||
var pre = div.find('pre'); | ||
|
||
// get the styles from the current theme | ||
pre.parent().parent().css('position', 'relative'); | ||
var hide_text = 'Hide prompts and outputs'; | ||
var show_text = 'Show prompts and outputs'; | ||
|
||
// create and add the button to all the code blocks that contain >>> | ||
div.each(function (index) { | ||
var jthis = $(this); | ||
if (jthis.find('.gp').length > 0) { | ||
var button = $('<span class="copybutton">>>></span>'); | ||
button.attr('title', hide_text); | ||
button.data('hidden', 'false'); | ||
jthis.prepend(button); | ||
} | ||
// tracebacks (.gt) contain bare text elements that need to be | ||
// wrapped in a span to work with .nextUntil() (see later) | ||
jthis.find('pre:has(.gt)').contents().filter(function () { | ||
return ((this.nodeType == 3) && (this.data.trim().length > 0)); | ||
}).wrap('<span>'); | ||
}); | ||
|
||
// define the behavior of the button when it's clicked | ||
$('.copybutton').click(function (e) { | ||
e.preventDefault(); | ||
var button = $(this); | ||
if (button.data('hidden') === 'false') { | ||
// hide the code output | ||
button.parent().find('.go, .gp, .gt').hide(); | ||
button.next('pre') | ||
.find('.gt') | ||
.nextUntil('.gp, .go') | ||
.css('visibility', 'hidden'); | ||
button.css('text-decoration', 'line-through'); | ||
button.attr('title', show_text); | ||
button.data('hidden', 'true'); | ||
} else { | ||
// show the code output | ||
button.parent().find('.go, .gp, .gt').show(); | ||
button.next('pre') | ||
.find('.gt') | ||
.nextUntil('.gp, .go') | ||
.css('visibility', 'visible'); | ||
button.css('text-decoration', 'none'); | ||
button.attr('title', hide_text); | ||
button.data('hidden', 'false'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.