Skip to content

Commit

Permalink
Initial theme version of new packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
danwos committed Jun 9, 2017
0 parents commit a8ebf51
Show file tree
Hide file tree
Showing 16 changed files with 1,076 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.pyc
*.pyo
.DS_Store
.idea
build
dist
*.egg-info
45 changes: 45 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Modifications Groundwork:
Copyright (c) 2016 Daniel Woste

Modifications:
Copyright (c) 2010 Kenneth Reitz.

Original Project:
Copyright (c) 2010 by Armin Ronacher.


Some rights reserved.

Redistribution and use in source and binary forms of the theme, with or
without modification, are permitted provided that the following conditions
are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.

We kindly ask you to only use these themes in an unmodified manner just
for groundwork and groundwork-related products, not for unrelated projects.
If you like the visual style and want to use it for your own projects,
please consider making some larger changes to the themes (such as changing
font faces, sizes, colors or margins).

THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include LICENSE
graft groundwork_sphinx_theme/groundwork/
44 changes: 44 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
groundwork-sphinx-theme
=======================

This repository contains sphinx styles, which are use by most groundwork related projects.
It is a derivative of Kenneth Reitz's themes for his projects and of Mitsuhiko's themes for Flask and Flask related
projects. To use this style in your Sphinx documentation, follow this guide:

1. Install the package using pip: ``pip install groundwork-sphinx-theme``

2. Add this to ``conf.py``:

.. code-block:: python
html_theme = 'groundwork'
Configuration
-------------
The groundwork-sphinx-theme provides the following configuration parameters:

* **sidebar_width**: Allows the user to set the sidebar width in pixels. Good for deeply nested TOCs (Default: 220x)
* **stickysidbar**: If True it makes the sidebar always visible if pages get longer (Default: True)
* **stickysidbarscrollable**: Makes the sticky sidebar scrollable in small browser windows (Default: False)
* **contribute**: If True, a contribute-area with github-buttons is shown inside the sidebar
* **github_user**: Used the for github follow button. E.g.: useblocks
* **github_fork**: Used for the github fork buttons. E.g.: useblocks/groundwork

You can change their value inside the file `conf.py` of your sphinx project::

html_theme_options = {
"sidebar_width": '240px',
"stickysidebar": True,
"stickysidebarscrollable": True,
"contribute": True,
"github_fork": "useblocks/groundwork",
"github_user": "useblocks",
}

Screenshot
----------

.. image:: screenshot.png
:height: 400px
:alt: screenshot of groundwork sphinx theme
:align: center
Empty file added __init__.py
Empty file.
25 changes: 25 additions & 0 deletions groundwork_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Old way until 1.6
# But this works only

import os

__version__ = '1.0.5'


def get_path():
return os.path.abspath(os.path.dirname(__file__))


def setup(app):
return {
'version': __version__,
'parallel_read_safe': True
}

# New way since sphinx 1.6
# Used for http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
# but not working.

# from os import path
# def setup(app):
# app.add_html_theme('groundwork', path.abspath(path.join(path.dirname(__file__), "groundwork")))
86 changes: 86 additions & 0 deletions groundwork_sphinx_theme/flask_theme_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# flasky extensions. flasky pygments style based on tango style
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal


class FlaskyStyle(Style):
background_color = "#f8f8f8"
default_style = ""

