Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
499b061
Add condition for sticky toc
DrDrij Jun 6, 2021
7923265
Merge branch 'master' into rhs-toc-adjustments
AakashGfude Jun 11, 2021
2e6acdd
Add link highlighting function for page TOC
DrDrij Jun 22, 2021
0fe9120
Add styles for page TOC highlighting
DrDrij Jun 22, 2021
6f9d006
Page TOC style tweak
DrDrij Jun 22, 2021
0b98935
Hide nested pages in page TOC
DrDrij Jun 22, 2021
17ccb9e
Add sticky_toc option to conf
DrDrij Jun 22, 2021
85ed2f2
Only highlight if sticky
DrDrij Jun 22, 2021
341ee62
Add context to RHS TOC parameter
DrDrij Sep 9, 2021
d5e85ab
Add context to RHS TOC parameter
DrDrij Sep 9, 2021
8fe2483
Add context to RHS TOC parameter
DrDrij Sep 9, 2021
7f004f0
Add context to RHS TOC parameter
DrDrij Sep 9, 2021
cb28e45
merging master
AakashGfude May 3, 2022
1bd3d58
editing pre-commit config
AakashGfude May 3, 2022
43030f4
theme.conf
AakashGfude May 5, 2022
aa6f864
setup.py
AakashGfude May 5, 2022
67bf824
versions in pre-commit
AakashGfude May 5, 2022
23777b6
ensuring markupsafe is right version
AakashGfude May 5, 2022
db6cdca
minor setup fix
AakashGfude May 5, 2022
ba7f601
markupsafe
AakashGfude May 5, 2022
f22348c
checkout branch of lecture-python-programming.myst with rhs toc settings
mmcky May 6, 2022
adde74b
checkout correct branch after cloning
mmcky May 6, 2022
c932aa7
checkout inside repo
mmcky May 6, 2022
42da195
sticky_toc
AakashGfude May 12, 2022
3ec412e
sphinx version
AakashGfude May 12, 2022
20c8790
changing install order
AakashGfude May 12, 2022
91f2ec9
fixing sphinx versions
AakashGfude May 12, 2022
d00b16f
Merge branch 'master' into rhs-toc-adjustments
AakashGfude Apr 28, 2023
eb7e422
Merge branch 'master' into rhs-toc-adjustments
AakashGfude Apr 30, 2023
b50aed5
changing to sticky_contents
AakashGfude Apr 30, 2023
be53f5c
input checkbox styling
AakashGfude May 1, 2023
05cd737
updating master
AakashGfude May 1, 2023
0acf72c
keeping it True by deafult
AakashGfude May 3, 2023
9abf43c
resolved merge conflict
AakashGfude May 3, 2023
8416d73
sticky_contents default reverted
AakashGfude May 4, 2023
6f47f6a
Merge branch 'master' into rhs-toc-adjustments
AakashGfude May 4, 2023
06127b2
running pre-commit
AakashGfude May 4, 2023
a75930f
update to python=3.10
mmcky May 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
auto-update-conda: true
auto-activate-base: true
miniconda-version: 'latest'
python-version: 3.9
python-version: "3.10"
environment-file: lecture-python-programming.myst/environment.yml
activate-environment: lecture-python-programming
- name: Install quantecon-book-theme
Expand Down
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ repos:
quantecon_book_theme/static/.*|
quantecon_book_theme/theme.conf
)$
additional_dependencies: ['markupsafe==2.0.1']
4 changes: 4 additions & 0 deletions quantecon_book_theme/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@

<div class="qe-page__toc">

