Commit 474510f2 authored by moto's avatar moto Committed by Facebook GitHub Bot
Browse files

Fix documentation (#2407)

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 https://github.com/pytorch/audio/pull/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: https://github.com/pytorch/audio/pull/2407

Reviewed By: carolineechen

Differential Revision: D36612904

Pulled By: mthrok

fbshipit-source-id: 56aa7623a8925a241cf4790ac77a87424ad9237c
parent 38e530d7
......@@ -54,7 +54,9 @@
#}
{%- block footer %}
<script type="text/javascript">
var collapsedSections = []
</script>
{{ super() }}
<script type="text/javascript">
$(document).ready(function() {
......@@ -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 %}
......@@ -54,6 +54,8 @@ extensions = [
"nbsphinx",
]
nbsphinx_requirejs_path = ""
autodoc_member_order = "bysource"
# katex options
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment