summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-01-16 18:43:14 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2012-01-16 18:43:14 -0500
commit8f1bdc9b32faf504ca7c5fd5de741c4e92fb364b (patch)
treee151dd474a52be5519b12fd09764df632fb3ffca
parent9e134cb7767f54763431a59467bfb92d0ef8e0c9 (diff)
downloadmako-8f1bdc9b32faf504ca7c5fd5de741c4e92fb364b.tar.gz
build in new readthedocs + mako site layout build
-rw-r--r--doc/build/builder/builders.py51
-rw-r--r--doc/build/conf.py2
-rw-r--r--doc/build/static/makoLogo.pngbin0 -> 11715 bytes
-rw-r--r--doc/build/static/python-logo.gifbin0 -> 2549 bytes
-rw-r--r--doc/build/static/site.css82
-rw-r--r--doc/build/templates/genindex.mako2
-rw-r--r--doc/build/templates/layout.mako44
-rw-r--r--doc/build/templates/makoorg/root.mako58
-rw-r--r--doc/build/templates/page.mako2
-rw-r--r--doc/build/templates/pre_layout.mako2
-rw-r--r--doc/build/templates/rtd_layout.mako174
-rw-r--r--doc/build/templates/search.mako2
-rw-r--r--doc/build/templates/static_base.mako19
13 files changed, 391 insertions, 47 deletions
diff --git a/doc/build/builder/builders.py b/doc/build/builder/builders.py
index 9ab6937..600beab 100644
--- a/doc/build/builder/builders.py
+++ b/doc/build/builder/builders.py
@@ -9,18 +9,23 @@ from pygments.filter import Filter, apply_filters
from pygments.lexers import PythonLexer, PythonConsoleLexer
from pygments.formatters import HtmlFormatter, LatexFormatter
import re
+import os
from mako.lookup import TemplateLookup
from mako.template import Template
from mako.ext.pygmentplugin import MakoLexer
+rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
class MakoBridge(TemplateBridge):
def init(self, builder, *args, **kw):
self.jinja2_fallback = BuiltinTemplateLoader()
self.jinja2_fallback.init(builder, *args, **kw)
self.layout = builder.config.html_context.get('mako_layout', 'html')
+ builder.config.html_context['site_base'] = builder.config['site_base']
- self.lookup = TemplateLookup(directories=builder.config.templates_path,
+ self.lookup = TemplateLookup(
+ directories=builder.config.templates_path,
imports=[
"from builder import util"
]
@@ -30,8 +35,47 @@ class MakoBridge(TemplateBridge):
template = template.replace(".html", ".mako")
context['prevtopic'] = context.pop('prev', None)
context['nexttopic'] = context.pop('next', None)
- context['mako_layout'] = self.layout == 'html' and 'static_base.mako' or 'site_base.mako'
- # sphinx 1.0b2 doesn't seem to be providing _ for some reason...
+
+ # site layout
+ if self.layout == 'site':
+ context['mako_layout'] = 'site_base.mako'
+ context['mako_pre_layout'] = "layout.mako"
+ # overrides site_base from conf.py
+ context['site_base'] = "/"
+ context['docs_base'] = "/"
+ else:
+ # RTD layout
+ if rtd:
+ # add variables if not present, such
+ # as if local test of READTHEDOCS variable
+ if 'MEDIA_URL' not in context:
+ context['MEDIA_URL'] = "http://media.readthedocs.org/"
+ if 'slug' not in context:
+ context['slug'] = "mako-test-slug"
+ if 'url' not in context:
+ context['url'] = "/some/test/url"
+ if 'current_version' not in context:
+ context['current_version'] = "some_version"
+ if 'versions' not in context:
+ context['versions'] = [('default', '/default/')]
+
+ context['docs_base'] = "http://readthedocs.org"
+ context['toolbar'] = True
+ context['mako_pre_layout'] = "rtd_layout.mako"
+ context['pdf_url'] = "%spdf/%s/%s/%s.pdf" % (
+ context['MEDIA_URL'],
+ context['slug'],
+ context['current_version'],
+ context['slug']
+ )
+ # local docs layout
+ else:
+ context['toolbar'] = False
+ context['docs_base'] = "/"
+ context['mako_pre_layout'] = "layout.mako"
+
+ context['mako_layout'] = 'makoorg/root.mako'
+
context.setdefault('_', lambda x:x)
return self.lookup.get_template(template).render_unicode(**context)
@@ -59,5 +103,6 @@ def setup(app):
# Mako is already in Pygments, adding the local
# lexer here so that the latest syntax is available
app.add_lexer('mako', MakoLexer())
+ app.add_config_value('site_base', "", True)
\ No newline at end of file
diff --git a/doc/build/conf.py b/doc/build/conf.py
index 288b3f5..43c29eb 100644
--- a/doc/build/conf.py
+++ b/doc/build/conf.py
@@ -38,6 +38,8 @@ templates_path = ['templates']
nitpicky = True
+site_base = "http://www.makotemplates.org"
+
# The suffix of source filenames.
source_suffix = '.rst'
diff --git a/doc/build/static/makoLogo.png b/doc/build/static/makoLogo.png
new file mode 100644
index 0000000..c43c087
--- /dev/null
+++ b/doc/build/static/makoLogo.png
Binary files differ
diff --git a/doc/build/static/python-logo.gif b/doc/build/static/python-logo.gif
new file mode 100644
index 0000000..01c7bf3
--- /dev/null
+++ b/doc/build/static/python-logo.gif
Binary files differ
diff --git a/doc/build/static/site.css b/doc/build/static/site.css
new file mode 100644
index 0000000..eb545d3
--- /dev/null
+++ b/doc/build/static/site.css
@@ -0,0 +1,82 @@
+body {
+ font-family: Tahoma, Geneva, sans-serif;
+ line-height:1.4em;
+ margin:15px;
+ background-color:#FFFFFF;
+}
+img {border:none;}
+a { text-decoration: none;}
+a:visited { color: #2929ff;}
+a:hover { color: #0000ff;}
+
+#wrap {
+ margin:0 auto;
+ max-width:1024px;
+ min-width:480px;
+ position:relative;
+
+}
+h1 {
+ font-size:1.6em;
+ font-weight:bold;
+}
+
+h2 {
+ font-size:1.1em;
+ font-weight:bold;
+ margin:10px 0px 10px 0px;
+}
+
+.clearfix{
+ clear:both;
+}
+
+.red {
+ font-weight:bold;
+ color:#FF0000;
+}
+.rightbar {
+ float:right;
+ margin:10px 30px 10px 30px;
+}
+.slogan {
+ margin-top:10px;
+}
+.toolbar {
+ margin-top:20px;
+}
+.copyright {
+ font-size:.8em;
+ text-align:center;
+ color:909090;
+}
+.pylogo {
+ text-align:right;
+ float:right;
+}
+.code {
+ font-family:monospace;
+}
+
+li {
+ margin:1px 0px 1px 0px;
+}
+
+.speedchart td {
+ font-size:small;
+}
+
+pre.codesample {
+ margin: 1.5em;
+ padding: .5em;
+ font-size: .95em;
+ line-height:1em;
+ background-color: #eee;
+ border: 1px solid #ccc;
+ width:450px;
+ overflow:auto;
+}
+
+#speedchart {
+ margin:5px 10px 5px 10px;
+}
diff --git a/doc/build/templates/genindex.mako b/doc/build/templates/genindex.mako
index 5bbf1f1..4f535f4 100644
--- a/doc/build/templates/genindex.mako
+++ b/doc/build/templates/genindex.mako
@@ -1,4 +1,4 @@
-<%inherit file="layout.mako"/>
+<%inherit file="pre_layout.mako"/>
<%block name="show_title" filter="util.striptags">
${_('Index')}
diff --git a/doc/build/templates/layout.mako b/doc/build/templates/layout.mako
index 5f21ef9..c8765ef 100644
--- a/doc/build/templates/layout.mako
+++ b/doc/build/templates/layout.mako
@@ -1,5 +1,7 @@
## coding: utf-8
-
+<%!
+ local_script_files = []
+%>
<%doc>
Structural elements are all prefixed with "docs-"
to prevent conflicts when the structure is integrated into the
@@ -166,28 +168,26 @@ withsidebar = bool(toc) and current_page_name != 'index'
</div>
-<%block name="footer">
- <div id="docs-bottom-navigation" class="docs-navigation-links">
- % if prevtopic:
- Previous:
- <a href="${prevtopic['link']|h}" title="${_('previous chapter')}">${prevtopic['title']}</a>
- % endif
- % if nexttopic:
- Next:
- <a href="${nexttopic['link']|h}" title="${_('next chapter')}">${nexttopic['title']}</a>
- % endif
+<div id="docs-bottom-navigation" class="docs-navigation-links">
+ % if prevtopic:
+ Previous:
+ <a href="${prevtopic['link']|h}" title="${_('previous chapter')}">${prevtopic['title']}</a>
+ % endif
+ % if nexttopic:
+ Next:
+ <a href="${nexttopic['link']|h}" title="${_('next chapter')}">${nexttopic['title']}</a>
+ % endif
- <div id="docs-copyright">
- % if hasdoc('copyright'):
- &copy; <a href="${pathto('copyright')}">Copyright</a> ${copyright|h}.
- % else:
- &copy; Copyright ${copyright|h}.
- % endif
- % if show_sphinx:
- Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> ${sphinx_version|h}.
- % endif
- </div>
+ <div id="docs-copyright">
+ % if hasdoc('copyright'):
+ &copy; <a href="${pathto('copyright')}">Copyright</a> ${copyright|h}.
+ % else:
+ &copy; Copyright ${copyright|h}.
+ % endif
+ % if show_sphinx:
+ Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> ${sphinx_version|h}.
+ % endif
</div>
-</%block>
+</div>
</div>
diff --git a/doc/build/templates/makoorg/root.mako b/doc/build/templates/makoorg/root.mako
new file mode 100644
index 0000000..64ae564
--- /dev/null
+++ b/doc/build/templates/makoorg/root.mako
@@ -0,0 +1,58 @@
+<%
+in_docs = getattr(next.module, 'in_docs', False)
+%>
+
+<html>
+<%def name="title()">
+Mako Templates for Python
+</%def>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
+<head>
+<title>${self.title()} </title>
+<%block name="headers">
+</%block>
+<link rel="stylesheet" href="${pathto('_static/site.css', 1)}"></link>
+
+
+</head>
+<body>
+ <div id="wrap">
+ <div class="rightbar">
+ <div class="slogan">
+ Hyperfast and lightweight templating for the Python platform.
+ </div>
+
+ % if toolbar:
+ <div class="toolbar">
+ <a href="${site_base}/">Home</a>
+ &nbsp; | &nbsp;
+ <a href="${site_base}/trac">Trac</a>
+ &nbsp; | &nbsp;
+ <a href="${site_base}/community.html">Community</a>
+ &nbsp; | &nbsp;
+ <a href="${pathto('index')}">Documentation</a>
+ &nbsp; | &nbsp;
+ <a href="${site_base}/download.html">Download</a>
+ </div>
+ % endif
+
+ </div>
+
+ <a href="/"><img src="${pathto('_static/makoLogo.png', 1)}" /></a>
+
+ <hr/>
+
+ ${next.body()}
+<div class="clearfix">
+<%block name="footer">
+<hr/>
+
+<div class="copyright">Website content copyright &copy; by Michael Bayer.
+ All rights reserved. Mako and its documentation are licensed
+ under the MIT license. mike(&)zzzcomputing.com</div>
+</%block>
+</div>
+</div>
+</body>
+</html>
diff --git a/doc/build/templates/page.mako b/doc/build/templates/page.mako
index e0f98cf..e134ab4 100644
--- a/doc/build/templates/page.mako
+++ b/doc/build/templates/page.mako
@@ -1,2 +1,2 @@
-<%inherit file="layout.mako"/>
+<%inherit file="pre_layout.mako"/>
${body| util.strip_toplevel_anchors} \ No newline at end of file
diff --git a/doc/build/templates/pre_layout.mako b/doc/build/templates/pre_layout.mako
new file mode 100644
index 0000000..5b1c508
--- /dev/null
+++ b/doc/build/templates/pre_layout.mako
@@ -0,0 +1,2 @@
+<%inherit file="${context['mako_pre_layout']}"/>
+${next.body()} \ No newline at end of file
diff --git a/doc/build/templates/rtd_layout.mako b/doc/build/templates/rtd_layout.mako
new file mode 100644
index 0000000..09cdb97
--- /dev/null
+++ b/doc/build/templates/rtd_layout.mako
@@ -0,0 +1,174 @@
+<!-- readthedocs add-in template, ported from their jinja source -->
+
+<%inherit file="/layout.mako"/>
+
+<%
+ newscript = []
+ # strip out script files that RTD wants to provide
+ for script in script_files:
+ for token in ("jquery.js", "underscore.js", "doctools.js"):
+ if token in script:
+ break
+ else:
+ newscript.append(script)
+ script_files[:] = newscript
+%>
+
+<%block name="headers">
+ ${parent.headers()}
+<!-- RTD <head> -->
+<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
+<script type="text/javascript" src="${MEDIA_URL}javascript/underscore.js"></script>
+<script type="text/javascript" src="${MEDIA_URL}javascript/doctools.js"></script>
+<script type="text/javascript" src="${MEDIA_URL}javascript/searchtools.js"></script>
+##{% if using_theme %}
+## <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
+##{% endif %}
+ <script type="text/javascript">
+ var doc_version = "${current_version}";
+ var doc_slug = "${slug}";
+ </script>
+ <script type="text/javascript" src="${MEDIA_URL}javascript/rtd.js"></script>
+<!-- end RTD <head> -->
+</%block>
+
+${next.body()}
+
+<%block name="footer">
+ ${parent.footer()}
+ <!-- End original user content -->
+## Keep this here, so that the RTD logo doesn't stomp on the bottom of the theme.
+<br>
+<br>
+<br>
+
+<style type="text/css">
+ .badge {
+ position: fixed;
+ display: block;
+ bottom: 5px;
+ height: 40px;
+ text-indent: -9999em;
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.2) inset;
+ -moz-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.2) inset;
+ -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2), 0 1px 0 rgba(255, 255, 255, 0.2) inset;
+ }
+ #version_menu {
+ position: fixed;
+ display: none;
+ bottom: 11px;
+ right: 166px;
+ list-style-type: none;
+ margin: 0;
+ }
+ .footer_popout:hover #version_menu {
+ display: block;
+ }
+ #version_menu li {
+ display: block;
+ float: right;
+ }
+ #version_menu li a {
+ display: block;
+ padding: 6px 10px 4px 10px;
+ margin: 7px 7px 0 0;
+ font-weight: bold;
+ font-size: 14px;
+ height: 20px;
+ line-height: 17px;
+ text-decoration: none;
+ color: #fff;
+ background: #8ca1af url(../images/gradient-light.png) bottom left repeat-x;
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ -webkit-border-radius: 3px;
+ box-shadow: 0 1px 1px #465158;
+ -moz-box-shadow: 0 1px 1px #465158;
+ -webkit-box-shadow: 0 1px 1px #465158;
+ text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
+ }
+ #version_menu li a:hover {
+ text-decoration: none;
+ background-color: #697983;
+ box-shadow: 0 1px 0px #465158;
+ -moz-box-shadow: 0 1px 0px #465158;
+ -webkit-box-shadow: 0 1px 0px #465158;
+ }
+ .badge.rtd {
+ background: #257597 url(http://media.readthedocs.org/images/badge-rtd.png) top left no-repeat;
+ border: 1px solid #282E32;
+ width: 160px;
+ right: 5px;
+ }
+ .badge.revsys { background: #465158 url(http://media.readthedocs.org/images/badge-revsys.png) top left no-repeat;
+ border: 1px solid #1C5871;
+ width: 290px;
+ right: 173px;
+ }
+ .badge.revsys-inline-sponsored {
+ position: inherit;
+ margin-left: auto;
+ margin-right: 175px;
+ margin-bottom: 5px;
+ background: #465158 url(http://media.readthedocs.org/images/badge-revsys.png) top left no-repeat;
+ border: 1px solid #1C5871;
+ width: 290px;
+ right: 173px;
+ }
+ .badge.revsys-inline {
+ position: inherit;
+ margin-left: auto;
+ margin-right: 175px;
+ margin-bottom: 5px;
+ background: #465158 url(http://media.readthedocs.org/images/badge-revsys-sm.png) top left no-repeat;
+ border: 1px solid #1C5871;
+ width: 205px;
+ right: 173px;
+ }
+
+</style>
+<div class="rtd_doc_footer">
+ <div class="footer_popout">
+ <a href="http://readthedocs.org/projects/${slug}/?fromdocs=${slug}" class="badge rtd">Brought to you by Read the Docs</a>
+ <ul id="version_menu">
+ ## note that rtd.js blows this away, probably checks if the links
+ ## are good or something like that (in which case why are they in the 'versions'
+ ## collection...)
+ % for _slug, url in versions:
+ <li><a href="http://readthedocs.org${url}">${_slug}</a></li>
+ % endfor
+ </ul>
+ </div>
+</div>
+<!-- RTD Analytics Code -->
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-17997319-1']);
+ _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>
+
+% if analytics_code:
+<!-- User Analytics Code -->
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', '${analytics_code}']);
+ _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
+
+</%block>
diff --git a/doc/build/templates/search.mako b/doc/build/templates/search.mako
index eb21a24..ff03d5e 100644
--- a/doc/build/templates/search.mako
+++ b/doc/build/templates/search.mako
@@ -1,4 +1,4 @@
-<%inherit file="layout.mako"/>
+<%inherit file="pre_layout.mako"/>
<%!
local_script_files = ['_static/searchtools.js']
diff --git a/doc/build/templates/static_base.mako b/doc/build/templates/static_base.mako
deleted file mode 100644
index b3f7a52..0000000
--- a/doc/build/templates/static_base.mako
+++ /dev/null
@@ -1,19 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- ${metatags and metatags or ''}
- <title>${self.show_title()} &mdash; ${docstitle|h}</title>
- <%block name="headers"/>
- </head>
- <body>
- ${next.body()}
- </body>
-</html>
-
-
-<%!
- local_script_files = []
-%>