styles = {
# No corresponding class for the following:
#Text: "", # class: ''
Whitespace: "underline #f8f8f8", # class: 'w'
Error: "#a40000 border:#ef2929", # class: 'err'
Other: "#000000", # class 'x'

Comment: "italic #8f5902", # class: 'c'
Comment.Preproc: "noitalic", # class: 'cp'

Keyword: "bold #004461", # class: 'k'
Keyword.Constant: "bold #004461", # class: 'kc'
Keyword.Declaration: "bold #004461", # class: 'kd'
Keyword.Namespace: "bold #004461", # class: 'kn'
Keyword.Pseudo: "bold #004461", # class: 'kp'
Keyword.Reserved: "bold #004461", # class: 'kr'
Keyword.Type: "bold #004461", # class: 'kt'

Operator: "#582800", # class: 'o'
Operator.Word: "bold #004461", # class: 'ow' - like keywords

Punctuation: "bold #000000", # class: 'p'

# because special names such as Name.Class, Name.Function, etc.
# are not recognized as such later in the parsing, we choose them
# to look the same as ordinary variables.
Name: "#000000", # class: 'n'
Name.Attribute: "#c4a000", # class: 'na' - to be revised
Name.Builtin: "#004461", # class: 'nb'
Name.Builtin.Pseudo: "#3465a4", # class: 'bp'
Name.Class: "#000000", # class: 'nc' - to be revised
Name.Constant: "#000000", # class: 'no' - to be revised
Name.Decorator: "#888", # class: 'nd' - to be revised
Name.Entity: "#ce5c00", # class: 'ni'
Name.Exception: "bold #cc0000", # class: 'ne'
Name.Function: "#000000", # class: 'nf'
Name.Property: "#000000", # class: 'py'
Name.Label: "#f57900", # class: 'nl'
Name.Namespace: "#000000", # class: 'nn' - to be revised
Name.Other: "#000000", # class: 'nx'
Name.Tag: "bold #004461", # class: 'nt' - like a keyword
Name.Variable: "#000000", # class: 'nv' - to be revised
Name.Variable.Class: "#000000", # class: 'vc' - to be revised
Name.Variable.Global: "#000000", # class: 'vg' - to be revised
Name.Variable.Instance: "#000000", # class: 'vi' - to be revised

Number: "#990000", # class: 'm'

Literal: "#000000", # class: 'l'
Literal.Date: "#000000", # class: 'ld'

String: "#4e9a06", # class: 's'
String.Backtick: "#4e9a06", # class: 'sb'
String.Char: "#4e9a06", # class: 'sc'
String.Doc: "italic #8f5902", # class: 'sd' - like a comment
String.Double: "#4e9a06", # class: 's2'
String.Escape: "#4e9a06", # class: 'se'
String.Heredoc: "#4e9a06", # class: 'sh'
String.Interpol: "#4e9a06", # class: 'si'
String.Other: "#4e9a06", # class: 'sx'
String.Regex: "#4e9a06", # class: 'sr'
String.Single: "#4e9a06", # class: 's1'
String.Symbol: "#4e9a06", # class: 'ss'

Generic: "#000000", # class: 'g'
Generic.Deleted: "#a40000", # class: 'gd'
Generic.Emph: "italic #000000", # class: 'ge'
Generic.Error: "#ef2929", # class: 'gr'
Generic.Heading: "bold #000080", # class: 'gh'
Generic.Inserted: "#00A000", # class: 'gi'
Generic.Output: "#888", # class: 'go'
Generic.Prompt: "#745334", # class: 'gp'
Generic.Strong: "bold #000000", # class: 'gs'
Generic.Subheading: "bold #800080", # class: 'gu'
Generic.Traceback: "bold #a40000", # class: 'gt'
}
21 changes: 21 additions & 0 deletions groundwork_sphinx_theme/groundwork/contribute.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% if theme_contribute %}
<script async defer src="https://buttons.github.io/buttons.js"></script>
<div class="contribute">
<h3>Contribute</h3>
<a class="github-button" href="https://github.com/{{ theme_github_fork }}/fork"
data-icon="octicon-repo-forked"
data-style="mega"
aria-label="Fork {{ theme_github_fork }} on GitHub">Fork</a>
<a class="github-button" href="https://github.com/{{ theme_github_fork }}"
data-icon="octicon-star"
data-style="mega"
data-count-href="/{{ theme_github_fork }}/stargazers"
data-count-api="/repos/{{ theme_github_fork }}#stargazers_count"
data-count-aria-label="# stargazers on GitHub"
aria-label="Star {{ theme_github_fork }} on GitHub">Star</a>
<br>
<a class="github-button" href="https://github.com/{{ theme_github_user }}"
data-style="mega"
aria-label="Follow @{{ theme_github_user }} on GitHub">Follow @{{ theme_github_user }}</a>
</div>
{% endif %}
53 changes: 53 additions & 0 deletions groundwork_sphinx_theme/groundwork/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{%- extends "basic/layout.html" %}
{%- block extrahead %}
{{ super() }}
{% if theme_touch_icon %}
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
{% endif %}
<link media="only screen and (max-device-width: 480px)" href="{{pathto('_static/small_groundwork.css', 1) }}" type= "text/css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9">
<!-- Place this tag in your head or just before your close body tag. -->
{% endblock %}

{%- block sidebarsearch %}
{{ super() }}
{# {% if theme_contribute %}#}
{# <div class="contribute">#}
{# <h3>Contribute</h3>#}
{# <a class="github-button" href="https://github.com/{{ theme_github_fork }}/fork"#}
{# data-icon="octicon-repo-forked"#}
{# data-style="mega"#}
{# aria-label="Fork {{ theme_github_fork }} on GitHub">Fork</a>#}
{# <a class="github-button" href="https://github.com/{{ theme_github_fork }}"#}
{# data-icon="octicon-star"#}
{# data-style="mega"#}
{# data-count-href="/{{ theme_github_fork }}/stargazers"#}
{# data-count-api="/repos/{{ theme_github_fork }}#stargazers_count"#}
{# data-count-aria-label="# stargazers on GitHub"#}
{# aria-label="Star {{ theme_github_fork }} on GitHub">Star</a>#}
{# <br>#}
{# <a class="github-button" href="https://github.com/{{ theme_github_user }}"#}
{# data-style="mega"#}
{# aria-label="Follow @{{ theme_github_user }} on GitHub">Follow @{{ theme_github_user }}</a>#}
{# </div>#}
{# {% endif %}#}
{%- include "contribute.html" %}
{% endblock %}

{% block relbar2 %}
{% if theme_github_fork %}
<div class="github_fork">
<a href="http://github.com/{{ theme_github_fork }}">
<img style="position: fixed; top: 0; right: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_{{ theme_github_ribbon_color }}.png"
alt="Fork me on GitHub">
</a>
</div>
{% endif %}

{% endblock %}
{%- block footer %}
<div class="footer">
&copy; Copyright {{ copyright }}.
</div>
{%- endblock %}
19 changes: 19 additions & 0 deletions groundwork_sphinx_theme/groundwork/relations.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<h3>Related Topics</h3>
<ul>
<li><a href="{{ pathto(master_doc) }}">Documentation overview</a><ul>
{%- for parent in parents %}
<li><a href="{{ parent.link|e }}">{{ parent.title }}</a><ul>
{%- endfor %}
{%- if prev %}
<li>Previous: <a href="{{ prev.link|e }}" title="{{ _('previous chapter')
}}">{{ prev.title }}</a></li>
{%- endif %}
{%- if next %}
<li>Next: <a href="{{ next.link|e }}" title="{{ _('next chapter')
}}">{{ next.title }}</a></li>
{%- endif %}
{%- for parent in parents %}
</ul></li>
{%- endfor %}
</ul></li>
</ul>
Loading

0 comments on commit a8ebf51

Please sign in to comment.