Commit c3ab900e authored by Michael Dowling's avatar Michael Dowling

Initial commit

parents
*.pyc
\ No newline at end of file
Copyright (c) 2013 Michael Dowling <mtdowling@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
===================
Guzzle Sphinx Theme
===================
Installation
============
Clone into your _themes folder or checkout as a Git submodule.
Configuration
=============
Add the following to your conf.py:
sys.path.append(os.path.abspath('_themes'))
# Uses a Guzzle style Pygments theme
pygments_style = 'guzzle_theme.GuzzleStyle'
# Adds an HTML table visitor to apply Bootstrap table classes
html_translator_class = 'guzzle_theme.HTMLTranslator'
html_theme_path = ['_themes']
html_theme = 'guzzle_theme'
# Guzzle theme options (see theme.conf for more information)
html_theme_options = {
# Set the path to a special layout to include for the homepage
"index_template": "special_index.html",
# Set the name of the project to appear in the nav menu
"project_nav_name": "Project Name",
# Set your GitHub user and repo to enable GitHub stars links
"github_user": "my_github_user",
"github_repo": "my_github_repo",
# Set your Disqus short name to enable comments
"disqus_comments_shortname": "my_disqus_comments_short_name",
# Set you GA account ID to enable tracking
"google_analytics_account": "my_ga_account",
# Set a custom class to add to the navbar (e.g. navbar-inverse)
"navbar_class": "",
# Set the path to a logo to show above the table of contents
"index_logo": "",
# Set the height of the logo
"index_logo_height": "0px",
# Path to a touch icon
"touch_icon": ""
}
Customizing the layout
======================
You need to customize the navigation links of "layout.html" using a theme
customization. "layout.html" contains several blocks that can be
overridden or extended.
Place a "layout.html" file in your project's "/_templates" directory.
$ mkdir source/_templates
$ touch source/_templates/layout.html
Then, configure your "conf.py":
templates_path = ['_templates']
Finally, edit your override file "source/_templates/layout.html":
{# Import the theme's layout. #}
{% extends "!layout.html" %}
{# Customize the links in the main nav menu #}
{%- block nav_links %}
<li><a href="{{ pathto(master_doc) }}">Home</a></li>
<li><a href="{{ pathto('docs') }}">Docs</a></li>
<li><a href="http://guzzlephp.org/api/index.html">API</a></li>
<li><a href="https://github.com/guzzle/guzzle">GitHub</a></li>
<li><a href="https://groups.google.com/forum/?hl=en#!forum/guzzle">Forum</a></li>
<li><a href="https://packagist.org/packages/guzzle/guzzle">Packagist</a></li>
<li><a href="irc:irc.freenode.com/#guzzlephp">IRC</a></li>
{%- endblock %}
"""Sphinx Guzzle theme."""
import os
from docutils import nodes
from sphinx.locale import admonitionlabels
from sphinx.writers.html import HTMLTranslator as SphinxHTMLTranslator
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
class HTMLTranslator(SphinxHTMLTranslator):
"""
Handle translating to bootstrap structure.
"""
def visit_table(self, node, name=''):
"""
Override docutils default table formatter to not include a border
and to use Bootstrap CSS
See: http://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/docutils/writers/html4css1/__init__.py#l1550
"""
self.context.append(self.compact_p)
self.compact_p = True
classes = ' '.join(['table', 'table-bordered',
self.settings.table_style]).strip()
self.body.append(
self.starttag(node, 'table', CLASS=classes))
def depart_table(self, node):
"""
This needs overridin' too
"""
self.compact_p = self.context.pop()
self.body.append('</table>\n')
class GuzzleStyle(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: "#006EC4", # 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'
}
{% if theme_disqus_comments_shortname %}
<div id="comments">
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = '{{ theme_disqus_comments_shortname }}';
var disqus_identifier = '{{ pagename }}';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</div>
{% endif %}
# Guzzle Pygments theme
from pygments.style import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
Number, Operator, Generic, Whitespace, Punctuation, Other, Literal
class GuzzleStyle(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: "#006EC4", # 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'
}
{%- extends "basic/layout.html" %}
{# Do this so that bootstrap is included before the main css file #}
{%- block htmltitle %}
{{ super() }}
<link rel="stylesheet" type="text/css" href="{{ pathto('_static/css/bootstrap.min.css', 1) }}" />
{%- endblock %}
{# Displays the next and previous links both before and after content #}
{% macro render_relations(class='footer-links', add_spacer=0) -%}
{% if prev or next %}
<div class="{{ class }}">
<ul class="breadcrumb pull-right">
{%- if prev and prev.title != '&lt;no title&gt;' %}
<li>
<a href="{{ prev.link|e }}" title="{{ _('previous chapter')}}">Prev: {{ prev.title }}</a>
{%- if next and next.title != '&lt;no title&gt;' %}
<span class="divider">/</span>
{% endif %}
</li>
{%- endif %}
{%- if next and next.title != '&lt;no title&gt;' %}
<li><a href="{{ next.link|e }}" title="{{ _('next chapter')}}">Next: {{ next.title }}</a></li>
{%- endif %}
</ul>
</div>
{% else %}
{% if add_spacer %}
<div class="rel-spacer clearer"></div>
{% endif %}
{% endif %}
{%- endmacro %}
{%- block extrahead %}
<link rel="stylesheet" type="text/css" href="{{ pathto('_static/css/bootstrap-responsive.min.css', 1) }}" />
{% if theme_touch_icon %}
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}" />
{% endif %}
{{ super() }}
{% endblock %}
{% block header %}
<div class="navbar navbar-fixed-top {{ theme_navbar_class }}">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="{{ pathto(master_doc) }}">{{ theme_project_nav_name }}</a>
<ul class="nav">
{%- block nav_links %}
<li><a href="{{ pathto(master_doc) }}">Home</a></li>
{%- endblock %}
</ul>
{%- if theme_github_user and theme_github_repo %}
<div class="pull-right" id="github-stars">
<iframe src="http://ghbtns.com/github-btn.html?user={{ theme_github_user }}&repo={{ theme_github_repo }}&type=watch&count=true&size=small"
allowtransparency="true" frameborder="0" scrolling="0" width="110px" height="20px"></iframe>
</div>
{%- endif %}
</div>
</div>
</div>
{{ super() }}
{% endblock %}
{%- block content %}
{%- if pagename == 'index' and theme_index_template %}
{% include theme_index_template %}
{%- else %}
<div class="container">
{%- block top_rel_links %}
{{ render_relations('top-links', 1) }}
{%- endblock %}
{%- block document_wrapper %}
<div class="document clearer">
{%- block sidebar1 %}{{ sidebar() }}{% endblock %}
{%- block document %}
<div class="body">
{% block body %} {% endblock %}
</div>
{%- endblock %}
{%- block sidebar2 %}{# Place holder for other sidebar #}{% endblock %}
<div class="clearfix"></div>
</div>
{%- endblock %}
{%- block bottom_rel_links %}
{{ render_relations('footer-links') }}
{%- endblock %}
{%- block comments -%}
{% if theme_disqus_comments_shortname %}
<div class="container comment-container">
{% include "comments.html" %}
</div>
{% endif %}
{%- endblock %}
</div>
{%- endif %}
{%- endblock %}
{%- block footer %}
{%- block footer_wrapper %}
<div class="footer container">
&copy; Copyright {{ copyright }}. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
</div>
{%- endblock %}
{%- block ga %}
{%- if theme_google_analytics_account %}
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '{{ theme_google_analytics_account }}']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
{%- endif %}
{%- endblock %}
{%- endblock %}
<div class="left-bar-other">
<h3>Need help?</h3>
<p>Please post to our google group or #guzzlephp IRC channel on freenode if you need support or have a technical
question.</p>
</div>
<div class="left-bar-other">
<h3>Found an error?</h3>
<p>If you find an error in the documentation, please file a ticket or submit a pull request on
<a href="https://github.com/guzzle/guzzle">GitHub</a></p>
</div>
{%- if pagename != "search" %}
<div id="searchbox" style="display: none">
<h3>{{ _('Quick search') }}</h3>
<form class="form-search margin-top-1em" action="{{ pathto('search') }}" method="get">
<input type="text" name="q" style="width: 105px" class="input-small search-query" />
<button type="submit" class="btn btn-small">Search</button>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
{%- endif %}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
[theme]
inherit = basic
stylesheet = css/guzzle.css
[options]
# Set to an html template to load custom HTML for the homepage
index_template =
# Set a custom class to add to the navbar (e.g. navbar-inverse)
navbar_class =
# Name of the project that will be displayed in the main navigation bar
project_nav_name = ChangeMe
# Set GitHub settings to enable a GitHub stars link
github_user =
github_repo =
# Set the value to display a logo in the left navigation panel
index_logo =
index_logo_height = 0px
# Path to a touch icon
touch_icon =
# Set this value to enable Disqus comments
disqus_comments_shortname =
# Set to enable google analytics
google_analytics_account =
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment