Skip to content

Commit 6a0cecf

Browse files
Merge branch 'header-background' of github.com:nokia/sphinx_rtd_theme into header-background
2 parents 50acb56 + 78495af commit 6a0cecf

File tree

7 files changed

+64
-46
lines changed

7 files changed

+64
-46
lines changed

docs/changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ master
1111
New Features
1212
-------------
1313

14+
1415
Fixes
1516
-----
1617

18+
* Fix scrolling to active item in sidebar on load (#214)
19+
* Style caption link for code and literal blocks
1720
* Fix inconsistent font size and line height for autodoc "raises" and "returns" (#267)
1821

22+
1923
Other Changes
2024
--------------
2125

docs/configuring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ file of this repository, and can be defined in your project's ``conf.py`` via
1919
2020
html_theme_options = {
2121
'canonical_url': '',
22-
'analytics_id': '',
22+
'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
2323
'logo_only': False,
2424
'display_version': True,
2525
'prev_next_buttons_location': 'bottom',

js/theme.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function ThemeNav () {
152152
link.closest('li.toctree-l2').addClass('current');
153153
link.closest('li.toctree-l3').addClass('current');
154154
link.closest('li.toctree-l4').addClass('current');
155+
link[0].scrollIntoView();
155156
}
156157
}
157158
catch (err) {

sass/_theme_layout.sass

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,16 @@ html
3131
width: $nav-desktop-width
3232

3333
header, p.caption
34+
color: $nav-caption
3435
height: $base-font-size * 2
3536
display: inline-block
3637
line-height: $base-font-size * 2
3738
padding: 0 $gutter
38-
margin-bottom: 0
39+
margin: $base-line-height / 2 0 0 0
3940
display: block
4041
font-weight: bold
4142
text-transform: uppercase
42-
font-size: 80%
43+
font-size: 85%
4344
white-space: nowrap
4445

4546
ul
@@ -362,6 +363,8 @@ footer
362363
color: $text-medium
363364
font-size: 90%
364365

366+
.genindextable li > ul
367+
margin-left: $base-line-height
365368

366369
+media($tablet)
367370
.wy-body-for-nav

sass/_theme_rst.sass

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
@extend h2
173173

174174
// This is the #href that shows up on hover. Sphinx's is terrible so I hack it away.
175-
h1, h2, h3, h4, h5, h6, dl dt, p.caption, table > caption
175+
h1, h2, h3, h4, h5, h6, dl dt, p.caption, table > caption, .code-block-caption
176176
.headerlink
177177
visibility: hidden
178178
font-size: 14px

sass/_theme_variables.sass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ $nav-link-color: $blue
5151
$nav-link-color-visited: $purple
5252
$nav-link-color-hover: lighten($nav-link-color, 6%) !default
5353
$nav-link-color-alt: hsl(33, 100%, 51%)
54+
$nav-caption: desaturate($blue, 15%)
5455

5556
// Sidebar colors
5657
$sidebar-background-color: $table-stripe-color

sphinx_rtd_theme/layout.html

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,42 @@
2828
<link rel="canonical" href="{{ theme_canonical_url }}{{ pagename }}.html"/>
2929
{% endif %}
3030

31-
{# CSS #}
32-
33-
{# OPENSEARCH #}
34-
{% if not embedded %}
35-
{% if use_opensearch %}
36-
<link rel="search" type="application/opensearchdescription+xml"
37-
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
38-
href="{{ pathto('_static/opensearch.xml', 1) }}"/>
31+
{# JAVASCRIPTS #}
32+
<script type="text/javascript" src="{{ pathto('_static/js/modernizr.min.js', 1) }}"></script>
33+
{%- if not embedded %}
34+
{# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #}
35+
{% if sphinx_version >= "1.8.0" %}
36+
<script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
37+
{%- for scriptfile in script_files %}
38+
{{ js_tag(scriptfile) }}
39+
{%- endfor %}
40+
{% else %}
41+
<script type="text/javascript">
42+
var DOCUMENTATION_OPTIONS = {
43+
URL_ROOT:'{{ url_root }}',
44+
VERSION:'{{ release|e }}',
45+
LANGUAGE:'{{ language }}',
46+
COLLAPSE_INDEX:false,
47+
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
48+
HAS_SOURCE: {{ has_source|lower }},
49+
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
50+
};
51+
</script>
52+
{%- for scriptfile in script_files %}
53+
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
54+
{%- endfor %}
3955
{% endif %}
56+
<script type="text/javascript" src="{{ pathto('_static/js/theme.js', 1) }}"></script>
4057

41-
{% endif %}
58+
{# OPENSEARCH #}
59+
{%- if use_opensearch %}
60+
<link rel="search" type="application/opensearchdescription+xml"
61+
title="{% trans docstitle=docstitle|e %}Search within {{ docstitle }}{% endtrans %}"
62+
href="{{ pathto('_static/opensearch.xml', 1) }}"/>
63+
{%- endif %}
64+
{%- endif %}
4265

66+
{# CSS #}
4367
<link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" />
4468
<link rel="stylesheet" href="{{ pathto('_static/pygments.css', 1) }}" type="text/css" />
4569
{%- for css in css_files %}
@@ -49,6 +73,7 @@
4973
<link rel="stylesheet" href="{{ pathto(css, 1) }}" type="text/css" />
5074
{%- endif %}
5175
{%- endfor %}
76+
5277
{%- for cssfile in extra_css_files %}
5378
<link rel="stylesheet" href="{{ pathto(cssfile, 1) }}" type="text/css" />
5479
{%- endfor %}
@@ -74,10 +99,6 @@
7499
{%- endif %}
75100
{%- endblock %}
76101
{%- block extrahead %} {% endblock %}
77-
78-
{# Keep modernizr in head - http://modernizr.com/docs/#installing #}
79-
<script src="{{ pathto('_static/js/modernizr.min.js', 1) }}"></script>
80-
81102
</head>
82103

83104
<body class="wy-body-for-nav">
@@ -185,41 +206,29 @@
185206
</div>
186207
{% include "versions.html" %}
187208

188-
{% if not embedded %}
189-
190-
{# XXX Sphinx 1.8.0 made this an external js-file, quick fix until we refactor the template to inherert more blocks directly from sphinx #}
191-
{% if sphinx_version >= "1.8.0" %}
192-
<script type="text/javascript" id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
193-
{%- for scriptfile in script_files %}
194-
{{ js_tag(scriptfile) }}
195-
{%- endfor %}
196-
{% else %}
197-
<script type="text/javascript">
198-
var DOCUMENTATION_OPTIONS = {
199-
URL_ROOT:'{{ url_root }}',
200-
VERSION:'{{ release|e }}',
201-
LANGUAGE:'{{ language }}',
202-
COLLAPSE_INDEX:false,
203-
FILE_SUFFIX:'{{ '' if no_search_suffix else file_suffix }}',
204-
HAS_SOURCE: {{ has_source|lower }},
205-
SOURCELINK_SUFFIX: '{{ sourcelink_suffix }}'
206-
};
207-
</script>
208-
{%- for scriptfile in script_files %}
209-
<script type="text/javascript" src="{{ pathto(scriptfile, 1) }}"></script>
210-
{%- endfor %}
211-
{% endif %}
212-
213-
{% endif %}
214-
215-
<script type="text/javascript" src="{{ pathto('_static/js/theme.js', 1) }}"></script>
216-
217209
<script type="text/javascript">
218210
jQuery(function () {
219211
SphinxRtdTheme.Navigation.enable({{ 'true' if theme_sticky_navigation|tobool else 'false' }});
220212
});
221213
</script>
222214

215+
{# Do not conflict with RTD insertion of analytics script #}
216+
{% if not READTHEDOCS %}
217+
{% if theme_analytics_id %}
218+
<!-- Theme Analytics -->
219+
<script>
220+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
221+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
222+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
223+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
224+
225+
ga('create', '{{ theme_analytics_id }}', 'auto');
226+
ga('send', 'pageview');
227+
</script>
228+
229+
{% endif %}
230+
{% endif %}
231+
223232
{%- block footer %} {% endblock %}
224233

225234
</body>

0 commit comments

Comments
 (0)