From 2bb8782c8041ce306d11236d529a8b0b5b1aeb6f Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Tue, 18 Apr 2017 00:21:12 -0400 Subject: [PATCH 01/14] Set margin-bottom to 0 for captions in figures The issue here is that figures have a margin of 24px and `p` tags also have a margin of 24px so figure caption get huge 48px margins on the bottom. --- sass/_theme_rst.sass | 1 + 1 file changed, 1 insertion(+) diff --git a/sass/_theme_rst.sass b/sass/_theme_rst.sass index ef0ebda6..2a927ba4 100644 --- a/sass/_theme_rst.sass +++ b/sass/_theme_rst.sass @@ -26,6 +26,7 @@ margin-bottom: $base-line-height p.caption font-style: italic + margin-bottom: 0px div.figure.align-center text-align: center From 079faa00d3a64d74cd15d63c78e25623b2c3fddd Mon Sep 17 00:00:00 2001 From: Jesse Tan Date: Mon, 18 Dec 2017 16:06:21 +0100 Subject: [PATCH 02/14] Do not add border to active links with level >1 --- sass/_theme_layout.sass | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sass/_theme_layout.sass b/sass/_theme_layout.sass index 626d1f45..10b44443 100644 --- a/sass/_theme_layout.sass +++ b/sass/_theme_layout.sass @@ -78,8 +78,6 @@ position: relative background: $menu-vertical-background-color border: none - border-bottom: solid 1px darken($menu-vertical-background-color, 20%) - border-top: solid 1px darken($menu-vertical-background-color, 20%) padding-left: $gutter -4px +font-smooth &:hover @@ -94,6 +92,10 @@ line-height: 1.6em color: darken($menu-link-medium, 30%) + li.toctree-l1.current > a + border-bottom: solid 1px darken($menu-vertical-background-color, 20%) + border-top: solid 1px darken($menu-vertical-background-color, 20%) + // This is the on state for pages beyond second level li.toctree-l1.current li.toctree-l2, li.toctree-l2.current li.toctree-l3 > ul @@ -123,8 +125,6 @@ display: block background: darken($menu-vertical-background-color, 25%) padding: $gutter / 4 $gutter * 3.5 - border-top: none - border-bottom: none a:hover span.toctree-expand color: $menu-link-medium span.toctree-expand From 9b30e1b79396c25fab4a108cc1f18106c2cb859c Mon Sep 17 00:00:00 2001 From: Jesse Tan Date: Tue, 19 Dec 2017 12:47:42 +0100 Subject: [PATCH 03/14] Correctly change current link in toctree if toplevel headers are on same page Fixes #516 --- js/theme.js | 59 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/js/theme.js b/js/theme.js index 9fb32829..4152cb4a 100644 --- a/js/theme.js +++ b/js/theme.js @@ -105,35 +105,42 @@ function ThemeNav () { nav.reset = function () { // Get anchor from URL and open up nested nav var anchor = encodeURI(window.location.hash); - if (anchor) { - try { - var link = $('.wy-menu-vertical') - .find('[href="' + anchor + '"]'); - // If we didn't find a link, it may be because we clicked on - // something that is not in the sidebar (eg: when using - // sphinxcontrib.httpdomain it generates headerlinks but those - // aren't picked up and placed in the toctree). So let's find - // the closest header in the document and try with that one. - if (link.length === 0) { - var doc_link = $('.document a[href="' + anchor + '"]'); - var closest_section = doc_link.closest('div.section'); - // Try again with the closest section entry. - link = $('.wy-menu-vertical') - .find('[href="#' + closest_section.attr("id") + '"]'); - } - // If we found a matching link then reset current and re-apply - // otherwise retain the existing match - if (link.length > 0) { - $('.wy-menu-vertical li.toctree-l1 li.current').removeClass('current'); - link.closest('li.toctree-l2').addClass('current'); - link.closest('li.toctree-l3').addClass('current'); - link.closest('li.toctree-l4').addClass('current'); - } + + try { + if (!anchor) { + anchor = '#'; } - catch (err) { - console.log("Error expanding nav for anchor", err); + var link = $('.wy-menu-vertical') + .find('[href="' + anchor + '"]'); + // If we didn't find a link, it may be because we clicked on + // something that is not in the sidebar (eg: when using + // sphinxcontrib.httpdomain it generates headerlinks but those + // aren't picked up and placed in the toctree). So let's find + // the closest header in the document and try with that one. + if (link.length === 0) { + var doc_link = $('.document a[href="' + anchor + '"]'); + var closest_section = doc_link.closest('div.section'); + // Try again with the closest section entry. + link = $('.wy-menu-vertical') + .find('[href="#' + closest_section.attr("id") + '"]'); + } + // If we found a matching link then reset current and re-apply + // otherwise retain the existing match + if (link.length > 0) { + $('.wy-menu-vertical .current').removeClass('current'); + link.addClass('current'); + link.closest('li.toctree-l1').addClass('current'); + link.closest('li.toctree-l1').parent().addClass('current'); + link.closest('li.toctree-l1').addClass('current'); + link.closest('li.toctree-l2').addClass('current'); + link.closest('li.toctree-l3').addClass('current'); + link.closest('li.toctree-l4').addClass('current'); } } + catch (err) { + console.log("Error expanding nav for anchor", err); + } + }; nav.onScroll = function () { From bf848802a63fcf578febde57fc94a67f8623d548 Mon Sep 17 00:00:00 2001 From: Jesse Tan Date: Thu, 28 Dec 2017 10:22:16 +0100 Subject: [PATCH 04/14] Uglify during build --- Gruntfile.js | 23 +++++++++++++++++++++-- package.json | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9ca0ce09..99fde4e9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -111,7 +111,26 @@ module.exports = function(grunt) { dest: 'sphinx_rtd_theme/static/js/theme.js' } }, - + uglify: { + dist: { + options: { + sourceMap: false, + mangle: { + reserved: ['jQuery'] // Leave 'jQuery' identifier unchanged + }, + ie8: true // compliance with IE 6-8 quirks + }, + files: [{ + expand: true, + src: ['sphinx_rtd_theme/static/js/*.js', '!sphinx_rtd_theme/static/js/*.min.js'], + dest: 'sphinx_rtd_theme/static/js/', + rename: function (dst, src) { + // Use unminified file name for minified file + return src; + } + }] + } + }, exec: { bower_update: { cmd: 'bower update' @@ -162,5 +181,5 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-browserify'); grunt.registerTask('default', ['exec:bower_update','clean','copy:fonts','sass:dev','browserify:dev','exec:build_sphinx','connect','open','watch']); - grunt.registerTask('build', ['exec:bower_update','clean','copy:fonts','sass:build','browserify:build','exec:build_sphinx']); + grunt.registerTask('build', ['exec:bower_update','clean','copy:fonts','sass:build','browserify:build','uglify','exec:build_sphinx']); } diff --git a/package.json b/package.json index 03f08f91..0141962c 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "grunt-contrib-connect": "^1.0.2", "grunt-contrib-copy": "~1.0.0", "grunt-contrib-sass": "~1.0.0", + "grunt-contrib-uglify": "^3.3.0", "grunt-contrib-watch": "~1.0.0", "grunt-exec": "~1.0.1", "grunt-open": "0.2.3", From 067a6794f0d799892c78c98168574d8669524d19 Mon Sep 17 00:00:00 2001 From: Jesse Tan Date: Fri, 29 Dec 2017 16:23:17 +0100 Subject: [PATCH 05/14] Match minor dependency version for consistency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0141962c..9cb62f44 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "grunt-contrib-connect": "^1.0.2", "grunt-contrib-copy": "~1.0.0", "grunt-contrib-sass": "~1.0.0", - "grunt-contrib-uglify": "^3.3.0", + "grunt-contrib-uglify": "~3.3.0", "grunt-contrib-watch": "~1.0.0", "grunt-exec": "~1.0.1", "grunt-open": "0.2.3", From 636f37ae6794281a2d99efbed0ec68d6b4a1ed93 Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Mon, 15 Jan 2018 16:01:02 -0500 Subject: [PATCH 06/14] Remove base64 background image (#537) * Remove base64 background image * Address review comments --- sass/_theme_layout.sass | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sass/_theme_layout.sass b/sass/_theme_layout.sass index 626d1f45..499dd233 100644 --- a/sass/_theme_layout.sass +++ b/sass/_theme_layout.sass @@ -247,9 +247,7 @@ .wy-body-for-nav - background: left repeat-y $section-background-color - background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDoxOERBMTRGRDBFMUUxMUUzODUwMkJCOThDMEVFNURFMCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDoxOERBMTRGRTBFMUUxMUUzODUwMkJCOThDMEVFNURFMCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjE4REExNEZCMEUxRTExRTM4NTAyQkI5OEMwRUU1REUwIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjE4REExNEZDMEUxRTExRTM4NTAyQkI5OEMwRUU1REUwIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+EwrlwAAAAA5JREFUeNpiMDU0BAgwAAE2AJgB9BnaAAAAAElFTkSuQmCC) - background-size: $nav-desktop-width 1px + background: $section-background-color .wy-grid-for-nav position: absolute From 5062c200d6e956cb8a96ec2940177efab7d715db Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Mon, 15 Jan 2018 16:09:24 -0500 Subject: [PATCH 07/14] Do not set the default role for the body tag (#542) * Do not set the default role for the body tag See https://www.w3.org/TR/html5/sections.html#the-body-element And: https://github.com/sphinx-doc/sphinx/pull/3495 * Remove nav role from nav tag --- sphinx_rtd_theme/layout.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx_rtd_theme/layout.html b/sphinx_rtd_theme/layout.html index e647bddd..21ddbaf5 100644 --- a/sphinx_rtd_theme/layout.html +++ b/sphinx_rtd_theme/layout.html @@ -86,7 +86,7 @@ - + {% block extrabody %} {% endblock %}
@@ -152,7 +152,7 @@
{# MOBILE NAV, TRIGGLES SIDE NAV ON TOGGLE #} -