$(document).ready(function () {
  var sections = $('div.section');
  var activeLink = null;
  var bottomHeightThreshold = $(document).height() - 30;

  $(window).scroll(function (event) {
    var distanceFromTop = $(this).scrollTop();
    var currentSection = null;

    if(distanceFromTop + window.innerHeight > bottomHeightThreshold) {
      currentSection = $(sections[sections.length - 1]);
    }
    else {
      sections.each(function () {
        var section = $(this);
        if (section.offset().top - 1 < distanceFromTop) {
          currentSection = section;
        }
      });
    }

    if (activeLink) {
      activeLink.parent().removeClass('active');
    }

    if (currentSection) {
      activeLink = $('.sphinxsidebar a[href="#' + currentSection.attr('id') + '"]');
      activeLink.parent().addClass('active');
    }

    const tables = document.querySelectorAll('.py-attribute-table[data-move-to-id]');
    tables.forEach(table => {
      let element = document.getElementById(table.getAttribute('data-move-to-id'));
      let parent = element.parentNode;
      // insert ourselves after the element
      parent.insertBefore(table, element.nextSibling);
    });
  });
});

@@ -835,16 +835,21 @@
    %7D%0A%0A  
+%7D);%0A%0A
   const 
@@ -924,18 +924,16 @@
 -id%5D');%0A
-  
   tables
@@ -952,18 +952,16 @@
 le =%3E %7B%0A
-  
     let 
@@ -1038,18 +1038,16 @@
 ));%0A    
- 
- 
 let pare
@@ -1071,18 +1071,16 @@
 ntNode;%0A
-  
     // i
@@ -1117,18 +1117,16 @@
 ent%0A    
- 
- 
 parent.i
@@ -1166,24 +1166,16 @@
 bling);%0A
-    %7D);%0A
   %7D);%0A%7D)

Move table JS outside of scrolling