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

Upgrade readthedocs theme to v1.0.0 #2585

Merged
merged 24 commits into from Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions .csslintrc
@@ -1,9 +1,6 @@
--exclude-list = mkdocs/themes/mkdocs/css/bootstrap.min.css,
mkdocs/themes/readthedocs/css/bootstrap-custom.min.css,
mkdocs/themes/mkdocs/css/font-awesome.min.css,
mkdocs/themes/readthedocs/css/font-awesome-4.5.0.css,
mkdocs/themes/mkdocs/css/highlight.css,
mkdocs/themes/readthedocs/css/highlight.css,
mkdocs/themes/readthedocs/css/theme.css
--errors = known-properties,
box-sizing,
Expand Down
7 changes: 4 additions & 3 deletions .jshintignore
@@ -1,8 +1,9 @@
mkdocs/themes/**/js/highlight.pack.js
mkdocs/themes/**/js/jquery-**.min.js
mkdocs/themes/**/js/bootstrap.min.js
mkdocs/themes/**/js/modernizr-**.min.js
mkdocs/themes/mkdocs/js/highlight.pack.js
mkdocs/themes/mkdocs/js/bootstrap.min.js
mkdocs/themes/mkdocs/js/modernizr-**.min.js
mkdocs/themes/readthedocs/js/theme.js
mkdocs/themes/readthedocs/js/html5shiv.min.js
mkdocs/contrib/search/templates/search/lunr.js
mkdocs/contrib/search/lunr-language/lunr.**.js
mkdocs/contrib/search/lunr-language/tinyseg.js
12 changes: 9 additions & 3 deletions mkdocs/tests/config/config_tests.py
Expand Up @@ -135,13 +135,15 @@ def test_theme(self):
'locale': parse_locale('en'),
'include_search_page': True,
'search_index_only': False,
'analytics': {'gtag': None},
'analytics': {'anonymize_ip': False, 'gtag': None},
'highlightjs': True,
'hljs_languages': [],
'include_homepage_in_sidebar': True,
'prev_next_buttons_location': 'bottom',
'navigation_depth': 4,
'sticky_navigation': True,
'style_nav_header_background': None,
'logo': None,
'titles_only': False,
'collapse_navigation': True
}
Expand All @@ -152,13 +154,15 @@ def test_theme(self):
'locale': parse_locale('en'),
'include_search_page': True,
'search_index_only': False,
'analytics': {'gtag': None},
'analytics': {'anonymize_ip': False, 'gtag': None},
'highlightjs': True,
'hljs_languages': [],
'include_homepage_in_sidebar': True,
'prev_next_buttons_location': 'bottom',
'navigation_depth': 4,
'sticky_navigation': True,
'style_nav_header_background': None,
'logo': None,
'titles_only': False,
'collapse_navigation': True
}
Expand All @@ -173,13 +177,15 @@ def test_theme(self):
'locale': parse_locale('en'),
'include_search_page': True,
'search_index_only': False,
'analytics': {'gtag': None},
'analytics': {'anonymize_ip': False, 'gtag': None},
'highlightjs': True,
'hljs_languages': [],
'include_homepage_in_sidebar': True,
'prev_next_buttons_location': 'bottom',
'navigation_depth': 4,
'sticky_navigation': True,
'style_nav_header_background': None,
'logo': None,
'titles_only': False,
'collapse_navigation': True
}
Expand Down
210 changes: 114 additions & 96 deletions mkdocs/themes/readthedocs/base.html
@@ -1,153 +1,171 @@
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="{{ config.theme.locale|default('en') }}" > <!--<![endif]-->
<html class="writer-html5" lang="{{ config.theme.locale|default('en') }}" >
<head>
{%- block site_meta %}
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% if page and page.is_homepage %}<meta name="description" content="{{ config.site_description }}">{% endif %}
{% if config.site_author %}<meta name="author" content="{{ config.site_author }}">{% endif %}
{% if page and page.canonical_url %}<link rel="canonical" href="{{ page.canonical_url }}">{% endif %}
{% if config.site_favicon %}<link rel="shortcut icon" href="{{ config.site_favicon|url }}">
{% else %}<link rel="shortcut icon" href="{{ 'img/favicon.ico'|url }}">{% endif %}
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{%- if page and page.is_homepage %}<meta name="description" content="{{ config.site_description }}" />{%- endif %}
{%- if config.site_author %}<meta name="author" content="{{ config.site_author }}" />{%- endif %}
{%- if page and page.canonical_url %}<link rel="canonical" href="{{ page.canonical_url }}" />{%- endif %}
{%- if config.site_favicon %}
<link rel="shortcut icon" href="{{ config.site_favicon|url }}" />
{%- else %}
<link rel="shortcut icon" href="{{ 'img/favicon.ico'|url }}" />
{%- endif %}
{%- endblock %}

{%- block htmltitle %}
<title>{% if page and page.title and not page.is_homepage %}{{ page.title }} - {% endif %}{{ config.site_name }}</title>
<title>{% if page and page.title and not page.is_homepage %}{{ page.title }} - {% endif %}{{ config.site_name }}</title>
{%- endblock %}

{%- block styles %}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700" />

<link rel="stylesheet" href="{{ 'css/theme.css'|url }}" />
<link rel="stylesheet" href="{{ 'css/theme_extra.css'|url }}" />
{%- if config.theme.highlightjs %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
{%- endif %}
{%- for path in extra_css %}
<link href="{{ path }}" rel="stylesheet" />
{%- endfor %}
<link rel="stylesheet" href="{{ 'css/theme.css'|url }}" />
<link rel="stylesheet" href="{{ 'css/theme_extra.css'|url }}" />
{%- if config.theme.highlightjs %}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/github.min.css" />
{%- endif %}
{%- for path in extra_css %}
<link href="{{ path }}" rel="stylesheet" />
{%- endfor %}
{%- endblock %}

{%- block libs %}
{% if page %}
<script>
// Current page data
var mkdocs_page_name = {{ page.title|tojson|safe }};
var mkdocs_page_input_path = {{ page.file.src_path|string|tojson|safe }};
var mkdocs_page_url = {{ page.abs_url|tojson|safe }};
</script>
{% endif %}
<script src="{{ 'js/jquery-2.1.1.min.js'|url }}" defer></script>
<script src="{{ 'js/modernizr-2.8.3.min.js'|url }}" defer></script>
{%- if config.theme.highlightjs %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
{%- for lang in config.theme.hljs_languages %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/languages/{{lang}}.min.js"></script>
{%- endfor %}
<script>hljs.initHighlightingOnLoad();</script>
{%- endif %}
{% if page %}
<script>
// Current page data
var mkdocs_page_name = {{ page.title|tojson|safe }};
var mkdocs_page_input_path = {{ page.file.src_path|string|tojson|safe }};
var mkdocs_page_url = {{ page.abs_url|tojson|safe }};
</script>
{% endif %}
<script src="{{ 'js/jquery-3.6.0.min.js'|url }}" defer></script>
<!--[if lt IE 9]>
<script src="{{ 'js/html5shiv.min.js'|url }}"></script>
<![endif]-->
{%- if config.theme.highlightjs %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js"></script>
{%- for lang in config.theme.hljs_languages %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/languages/{{lang}}.min.js"></script>
{%- endfor %}
<script>hljs.initHighlightingOnLoad();</script>
{%- endif %}
{%- endblock %}

{%- block extrahead %} {% endblock %}

{%- block analytics %}
{%- if config.theme.analytics.gtag %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ config.theme.analytics.gtag }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ config.theme.analytics.gtag }}');
</script>
{%- elif config.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', '{{ config.google_analytics[0] }}', '{{ config.google_analytics[1] }}');
ga('send', 'pageview');
</script>
{% endif %}
{%- if config.theme.analytics.gtag %}
<script async src="https://www.googletagmanager.com/gtag/js?id={{ config.theme.analytics.gtag }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ config.theme.analytics.gtag }}'{%- if config.theme.analytics.anonymize_ip %}, {'anonymize_ip': true}{%- endif %});
</script>
{%- elif config.google_analytics %}
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', '{{ config.google_analytics[0] }}', '{{ config.google_analytics[1] }}');
{%- if config.theme.analytics.anonymize_ip %}ga('set', 'anonymizeIp', true);{%- endif %}
ga('send', 'pageview');
</script>
{% endif %}
{%- endblock %}
</head>

<body class="wy-body-for-nav" role="document">

<div class="wy-grid-for-nav">

{# SIDE NAV, TOGGLES ON MOBILE #}
{#- SIDE NAV, TOGGLES ON MOBILE #}
<nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
{%- block site_name %}
<a href="{{ nav.homepage.url|url }}" class="icon icon-home"> {{ config.site_name }}</a>
{%- endblock %}
{%- block search_button %}
{% if 'search' in config['plugins'] %}{% include "searchbox.html" %}{% endif %}
{%- endblock %}
<div class="wy-side-nav-search" {% if config.theme.style_nav_header_background %} style="background: {{config.theme.style_nav_header_background}}" {% endif %}>
{%- block site_name %}
{%- if config.theme.logo %}
<a href="{{ nav.homepage.url|url }}">
{%- else %}
<a href="{{ nav.homepage.url|url }}" class="icon icon-home"> {{ config.site_name }}
{%- endif %}
{%- if config.theme.logo %}
<img src="{{ config.theme.logo|url }}" class="logo" alt="{% trans %}Logo{% endtrans %}"/>
{%- endif %}
</a>
{%- endblock %}
{%- if config.extra.version %}
<div class="version">
{{ config.extra.version }}
</div>
{%- endif %}
{%- block search_button %}
{%- if 'search' in config['plugins'] %}{%- include "searchbox.html" %}{%- endif %}
{%- endblock %}
</div>

<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="{% trans %}Navigation menu{% endtrans %}">
{%- block site_nav %}
{%- set navlevel = 1 %}
{%- for nav_item in nav %}
{%- set navlevel = 1 %}
{%- for nav_item in nav %}
{%- if nav_item.is_section %}
<p class="caption"><span class="caption-text">{{ nav_item.title }}</span></p>
<ul{% if nav_item.active %} class="current"{% endif %}>
{%- for nav_item in nav_item.children %}
<li class="toctree-l{{ navlevel }}{% if nav_item.active %} current{% endif %}">
{%- include 'nav.html' %}
</li>
{%- endfor %}
</ul>
<p class="caption"><span class="caption-text">{{ nav_item.title }}</span></p>
<ul{% if nav_item.active %} class="current"{% endif %}>
{%- for nav_item in nav_item.children %}
<li class="toctree-l{{ navlevel }}{% if nav_item.active %} current{% endif %}">
{%- include 'nav.html' %}
</li>
{%- endfor %}
</ul>
{%- elif config.theme.include_homepage_in_sidebar or (not nav_item == nav.homepage) %}
<ul{% if nav_item.active %} class="current"{% endif %}>
<li class="toctree-l{{ navlevel }}{% if nav_item.active %} current{% endif %}">
{%- include 'nav.html' %}
</li>
</ul>
<ul{% if nav_item.active %} class="current"{% endif %}>
<li class="toctree-l{{ navlevel }}{% if nav_item.active %} current{% endif %}">
{%- include 'nav.html' %}
</li>
</ul>
{%- endif %}
{%- endfor %}
{%- endblock %}
{%- endfor %}
{%- endblock %}
</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

{# MOBILE NAV, TRIGGLES SIDE NAV ON TOGGLE #}
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="{{ nav.homepage.url|url }}">{{ config.site_name }}</a>
{#- MOBILE NAV, TRIGGLES SIDE NAV ON TOGGLE #}
<nav class="wy-nav-top" role="navigation" aria-label="{% trans %}Top Navigation{% endtrans %}" {% if config.theme.style_nav_header_background %} style="background: {{config.theme.style_nav_header_background}}" {% endif %}>
Sparticuz marked this conversation as resolved.
Show resolved Hide resolved
{%- block mobile_nav %}
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="{{ nav.homepage.url|url }}">{{ config.site_name }}</a>
{% endblock %}
</nav>

{# PAGE CONTENT #}
{#- PAGE CONTENT #}
<div class="wy-nav-content">
<div class="rst-content">
{% include "breadcrumbs.html" %}
<div role="main">
<div class="section">
{%- include "breadcrumbs.html" %}
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
oprypin marked this conversation as resolved.
Show resolved Hide resolved
<div class="section" itemprop="articleBody">
{% block content %}
{{ page.content }}
{% endblock %}
</div>
</div>
{%- block footer %}
{% include "footer.html" %}
{% endblock %}
{%- block footer %}
{%- include "footer.html" %}
{% endblock %}
</div>
</div>

</section>

</div>

{% include "versions.html" %}
{% include "versions.html" -%}

{%- block scripts %}
<script>var base_url = '{{ base_url }}';</script>
Expand Down