From 8ff1e94b68e2085c910acd6cc51868f396713de0 Mon Sep 17 00:00:00 2001 From: Nikita Titov Date: Thu, 23 Aug 2018 05:07:11 +0300 Subject: [PATCH] [docs] added possibility for collapsing sections (#1594) * added possibility to collapse long sections in docs * added contents in the installation guide --- docs/Installation-Guide.rst | 18 ++++++++++++++++++ docs/_static/js/script.js | 27 ++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/Installation-Guide.rst b/docs/Installation-Guide.rst index 526cd642ef6..d93dd964e90 100644 --- a/docs/Installation-Guide.rst +++ b/docs/Installation-Guide.rst @@ -5,6 +5,24 @@ Here is the guide for the build of LightGBM CLI version. For the build of Python-package and R-package, please refer to `Python-package`_ and `R-package`_ folders respectively. +**Contents** + +- `Windows <#windows>`__ + +- `Linux <#linux>`__ + +- `macOS <#macos>`__ + +- `Docker <#docker>`__ + +- `MPI Version <#build-mpi-version>`__ + +- `GPU Version <#build-gpu-version>`__ + +- `HDFS Version <#build-hdfs-version>`__ + +- `Java Wrapper <#build-java-wrapper>`__ + Windows ~~~~~~~ diff --git a/docs/_static/js/script.js b/docs/_static/js/script.js index 9fab7c8e241..8b00c3688f9 100644 --- a/docs/_static/js/script.js +++ b/docs/_static/js/script.js @@ -1,4 +1,29 @@ $(function() { $('a[href^="./"][href*=".rst"]').attr('href', (i, val) => { return val.replace('.rst', '.html'); }); /* Replace '.rst' with '.html' in all internal links like './[Something].rst[#anchor]' */ - $('.wy-nav-content').each(function () { this.style.setProperty('max-width', 'none', 'important'); }); + + $('.wy-nav-content').each(function () { this.style.setProperty('max-width', 'none', 'important'); }); /* Use wider container for the page content */ + + /* Collapse specified sections in the installation guide */ + if(window.location.pathname.toLocaleLowerCase().indexOf('installation-guide') != -1) { + $('').appendTo('body'); + var collapsable = ['#build-mpi-version', '#build-gpu-version', '#build-hdfs-version', '#build-java-wrapper']; + $.each(collapsable, function(i, val) { + var header = val + ' > :header:first'; + var content = val + ' :not(:header:first)'; + $(header).addClass('closed'); + $(content).hide(); + $(header).click(function() { + $(header).toggleClass('closed opened'); + $(content).slideToggle(0); + }); + }); + /* Uncollapse parent sections when nested section is specified in the URL or before navigate to it from navbar */ + function uncollapse(section) { + section.parents().each((i, val) => { $(val).children('.closed').click(); }); + } + uncollapse($(window.location.hash)); + $('.wy-menu.wy-menu-vertical li a.reference.internal').click(function() { + uncollapse($($(this).attr('href'))); + }); + } });