Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
3e0fe3cf
Unverified
Commit
3e0fe3cf
authored
Aug 10, 2020
by
Sylvain Gugger
Committed by
GitHub
Aug 10, 2020
Browse files
Colab button (#6389)
* Add colab button * Add colab link for tutorials
parent
79588e6f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
0 deletions
+62
-0
docs/source/_static/css/huggingface.css
docs/source/_static/css/huggingface.css
+31
-0
docs/source/_static/js/custom.js
docs/source/_static/js/custom.js
+31
-0
No files found.
docs/source/_static/css/huggingface.css
View file @
3e0fe3cf
/* Our DOM objects */
/* Colab dropdown */
.colab-dropdown
{
position
:
relative
;
display
:
inline-block
;
}
.colab-dropdown-content
{
display
:
none
;
position
:
absolute
;
background-color
:
#f9f9f9
;
min-width
:
117px
;
box-shadow
:
0px
8px
16px
0px
rgba
(
0
,
0
,
0
,
0.2
);
z-index
:
1
;
}
.colab-dropdown-content
button
{
color
:
#6670FF
;
background-color
:
#f9f9f9
;
font-size
:
12px
;
border
:
none
;
min-width
:
117px
;
padding
:
5px
5px
;
text-decoration
:
none
;
display
:
block
;
}
.colab-dropdown-content
button
:hover
{
background-color
:
#eee
;}
.colab-dropdown
:hover
.colab-dropdown-content
{
display
:
block
;}
/* Version control */
.version-button
{
...
...
docs/source/_static/js/custom.js
View file @
3e0fe3cf
...
...
@@ -21,6 +21,17 @@ const versionMapping = {
"
v1.1.0
"
:
"
v1.1.0
"
,
"
v1.0.0
"
:
"
v1.0.0
"
}
// The page that have a notebook and therefore should have the open in colab badge.
const
hasNotebook
=
[
"
benchmarks
"
,
"
multilingual
"
,
"
perplexity
"
,
"
preprocessing
"
,
"
quicktour
"
,
"
task_summary
"
,
"
tokenizer_summary
"
,
"
training
"
];
function
addIcon
()
{
const
huggingFaceLogo
=
"
https://huggingface.co/landing/assets/transformers-docs/huggingface_logo.svg
"
;
...
...
@@ -82,6 +93,25 @@ function addGithubButton() {
document
.
querySelector
(
"
.wy-side-nav-search .icon-home
"
).
insertAdjacentHTML
(
'
afterend
'
,
div
);
}
function
addColabLink
()
{
const
parts
=
location
.
toString
().
split
(
'
/
'
);
const
pageName
=
parts
[
parts
.
length
-
1
].
split
(
"
.
"
)[
0
];
if
(
hasNotebook
.
includes
(
pageName
))
{
const
linksColab
=
`
<div class="colab-dropdown">
<img alt="Open In Colab" src="https://colab.research.google.com/assets/colab-badge.svg">
<div class="colab-dropdown-content">
<button onclick=" window.open('https://colab.research.google.com/github/sgugger/test_nbs/blob/master/
${
pageName
}
.ipynb')">Mixed</button>
<button onclick=" window.open('https://colab.research.google.com/github/sgugger/test_nbs/blob/master/pytorch/
${
pageName
}
.ipynb')">PyTorch</button>
<button onclick=" window.open('https://colab.research.google.com/github/sgugger/test_nbs/blob/master/tensorflow/
${
pageName
}
.ipynb')">TensorFlow</button>
</div>
</div>`
const
leftMenu
=
document
.
querySelector
(
"
.wy-breadcrumbs-aside
"
)
leftMenu
.
innerHTML
=
linksColab
+
'
\n
'
+
leftMenu
.
innerHTML
}
}
function
addVersionControl
()
{
// To grab the version currently in view, we parse the url
const
parts
=
location
.
toString
().
split
(
'
/
'
);
...
...
@@ -255,6 +285,7 @@ function onLoad() {
addGithubButton
();
parseGithubButtons
();
addHfMenu
();
addColabLink
();
platformToggle
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment