Skip to content

Commit

Permalink
Fix documentation (#2407)
Browse files Browse the repository at this point in the history
Summary:
This commit fixes multiple issues with documentation.

https://output.circle-artifacts.com/output/job/23245537-e57b-4b9d-9b81-b3df20996d1f/artifacts/0/docs/tutorials/audio_resampling_tutorial.html

1. Duplicated requirejs
The nbsphinx extension introduced in #2393 pulled a requirejs
which caused the initialization script to halt.
As a result, the right side bar was left uninitialized.

2. Undefined variable error
It turned out that PyTorch's theme expected the downstream projects
to define `collapsedSections` variable.
Currently console log shows `collapsedSections is not defined`.
As a result of this fix, we start to see the + symbol on left side.

3. Fix the behavior of default expand
Tweaks the right-side bar initialization behavior
so that expand-all only happens once, not at every resize.

4. Overwrite the link to GitHub
The `GitHub` tab in main-menu always linked PyTorch core.
This commit adds overwrite to torchaudio page

Pull Request resolved: #2407

Reviewed By: carolineechen

Differential Revision: D36612904

Pulled By: mthrok

fbshipit-source-id: 56aa7623a8925a241cf4790ac77a87424ad9237c
  • Loading branch information
mthrok authored and facebook-github-bot committed May 24, 2022
1 parent 38e530d commit 474510f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 23 deletions.
60 changes: 37 additions & 23 deletions docs/source/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
#}

{%- block footer %}

<script type="text/javascript">
var collapsedSections = []
</script>
{{ super() }}
<script type="text/javascript">
$(document).ready(function() {
Expand All @@ -69,30 +71,42 @@
$(".pytorch-call-to-action-links a[data-response='Run in Google Colab']").attr("href", colabLink);
$(".pytorch-call-to-action-links a[data-response='View on Github']").attr("href", githubLink);
}
});
</script>

{% if 'tutorial' in pagename %}
{#
# Override the right side menu bar behavior so that subsections
# are shown by default in tutorial page.
# Based off of
# https://github.com/pytorch/pytorch_sphinx_theme/blob/b4d00058a48604d8fb63771b513a50450f0ee188/pytorch_sphinx_theme/static/js/theme.js#L568-L579
#}
<script type="text/javascript">
$(window).ready(function() {
var original = window.sideMenus.bind;
window.sideMenus.bind = function() {
original();
$("#pytorch-right-menu a.reference.internal").each(function(i) {
if (this.classList.contains("not-expanded")) {
this.nextElementSibling.style.display = "block";
this.classList.remove("not-expanded");
this.classList.add("expanded");
}
});
};
var overwrite = function(_) {
if ($(this).length > 0) {
$(this)[0].href = "https://github.com/pytorch/audio"
}
}
// PC
$(".main-menu a:contains('GitHub')").each(overwrite);
// Mobile
$(".main-menu a:contains('Github')").each(overwrite);
});

{% if 'tutorial' in pagename %}
{#
# Override the right side menu bar behavior so that subsections
# are shown by default in tutorial page.
# Based off of
# https://github.com/pytorch/pytorch_sphinx_theme/blob/b4d00058a48604d8fb63771b513a50450f0ee188/pytorch_sphinx_theme/static/js/theme.js#L568-L579
#}
$(window).ready(function() {
var original = window.sideMenus.bind;
var startup = true;
window.sideMenus.bind = function() {
original();
if (startup) {
$("#pytorch-right-menu a.reference.internal").each(function(i) {
if (this.classList.contains("not-expanded")) {
this.nextElementSibling.style.display = "block";
this.classList.remove("not-expanded");
this.classList.add("expanded");
}
});
startup = false;
}
};
});
</script>
{% endif %}
{% endblock %}
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"nbsphinx",
]

nbsphinx_requirejs_path = ""

autodoc_member_order = "bysource"

# katex options
Expand Down

0 comments on commit 474510f

Please sign in to comment.