Skip to content

Conversation

@Bgreen23
Copy link
Contributor

This PR updates the expand/collapse script to work with the tutorial and docs layout pages. The array has been moved to those layout files to avoid potential issues of shared caption titles between the two left navs. There are two additional PR's(one for docs and one for tutorials) that will need to be merged alongside this PR.
PR for tutorials: pytorch/tutorials#1372
PR for docs: pytorch/pytorch#52703

@Bgreen23
Copy link
Contributor Author

Bgreen23 commented Feb 24, 2021

Sections are set to be expanded by default. To collapse a section for the Docs go to the https://github.com/pytorch/pytorch/blob/master/docs/source/_templates/layout.html file and for tutorials go to https://github.com/pytorch/tutorials/blob/master/_templates/layout.html.
In those files, there is a script with an array.

<script type="text/javascript">
    var collapsedSections = [];
 </script>

Add the caption titles of the sections that should be collapsed to the 'collapsedSections' array and those sections will be collapsed on next build

@brianjo
Copy link
Contributor

brianjo commented Feb 24, 2021

Thanks @Bgreen23! Just to confirm, the javascript component is optional, so sites using this can expect this theme update to work without further customization?

@Bgreen23
Copy link
Contributor Author

Thanks @Bgreen23! Just to confirm, the javascript component is optional, so sites using this can expect this theme update to work without further customization?

@brianjo I'm not sure how other sites utilize this theme, but this shouldn't cause any issues. The JS looks for collapsedSection and then adds the classes to expand/collapse the sections. If collapsedSection is not set then the newly added JS will get skipped over.

@brianjo brianjo merged commit 564c5cb into pytorch:master Feb 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants