0

I'm using Sphinx and ReadTheDocs to build the documentation of my project.

I want to display several version to my end user so I built several branch in my admin area : active version

But when I'm displaying the doc in my browser (https://sepal-ui.readthedocs.io/en/v_1.1.0/), I cannot click on the flyout menu and change version.

flyout

Is it normal and how to make it functional ? I use a readthedocs.yml file (link). Am I missing something ?

mzjn
  • 48,958
  • 13
  • 128
  • 248
Pierrick Rambaud
  • 1,726
  • 1
  • 20
  • 47

1 Answers1

0

I had exactly the same issue.

I could solve it by adding a script (let's call it flyout.js) to my docs/source/_static directory:

$(document).ready(function() {
    var dropdownToggle = $('.sidebar-nav li a.has-dropdown');
    
    dropdownToggle.on('click', function(e) {
      e.preventDefault();
      var thisLink = $(this);
      var thisParent = thisLink.parent();
  
      if (thisParent.hasClass('open')) {
        thisParent.removeClass('open');
      } else {
        $('.sidebar-nav li').removeClass('open'); 
        thisParent.addClass('open');
      }
    });

    $(document).on('click', function(e) {
      if (!$(e.target).closest('.sidebar-nav li').length) {
        $('.sidebar-nav li').removeClass('open');
      }
    });
});

This scripts gets the flyout drop-down and add open/close features to it.

Once done, you have to add a reference to this script to your conf.py, as well as references to its dependencies:

html_js_files = [
    'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js', 
    '_static/flyout.js'
]

This worked for me. I have to confess I didn't find this by myself. I was stuck and after a lot of unsuccessful researches I ended up asking ChatGPT. Its answer was not perfect and had inconsistencies, but at least it led me to this (which is, when you think of it, somewhat unbelievable).

Shlublu
  • 10,917
  • 4
  • 51
  • 70