Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decouple the theme JS from readthedocs.org #3968

Merged
merged 12 commits into from Jun 6, 2018
28 changes: 20 additions & 8 deletions docs/badges.rst
Expand Up @@ -26,13 +26,25 @@ Now you can pass the ``style`` GET argument,
to get custom styled badges same as you would for shields.io.
If no argument is passed, ``flat`` is used as default.

STYLE | BADGE
------------ | -------------
flat | ![Flat Badge](https://readthedocs.org/projects/pip/badge/?version=latest&style=flat)
flat-square | ![Flat-Square Badge](https://readthedocs.org/projects/pip/badge/?version=latest&style=flat-square)
for-the-badge | ![ Badge](https://readthedocs.org/projects/pip/badge/?version=latest&style=for-the-badge)
plastic | ![Plastic Badge](https://readthedocs.org/projects/pip/badge/?version=latest&style=plastic)
social | ![Social Badge](https://readthedocs.org/projects/pip/badge/?version=latest&style=social)
+---------------+---------------------+
| STYLE | BADGE |
+===============+=====================+
| flat | |Flat Badge| |
+---------------+---------------------+
| flat-square | |Flat-Square Badge| |
+---------------+---------------------+
| for-the-badge | |Badge| |
+---------------+---------------------+
| plastic | |Plastic Badge| |
+---------------+---------------------+
| social | |Social Badge| |
+---------------+---------------------+

.. |Flat Badge| image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=flat
.. |Flat-Square Badge| image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=flat-square
.. |Badge| image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=for-the-badge
.. |Plastic Badge| image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=plastic
.. |Social Badge| image:: https://readthedocs.org/projects/pip/badge/?version=latest&style=social


Project Pages
Expand Down Expand Up @@ -63,4 +75,4 @@ since it will stay up to date with your Read the Docs project::
.. |red| image:: https://media.readthedocs.org/static/projects/badges/failing.svg
.. |yellow| image:: https://media.readthedocs.org/static/projects/badges/unknown.svg
.. |nbsp| unicode:: 0xA0
:trim:
:trim:
21 changes: 12 additions & 9 deletions readthedocs/core/static-src/core/js/doc-embed/sphinx.js
Expand Up @@ -4,7 +4,7 @@


var rtddata = require('./rtd-data');
var sphinx_theme = require('sphinx-rtd-theme');
var sphinx_theme;


function init() {
Expand All @@ -26,13 +26,16 @@ function init() {
}
});

/// Read the Docs Sphinx theme code
if (!("builder" in rtd) || "builder" in rtd && rtd["builder"] !== "mkdocs") {
/// Inject the Read the Docs Sphinx theme code
/// This is necessary on older versions of the RTD theme (<0.4.0)
/// and on themes other then the RTD theme (used for the version menu)
if ((rtd.builder === undefined || rtd.builder === 'sphinx') && window.SphinxRtdTheme === undefined) {
sphinx_theme = require('sphinx-rtd-theme'); // eslint-disable-line global-require

var theme = sphinx_theme.ThemeNav;

// TODO dont do this, the theme should explicitly check when it has be
// already enabled. See:
// https://github.com/snide/sphinx_rtd_theme/issues/250
// Enable the version selector (flyout) menu
// This is necessary for 3rd party themes
$(document).ready(function () {
setTimeout(function () {
if (!theme.navBar) {
Expand All @@ -42,11 +45,11 @@ function init() {
});

if (rtd.is_rtd_theme()) {
// Because generated HTML will not immediately have the new
// scroll element, gracefully handle failover by adding it
// dynamically.
// Add a scrollable element to the sidebar on the RTD sphinx theme
// This fix is for sphinx_rtd_theme<=0.1.8
var navBar = jquery('div.wy-side-scroll:first');
if (!navBar.length) {
console.log('Applying theme sidebar fix...');
var navInner = jquery('nav.wy-nav-side:first');
var navScroll = $('<div />')
.addClass('wy-side-scroll');
Expand Down