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
6894b486
Unverified
Commit
6894b486
authored
Jun 24, 2020
by
Sylvain Gugger
Committed by
GitHub
Jun 24, 2020
Browse files
Fix version controller links (for realsies) (#5251)
parent
1121ce9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
docs/source/_static/js/custom.js
docs/source/_static/js/custom.js
+7
-6
No files found.
docs/source/_static/js/custom.js
View file @
6894b486
...
...
@@ -84,14 +84,14 @@ function addGithubButton() {
function
addVersionControl
()
{
// To grab the version currently in view, we parse the url
const
parts
=
location
.
toString
().
split
(
'
/
'
);
let
versionIndex
=
parts
.
length
-
2
let
versionIndex
=
parts
.
length
-
2
;
// Index page may not have a last part with filename.html so we need to go up
if
(
!
parts
[
versionIndex
].
match
(
/
\.
html$/
))
{
versionIndex
=
parts
.
length
-
1
if
(
parts
[
parts
.
length
-
1
]
!=
""
&&
!
parts
[
parts
.
length
-
1
].
match
(
/
\.
html$/
))
{
versionIndex
=
parts
.
length
-
1
;
}
// Main classes and models are nested so we need to go deeper
else
if
(
parts
[
versionIndex
]
==
"
main_classes
"
||
parts
[
versionIndex
]
==
"
model_doc
"
)
{
versionIndex
=
parts
.
length
-
3
versionIndex
=
versionIndex
-
1
;
}
const
version
=
parts
[
versionIndex
];
...
...
@@ -100,11 +100,12 @@ function addVersionControl() {
const
htmlLines
=
[];
for
(
const
[
key
,
value
]
of
Object
.
entries
(
versionMapping
))
{
var
urlParts
=
parts
.
slice
(
0
,
versionIndex
-
1
);
let
baseUrlIndex
=
(
version
==
"
transformers
"
)
?
versionIndex
+
1
:
versionIndex
;
var
urlParts
=
parts
.
slice
(
0
,
baseUrlIndex
);
if
(
key
!=
""
)
{
urlParts
=
urlParts
.
concat
([
key
]);
}
urlParts
=
urlParts
.
concat
(
parts
.
slice
(
versionIndex
));
urlParts
=
urlParts
.
concat
(
parts
.
slice
(
versionIndex
+
1
));
htmlLines
.
push
(
`<a href="
${
urlParts
.
join
(
'
/
'
)}
">
${
value
}
</a>`
);
}
...
...
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