Skip to content

Commit 7410c56

Browse files
authored
Merge pull request SymbiFlow#1 from daniellimws/master
Importing SymbiFlow theme's extra features
2 parents 3c3d153 + 9628ac8 commit 7410c56

File tree

16 files changed

+180
-91
lines changed

16 files changed

+180
-91
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ example shows:
7474
'color_accent': 'light-blue',
7575
7676
# Set the repo location to get a badge with stats
77-
'repo_url': 'https://github.com/project/project/',
77+
'github_url': 'https://github.com/project/project/',
7878
'repo_name': 'Project',
7979
8080
# Visible levels of the global TOC; -1 means unlimited

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
# material theme options (see theme.conf for more information)
9191
html_theme_options = {
9292
"base_url": "http://bashtage.github.io/sphinx-material/",
93-
"repo_url": "https://github.com/bashtage/sphinx-material/",
93+
"github_url": "https://github.com/bashtage/sphinx-material/",
9494
"repo_name": "Material for Sphinx",
9595
"google_analytics_account": "UA-XXXXX",
9696
"html_minify": False,

docs/customization.rst

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ options are:
1212
1313
html_theme_options = {
1414
'base_url': 'http://bashtage.github.io/sphinx-material/',
15-
'repo_url': 'https://github.com/bashtage/sphinx-material/',
15+
'github_url': 'https://github.com/bashtage/sphinx-material/',
1616
'repo_name': 'Material for Sphinx',
1717
'google_analytics_account': 'UA-XXXXX',
1818
'html_minify': True,
@@ -35,10 +35,10 @@ Configuration Options
3535
Path to a touch icon, should be 152x152 or larger.
3636
``google_analytics_account``
3737
Set to enable google analytics.
38-
``repo_url``
38+
``github_url``
3939
Set the repo url for the link to appear.
4040
``repo_name``
41-
The name of the repo. If must be set if repo_url is set.
41+
The name of the repo. If must be set if github_url is set.
4242
``repo_type``
4343
Must be one of github, gitlab or bitbucket.
4444
``base_url``
@@ -99,28 +99,6 @@ Configuration Options
9999
A list of classes to **not strip** from tables. All other classes are stripped, and the default
100100
table has no class attribute. Custom table classes need to provide the full style for the table.
101101

102-
Sidebars
103-
========
104-
You must set ``html_sidebars`` in order for the side bar to appear. There are
105-
four in the complete set.
106-
107-
.. code-block:: python
108-
109-
html_sidebars = {
110-
"**": ["logo-text.html", "globaltoc.html", "localtoc.html", "searchbox.html"]
111-
}
112-
113-
114-
You can exclude any to hide a specific sidebar. For example, if this is changed to
115-
116-
.. code-block:: python
117-
118-
html_sidebars = {
119-
"**": ["globaltoc.html"]
120-
}
121-
122-
then only the global ToC would appear on all pages (``**`` is a glob pattern).
123-
124102
Customizing the layout
125103
======================
126104

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ or ``theme.conf`` for more details.
7070
'color_accent': 'light-blue',
7171
7272
# Set the repo location to get a badge with stats
73-
'repo_url': 'https://github.com/project/project/',
73+
'github_url': 'https://github.com/project/project/',
7474
'repo_name': 'Project',
7575
7676
# Visible levels of the global TOC; -1 means unlimited
Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
{% set toctree = toctree(maxdepth=theme_globaltoc_depth|toint, collapse=theme_globaltoc_collapse|tobool, includehidden=theme_globaltoc_includehidden|tobool) %}
2-
{% if toctree and sidebars and 'globaltoc.html' in sidebars %}
3-
{% set toctree_nodes = derender_toc(toctree, False) %}
4-
<ul class="md-nav__list">
5-
{%- for item in toctree_nodes recursive %}
6-
<li class="md-nav__item">
7-
{% if "caption" in item %}
8-
<span class="md-nav__link caption">{{ item.caption }}</span>
9-
{% else %}
2+
{% set toctree_nodes = derender_toc(toctree, False) %}
3+
<ul class="md-nav__list">
4+
{%- for item in toctree_nodes recursive %}
5+
<li class="md-nav__item">
6+
{% if "caption" in item %}
7+
<span class="md-nav__link caption">{{ item.caption }}</span>
8+
{% else %}
9+
{% if item.current %}
10+
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
11+
<label class="md-nav__link md-nav__link--active" for="__toc"> {{ item.contents }} </label>
12+
{% endif %}
13+
<a href="{{ item.href|e }}" class="md-nav__link{% if item.current %} md-nav__link--active{% endif %}">{{ item.contents }}</a>
1014
{% if item.current %}
11-
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc">
12-
<label class="md-nav__link md-nav__link--active" for="__toc"> {{ item.contents }} </label>
15+
{%- set sphinx_material_include_searchbox=False %}
16+
{% include "localtoc.html" %}
1317
{% endif %}
14-
<a href="{{ item.href|e }}" class="md-nav__link{% if item.current %} md-nav__link--active{% endif %}">{{ item.contents }}</a>
15-
{% if item.current %}
16-
{%- set sphinx_material_include_searchbox=False %}
17-
{% include "localtoc.html" %}
18-
{% endif %}
19-
{%- set sphinx_material_include_searchbox=True %}
20-
{%- if item.children -%}
21-
<ul class="md-nav__list"> {{ loop(item.children) }}</ul>
22-
{%- endif %}
23-
{% endif %}
24-
</li>
25-
{%- endfor %}
26-
</ul>
27-
{# TODO: Fallback to toc? #}
28-
{% endif %}
18+
{%- set sphinx_material_include_searchbox=True %}
19+
{%- if item.children -%}
20+
<ul class="md-nav__list"> {{ loop(item.children) }}</ul>
21+
{%- endif %}
22+
{% endif %}
23+
</li>
24+
{%- endfor %}
25+
</ul>
26+
{# TODO: Fallback to toc? #}

sphinx_material/sphinx_material/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<label class="md-icon md-icon--search md-header-nav__button" for="__search"></label>
2828
{% include "searchbox.html" %}
2929
</div>
30-
{% if theme_repo_url %}
30+
{% if theme_github_url %}
3131
<div class="md-flex__cell md-flex__cell--shrink">
3232
<div class="md-header-nav__source">
3333
{% include "repo.html" %}

sphinx_material/sphinx_material/layout.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<link rel="stylesheet" href="{{ pathto('_static/stylesheets/application.css', 1) }}"/>
4343
<link rel="stylesheet" href="{{ pathto('_static/stylesheets/application-palette.css', 1) }}"/>
4444
<link rel="stylesheet" href="{{ pathto('_static/stylesheets/application-fixes.css', 1) }}"/>
45+
<link rel="stylesheet" href="{{ pathto('_static/stylesheets/symbiflow.css', 1) }}"/>
4546
{% block fonticon %}
4647
<link rel="stylesheet" href="{{ pathto('_static/fonts/material-icons.css', 1) }}"/>
4748
{% endblock %}
@@ -157,6 +158,35 @@
157158
</div>
158159
<div class="md-footer-meta md-typeset">
159160
<div class="md-footer-meta__inner md-grid">
161+
<div class="md-footer-social">
162+
{% if not theme_hide_symbiflow_links|tobool %}
163+
<div class="md-footer-social__link">
164+
<a href="https://symbiflow.github.io/" target="_blank">SymbiFlow</a>
165+
</div>
166+
<div class="md-footer-social__link">
167+
<a href="https://lists.librecores.org/listinfo/symbiflow" target="_blank">Mailing List</a>
168+
</div>
169+
<div class="md-footer-social__link">
170+
<a href="https://webchat.freenode.net/#symbiflow" target="_blank">IRC</a>
171+
</div>
172+
<div class="md-footer-social__link">
173+
<a href="https://join.slack.com/t/symbiflow/shared_invite/enQtNTkyMjcyNTkzOTY4LTU0MzhmYWNjOGMyMTkyNjA0MmEyMWM5OWY3ZDg5MWQ3ODlmOWQwZjk2YzBmMDBjMzkzMzNjYjkwYjAxZTMyNjQ" target="_blank">Slack</a>
174+
</div>
175+
</ul>
176+
{%- endif %}
177+
178+
{%- if theme_github_url %}
179+
<div class="md-footer-social__link">
180+
<a href="{{ theme_github_url }}" target="_blank">GitHub</a>
181+
</div>
182+
{%- endif %}
183+
{%- if theme_license_url %}
184+
<div class="md-footer-social__link">
185+
<!-- <a href="https://github.com/SymbiFlow/sphinx_symbiflow_theme/blob/master/LICENSE" target="_blank"><img alt="License Badge" src="https://img.shields.io/github/license/SymbiFlow/symbiflow-arch-defs"/></a> -->
186+
<a href="{{ theme_license_url }}" target="_blank">License</a>
187+
</div>
188+
{%- endif %}
189+
</div>
160190
<div class="md-footer-copyright">
161191
{%- if show_copyright %}
162192
<div class="md-footer-copyright__highlight">
@@ -179,7 +209,7 @@
179209
{% trans sphinx_version=sphinx_version|e %}Created using
180210
<a href="http://www.sphinx-doc.org/">Sphinx</a> {{ sphinx_version }}.
181211
{% endtrans %} and
182-
<a href="https://github.com/bashtage/sphinx-material/">Material for
212+
<a href="https://github.com/SymbiFlow/sphinx_symbiflow_theme">Material for
183213
Sphinx</a>
184214
{%- endif %}
185215
</div>
@@ -190,6 +220,7 @@
190220
</footer>
191221
{%- block footer_scripts %}
192222
<script src="{{ pathto('_static/javascripts/application.js', 1) }}"></script>
223+
<script src="{{ pathto('_static/javascripts/symbiflow.js', 1) }}"></script>
193224
<script>app.initialize({version: "1.0.4", url: {base: ".."}})</script>
194225
{%- endblock %}
195226
{%- endblock %}

sphinx_material/sphinx_material/localtoc.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{% set toc_nodes = derender_toc(toc, True, pagename) if display_toc else [] %}
22
<nav class="md-nav md-nav--secondary">
3-
{%- if display_toc and toc_nodes and sidebars and 'localtoc.html' in sidebars %}
3+
{%- if display_toc and toc_nodes %}
44
<label class="md-nav__title" for="__toc">Contents</label>
55
{%- endif %}
66
<ul class="md-nav__list" data-md-scrollfix="">
7-
{%- if display_toc and sidebars and 'localtoc.html' in sidebars %}
7+
{%- if display_toc %}
88
{%- for item in toc_nodes recursive %}
99
<li class="md-nav__item"><a href="{{ item.href|e }}" class="md-nav__link">{{ item.contents }}</a>
1010
{%- if item.children -%}

sphinx_material/sphinx_material/relbar.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{%- if nav_bar_tabs %}
22
<nav class="md-tabs" data-md-component="tabs">
33
<div class="md-tabs__inner md-grid">
4-
<ul class="md-tabs__list">
4+
<ul class="md-tabs__list" style="float:left">
55
{%- block rootrellink %}
66
{%- if theme_master_doc %}
77
<li class="md-tabs__item"><a href="{{ pathto(master_doc)|e }}" class="md-tabs__link">{{ shorttitle }}</a></li>
@@ -15,6 +15,12 @@
1515
<li class="md-tabs__item"><a href="{{ parent.link|e }}" class="md-tabs__link">{{ parent.title }}</a></li>
1616
{%- endfor %}
1717
</ul>
18+
<ul class="md-tabs__list" id="symbiflow-header" style="float:right">
19+
{% if not theme_hide_symbiflow_links|tobool %}
20+
<li class="md-tabs__item"><a href="https://symbiflow.github.io" class="md-tabs__link"><i class="md-icon">web</i> SymbiFlow Website</a></li>
21+
<li class="md-tabs__item"><a href="https://symbiflow.readthedocs.io/en/latest" class="md-tabs__link"><i class="md-icon">library_books</i> SymbiFlow Docs</a></li>
22+
{%- endif -%}
23+
</ul>
1824
</div>
1925
</nav>
2026
{%- endif %}

sphinx_material/sphinx_material/repo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a href="{{ theme_repo_url }}" title="Go to repository" class="md-source" data-md-source="github">
1+
<a href="{{ theme_github_url }}" title="Go to repository" class="md-source" data-md-source="github">
22
{% if theme_repo_type %}
33
<div class="md-source__icon">
44
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24" width="28" height="28">
Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
{% if sidebars and 'searchbox.html' in sidebars %}
21
<div class="md-search" data-md-component="search" role="dialog">
3-
<label class="md-search__overlay" for="__search"></label>
4-
<div class="md-search__inner" role="search">
5-
<form class="md-search__form" action="{{ pathto('search') }}" method="GET" name="search">
6-
<input type="text" class="md-search__input" name="q" placeholder="Search"
7-
autocapitalize="off" autocomplete="off" spellcheck="false"
8-
data-md-component="query" data-md-state="active">
9-
<label class="md-icon md-search__icon" for="__search"></label>
10-
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
11-
&#xE5CD;
12-
</button>
13-
</form>
14-
<div class="md-search__output">
15-
<div class="md-search__scrollwrap" data-md-scrollfix>
16-
<div class="md-search-result" data-md-component="result">
17-
<div class="md-search-result__meta">
18-
Type to start searching
19-
</div>
20-
<ol class="md-search-result__list"></ol>
2+
<label class="md-search__overlay" for="__search"></label>
3+
<div class="md-search__inner" role="search">
4+
<form class="md-search__form" action="{{ pathto('search') }}" method="GET" name="search">
5+
<input type="text" class="md-search__input" name="q" placeholder="Search"
6+
autocapitalize="off" autocomplete="off" spellcheck="false"
7+
data-md-component="query" data-md-state="active">
8+
<label class="md-icon md-search__icon" for="__search"></label>
9+
<button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1">
10+
&#xE5CD;
11+
</button>
12+
</form>
13+
<div class="md-search__output">
14+
<div class="md-search__scrollwrap" data-md-scrollfix>
15+
<div class="md-search-result" data-md-component="result">
16+
<div class="md-search-result__meta">
17+
Type to start searching
2118
</div>
19+
<ol class="md-search-result__list"></ol>
2220
</div>
2321
</div>
2422
</div>
2523
</div>
26-
{% endif %}
24+
</div>

sphinx_material/sphinx_material/sidebar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<a href="{{ pathto(master_doc)|e }}"
1111
title="{{ docstitle|striptags|e }}">{{ theme_nav_title or shorttitle }}</a>
1212
</label>
13-
{%- if theme_repo_url %}
13+
{%- if theme_github_url %}
1414
<div class="md-nav__source">
1515
{% include "repo.html" %}
1616
</div>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// for click-to-copy
2+
$(function() {
3+
function styleCodeBlock() {
4+
$('.highlight>pre').hover(function() {
5+
if ($(this).parent().hasClass("linenodiv")) return;
6+
$(this).attr('click-to-copy', 'click to copy...');
7+
});
8+
$('.highlight>pre').mouseup(function(){
9+
if ($(this).parent().hasClass("linenodiv")) return;
10+
$(this).attr('click-to-copy', 'click to copy...');
11+
var selectionText = getSelectionText();
12+
if (selectionText.trim().length > 0) return;
13+
var result = copyClipboard(this);
14+
if (result) {
15+
$(this).attr('click-to-copy', 'copied!');
16+
}
17+
});
18+
}
19+
20+
function getSelectionText() {
21+
var text = "";
22+
if (window.getSelection) {
23+
text = window.getSelection().toString();
24+
} else if (document.selection && document.selection.type != "Control") {
25+
text = document.selection.createRange().text;
26+
}
27+
return text;
28+
}
29+
30+
function copyClipboard(selector) {
31+
var body = document.body;
32+
if(!body) return false;
33+
34+
var $target = $(selector);
35+
if ($target.length === 0) { return false; }
36+
37+
var text = $target.text();
38+
var textarea = document.createElement('textarea');
39+
textarea.value = text;
40+
document.body.appendChild(textarea);
41+
textarea.select();
42+
var result = document.execCommand('copy');
43+
document.body.removeChild(textarea);
44+
return result;
45+
}
46+
47+
styleCodeBlock();
48+
});

sphinx_material/sphinx_material/static/stylesheets/application.css

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,12 @@ html .md-footer-meta.md-typeset a:focus,html .md-footer-meta.md-typeset a:hover{
802802
padding:.2rem 0 .6rem
803803
}
804804
.md-footer-social__link{
805-
display:inline-block;
805+
display:inline;
806806
width:1.6rem;
807807
height:1.6rem;
808-
font-size:.8rem;
809-
text-align:center
808+
font-size:.7rem;
809+
text-align:center;
810+
padding-right: 0.5rem;
810811
}
811812
.md-footer-social__link:before{
812813
line-height:1.9
@@ -2829,17 +2830,17 @@ html .md-typeset .superfences-tabs>label:hover{
28292830
}
28302831
.md-footer-copyright{
28312832
max-width:75%;
2832-
float:left
2833+
float:right
28332834
}
28342835
[dir=rtl] .md-footer-copyright{
2835-
float:right
2836+
float:left
28362837
}
28372838
.md-footer-social{
28382839
padding:.6rem 0;
2839-
float:right
2840+
float:left
28402841
}
28412842
[dir=rtl] .md-footer-social{
2842-
float:left
2843+
float:right
28432844
}
28442845
}
28452846
@media only screen and (max-width:29.9375em){

0 commit comments

Comments
 (0)