{% if theme_sticky_contents is defined and theme_sticky_contents is sameas true %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AakashGfude is the option called theme_sticky_contents or sticky_contents

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme_ is appended by sphinx itself for html_theme_options. Unfortunately, it's neither 😬. The correct one is theme_sticky_toc. I have corrected it.

<div class="inner sticky">
{%- else %}
<div class="inner">
{%- endif %}

{% set page_toc = generate_toc_html() %}

Expand Down

This file was deleted.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion quantecon_book_theme/theme.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Note: this should only be changed in src/jinja/theme.conf.j2
[theme]
inherit = pydata_sphinx_theme
stylesheet = quantecon-book-theme.531cac136e77cfd0e9b23b36a70b130a.css
stylesheet = quantecon-book-theme.721c9303961d2782852318325281aac8.css

[options]
single_page = False
Expand All @@ -28,4 +28,5 @@ keywords =
twitter =
twitter_logo_url =
og_logo_url =
sticky_contents = False
persistent_sidebar = False
2 changes: 2 additions & 0 deletions src/jinja/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ keywords =
twitter =
twitter_logo_url =
og_logo_url =
sticky_contents = False
persistent_sidebar = False
1 change: 1 addition & 0 deletions src/jinja/theme.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ keywords =
twitter =
twitter_logo_url =
og_logo_url =
sticky_contents = False
persistent_sidebar = False
8 changes: 7 additions & 1 deletion src/js/quantecon-book-theme.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// ScrollSpy Plugin: https://github.com/r3plica/Scrollspy
!function($,window,document,undefined){$.fn.extend({scrollspy:function(options){var defaults={namespace:"scrollspy",activeClass:"active",animate:!1,duration:1e3,offset:0,container:window,replaceState:!1};options=$.extend({},defaults,options);var add=function(ex1,ex2){return parseInt(ex1,10)+parseInt(ex2,10)},findElements=function(links){for(var elements=[],i=0;i<links.length;i++){var link=links[i],hash=$(link).attr("href"),element=$(hash);if(element.length>0){var top=Math.floor(element.offset().top),bottom=top+Math.floor(element.outerHeight());elements.push({element:element,hash:hash,top:top,bottom:bottom})}}return elements},findLink=function(links,hash){for(var i=0;i<links.length;i++){var link=$(links[i]);if(link.attr("href")===hash)return link}},resetClasses=function(links){for(var i=0;i<links.length;i++)$(links[i]).parent().removeClass(options.activeClass)},scrollArea="";return this.each(function(){for(var element=this,container=$(options.container),links=$(element).find("a"),i=0;i<links.length;i++){var link=links[i];$(link).on("click",function(e){var target=$(this).attr("href"),$target=$(target);if($target.length>0){var top=add($target.offset().top,options.offset);options.animate?$("html, body").animate({scrollTop:top},options.duration):window.scrollTo(0,top),e.preventDefault()}})}resetClasses(links);var elements=findElements(links),trackChanged=function(){for(var link,position={top:add($(this).scrollTop(),Math.abs(options.offset)),left:$(this).scrollLeft()},i=0;i<elements.length;i++){var current=elements[i];if(position.top>=current.top&&position.top<current.bottom){var hash=current.hash;if(link=findLink(links,hash)){options.onChange&&scrollArea!==hash&&(options.onChange(current.element,$(element),position),scrollArea=hash),options.replaceState&&history.replaceState({},"","/"+hash),resetClasses(links),link.parent().addClass(options.activeClass);break}}}!link&&"exit"!==scrollArea&&options.onExit&&(options.onExit($(element),position),resetClasses(links),scrollArea="exit",options.replaceState&&history.replaceState({},"","/"))};container.bind("scroll."+options.namespace,function(){trackChanged()}),$(document).ready(function(e){trackChanged()})})}})}(jQuery,window,document);
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ScrollSpy plugin is minified/obfuscated code that makes debugging and maintenance difficult. Consider using a readable version during development or include a reference to the original source for better maintainability.

Copilot uses AI. Check for mistakes.

document.addEventListener("DOMContentLoaded", function(){

// Avoid `console` errors in browsers that lack a console.
Expand Down Expand Up @@ -315,4 +318,7 @@ document.addEventListener("DOMContentLoaded", function(){
touch: false,
});

});
// Highlight page TOC links as user scrolls
$(".sticky #bd-toc-nav ul").scrollspy();

Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector .sticky #bd-toc-nav ul assumes a specific DOM structure. Consider making this more robust by checking if the element exists before initializing scrollspy to avoid potential errors.

Suggested change
var $tocNav = $(".sticky #bd-toc-nav ul");
if ($tocNav.length > 0) {
$tocNav.scrollspy();
}

Copilot uses AI. Check for mistakes.
})
19 changes: 17 additions & 2 deletions src/scss/quantecon-book-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,10 @@ tt {
width: 200px;

.inner {
height: 100%;
&.sticky {
position: sticky;
top: 7rem;
}
}

&-header {
Expand Down Expand Up @@ -500,6 +503,13 @@ tt {
opacity: 1;
}
}

&.active {
>a {
//color: $color-primary;
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented out color property. Commented code should be cleaned up rather than left in the codebase.

Suggested change
//color: $color-primary;

Copilot uses AI. Check for mistakes.
font-weight: bold;
}
}
}
}
.logo {
Expand Down Expand Up @@ -532,7 +542,7 @@ tt {
}

.nav>.active>ul {
display: block;
// display: block;
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented out display property. If this rule needs to be disabled, consider removing it entirely or documenting why it's commented out.

Suggested change
// display: block;

Copilot uses AI. Check for mistakes.
}

.nav .nav {
Expand Down Expand Up @@ -1483,6 +1493,11 @@ dl.module, dl.class, dl.exception, dl.function, dl.decorator, dl.data, dl.method
}
}

.toctree-checkbox[type="checkbox"] {
position: absolute;
left: 400rem;
Copy link

Copilot AI Aug 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value 400rem is a magic number that appears to be used to hide elements off-screen. Consider using a more semantic approach like left: -9999px or display: none with proper accessibility considerations.

Suggested change
left: 400rem;
left: -9999px;

Copilot uses AI. Check for mistakes.
}

.toctree-wrapper {
.caption-text {
font-weight: normal;
Expand Down