Skip to content

Commit b61b286

Browse files
author
Christine Abernathy
authored
Merge pull request #41 from caabernathy/fix-top-links
[WIP] Better navigation by controlling anchor names
2 parents cf3c267 + 3042d32 commit b61b286

File tree

5 files changed

+29
-17
lines changed

5 files changed

+29
-17
lines changed

_get_started/installation/linux.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ torch.cuda.is_available();
278278
</div>
279279

280280
## Building from source
281+
{: #linux-from-source}
281282

282283
For the majority of PyTorch users, installing from a pre-built binary via a package manager will be provide the best experience. However, there are times when you may want to install the bleeding edge PyTorch code, whether for testing or actual development on the PyTorch core. To install the latest PyTorch code, you will need to [build PyTorch from source](https://github.com/pytorch/pytorch#from-source).
283284

_get_started/installation/mac.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
PyTorch can be installed and used on MacOS. Depending on your system and compute requirements, your experience with PyTorch on a Mac may vary in terms of processing time. It is recommended, but not required, that your Mac have an NVIDIA GPU in order to harness the full power of PyTorch's [CUDA](https://developer.nvidia.com/cuda-zone) [support](https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html?highlight=cuda#cuda-tensors).
44

5-
> Currently, CUDA support on MacOS is only available by [building PyTorch from source](#building-from-source)
5+
> Currently, CUDA support on MacOS is only available by [building PyTorch from source](#mac-from-source)
66
77
## Prerequisites
88

@@ -122,6 +122,7 @@ torch.cuda.is_available();
122122
</div>
123123

124124
## Building from source
125+
{: #mac-from-source}
125126

126127
For the majority of PyTorch users, installing from a pre-built binary via a package manager will be provide the best experience. However, there are times when you may want to install the bleeding edge PyTorch code, whether for testing or actual development on the PyTorch core. To install the latest PyTorch code, you will need to [build PyTorch from source](https://github.com/pytorch/pytorch#from-source).
127128

_get_started/installation/windows.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ torch.cuda.is_available();
228228
```
229229

230230
## Building from source
231+
{: #windows-from-source}
231232

232233
For the majority of PyTorch users, installing from a pre-built binary via a package manager will be provide the best experience. However, there are times when you may want to install the bleeding edge PyTorch code, whether for testing or actual development on the PyTorch core. To install the latest PyTorch code, you will need to [build PyTorch from source](https://github.com/pytorch/pytorch#from-source).
233234

assets/quick-start-module.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var supportedOperatingSystems = new Map([
77

88
var opts = {
99
cuda: 'cuda9.0',
10-
os: getDefaultSelectedOS(),
10+
os: getAnchorSelectedOS() || getDefaultSelectedOS(),
1111
pm: 'conda',
1212
python: 'python3.6',
1313
};
@@ -38,7 +38,9 @@ cuda.on("click", function() {
3838

3939
// Force a selection onclick to get the right operating system selected from
4040
// the start
41-
document.getElementById(opts.os).click();
41+
$( document ).ready(function() {
42+
document.getElementById(opts.os).click();
43+
});
4244

4345

4446
// determine os (mac, linux, windows) based on user's platform
@@ -53,6 +55,27 @@ function getDefaultSelectedOS() {
5355
return supportedOperatingSystems.values().next().value;
5456
}
5557

58+
// determine os based on location hash
59+
function getAnchorSelectedOS() {
60+
var anchor = location.hash;
61+
console.log("getAnchorSelectedOS - 1 "+anchor);
62+
var ANCHOR_REGEX = /^#[^ ]+$/;
63+
// Look for anchor in the href
64+
if (!ANCHOR_REGEX.test(anchor)) {
65+
return false;
66+
}
67+
// Look for anchor with OS in the first portion
68+
var testOS = anchor.slice(1).split("-")[0];
69+
console.log("getAnchorSelectedOS - 2 "+testOS);
70+
for (var [navPlatformSubstring, os] of supportedOperatingSystems.entries()) {
71+
if (testOS.indexOf(navPlatformSubstring) !== -1) {
72+
console.log("getAnchorSelectedOS - 3 "+os);
73+
return os;
74+
}
75+
}
76+
return false;
77+
}
78+
5679
function selectedOption(option, selection, category) {
5780
$(option).removeClass("selected");
5881
$(selection).addClass("selected");

get-started.html

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,6 @@ <h1>Get<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Started</h1>
5050
</div>
5151

5252
<script type="text/javascript">
53-
// Make unique any same header ids and anchors in different sections
54-
$(".article-wrapper").each(function() {
55-
var articleId = $(this).data("id");
56-
var headers = $(this).find("h2, h3, h4, h5, h6");
57-
58-
headers.each(function() {
59-
var headerId = $(this).attr("id");
60-
var newId = articleId + "__" + headerId;
61-
62-
$(this).attr("id", newId);
63-
$(this).find(".anchorjs-link").attr("href", "#" + newId);
64-
});
65-
});
66-
6753
// This page includes content that is hidden from view until clicked in the article menu.
6854
// This ensures that named links display the correct content on page load
6955
var pageHash = window.location.hash.replace(/^#/, '');

0 commit comments

Comments
 (0)