From: Mike Bayer
Date: Mon, 23 Jan 2012 21:21:28 +0000 (-0500)
Subject: integrate new readthedocs/sqla.org doc build
X-Git-Tag: rel_0_6_9~9
X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb884dabbf39563d59f9b94665a28d72a81b8cb4;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git
integrate new readthedocs/sqla.org doc build
---
diff --git a/doc/build/Makefile b/doc/build/Makefile
index 2ee70dfb8b..e08b72b3fc 100644
--- a/doc/build/Makefile
+++ b/doc/build/Makefile
@@ -18,7 +18,6 @@ help:
@echo "Please use \`make ' where is one of"
@echo " html to make standalone HTML files"
@echo " dist-html same as html, but places files in /doc"
- @echo " site-mako to make sqlalchemy.org Mako files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@@ -48,13 +47,6 @@ dist-html:
@echo
@echo "Build finished. The HTML pages are in ../."
-site-mako:
- $(SPHINXBUILD) -b html -A mako_layout=site $(ALLSPHINXOPTS) $(BUILDDIR)/site
- $(MAKE) latexpdf
- cp $(BUILDDIR)/latex/*.pdf $(BUILDDIR)/site/
- @echo
- @echo "Build finished. The Mako pages are in $(BUILDDIR)/site."
-
dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
diff --git a/doc/build/builder/builders.py b/doc/build/builder/builders.py
index 308bd3b092..66ccf8dd19 100644
--- a/doc/build/builder/builders.py
+++ b/doc/build/builder/builders.py
@@ -11,29 +11,72 @@ from pygments.formatters import HtmlFormatter, LatexFormatter
import re
from mako.lookup import TemplateLookup
from mako.template import Template
+from mako import __version__
+import os
+
+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['release_date'] = builder.config['release_date']
- builder.config.html_context['versions'] = builder.config['versions']
-
+ builder.config.html_context['site_base'] = builder.config['site_base']
+
self.lookup = TemplateLookup(directories=builder.config.templates_path,
- format_exceptions=True,
+ #format_exceptions=True,
imports=[
"from builder import util"
]
)
+ if rtd:
+ import urllib2
+ template_url = builder.config['site_base'] + "/docs_base.mako"
+ template = urllib2.urlopen(template_url).read()
+ self.lookup.put_string("/rtd_base.mako", template)
+
def render(self, template, context):
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...
+ version = context['version']
+ pathto = context['pathto']
+
+ # 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'] = context['project'].lower()
+ if 'url' not in context:
+ context['url'] = "/some/test/url"
+ if 'current_version' not in context:
+ context['current_version'] = "latest"
+
+ if 'name' not in context:
+ context['name'] = context['project'].lower()
+
+ context['rtd'] = True
+ context['toolbar'] = True
+ context['layout'] = "rtd_layout.mako"
+ context['base'] = "rtd_base.mako"
+ context['pdf_url'] = "%spdf/%s/%s/%s.pdf" % (
+ context['MEDIA_URL'],
+ context['slug'],
+ context['current_version'],
+ context['slug']
+ )
+ # local docs layout
+ else:
+ context['rtd'] = False
+ context['toolbar'] = False
+ context['layout'] = "layout.mako"
+ context['base'] = "static_base.mako"
+
context.setdefault('_', lambda x:x)
return self.lookup.get_template(template).render_unicode(**context)
@@ -140,7 +183,7 @@ class PopupLatexFormatter(LatexFormatter):
for ttype, value in apply_filters(tokensource, [StripDocTestFilter()]):
if ttype in Token.Sql:
if ttype is not Token.Sql.Link and ttype is not Token.Sql.Open:
- yield Token.Literal, re.sub(r'(?:[{stop}|\n]*)$', '', value)
+ yield Token.Literal, re.sub(r'{stop}', '', value)
else:
continue
else:
@@ -150,7 +193,7 @@ class PopupLatexFormatter(LatexFormatter):
LatexFormatter.format(self, self._filter_tokens(tokensource), outfile)
def autodoc_skip_member(app, what, name, obj, skip, options):
- if what == 'class' and skip and name == '__init__':
+ if what == 'class' and skip and name in ('__init__', '__eq__', '__ne__', '__lt__', '__le__') and obj.__doc__:
return False
else:
return skip
@@ -158,9 +201,10 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
def setup(app):
app.add_lexer('pycon+sql', PyConWithSQLLexer())
app.add_lexer('python+sql', PythonWithSQLLexer())
- app.connect('autodoc-skip-member', autodoc_skip_member)
app.add_config_value('release_date', "", True)
- app.add_config_value('versions', "", True)
+ app.add_config_value('site_base', "", True)
+ app.add_config_value('build_number', "", 1)
+ app.connect('autodoc-skip-member', autodoc_skip_member)
PygmentsBridge.html_formatter = PopupSQLFormatter
PygmentsBridge.latex_formatter = PopupLatexFormatter
diff --git a/doc/build/conf.py b/doc/build/conf.py
index 8db196aad0..1bb3c5475e 100644
--- a/doc/build/conf.py
+++ b/doc/build/conf.py
@@ -68,7 +68,11 @@ release = "0.6.8"
release_date = "June 5, 2011"
-versions = [('0.7', '07'), ('0.6', '06'), ('0.5', '05')]
+site_base = "http://www.sqlalchemy.org"
+
+# arbitrary number recognized by builders.py, incrementing this
+# will force a rebuild
+build_number = 2
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
diff --git a/doc/build/static/docs.css b/doc/build/static/docs.css
index 1169a8a975..9a40fd6bf9 100644
--- a/doc/build/static/docs.css
+++ b/doc/build/static/docs.css
@@ -433,3 +433,14 @@ div#dialect-documentation {
border-top:1px solid;
/*clear:left;*/
}
+
+div .versionwarning,
+div .version-warning {
+ font-size:12px;
+ font-color:red;
+ border:1px solid;
+ padding:4px 4px;
+ margin:8px 0px 2px 0px;
+ background:#FFBBBB;
+}
+
diff --git a/doc/build/static/init.js b/doc/build/static/init.js
index fb250480b4..cd4dac6b91 100644
--- a/doc/build/static/init.js
+++ b/doc/build/static/init.js
@@ -1,7 +1,13 @@
-$(document).ready(function(){
+
+function initSQLPopups() {
$('div.popup_sql').hide();
$('a.sql_link').click(function() {
$(this).nextAll('div.popup_sql:first').toggle();
return false;
})
+}
+
+$(document).ready(function() {
+ initSQLPopups();
});
+
diff --git a/doc/build/templates/genindex.mako b/doc/build/templates/genindex.mako
index b1a44f56d0..fce20f28db 100644
--- a/doc/build/templates/genindex.mako
+++ b/doc/build/templates/genindex.mako
@@ -1,6 +1,8 @@
-<%inherit file="layout.mako"/>
+<%inherit file="${context['layout']}"/>
-<%def name="show_title()">${_('Index')}%def>
+<%block name="show_title" filter="util.striptags">
+ ${_('Index')}
+%block>
${_('Index')}
diff --git a/doc/build/templates/layout.mako b/doc/build/templates/layout.mako
index d34e4ef38a..def9585d5b 100644
--- a/doc/build/templates/layout.mako
+++ b/doc/build/templates/layout.mako
@@ -1,5 +1,9 @@
## coding: utf-8
+<%!
+ local_script_files = []
+%>
+
<%doc>
Structural elements are all prefixed with "docs-"
to prevent conflicts when the structure is integrated into the
@@ -19,12 +23,19 @@
docs-copyright
%doc>
-<%inherit file="${context['mako_layout']}"/>
+<%inherit file="${context['base']}"/>
<%
withsidebar = bool(toc) and current_page_name != 'index'
%>
+<%block name="head_title">
+ % if current_page_name != 'index':
+ ${capture(self.show_title) | util.striptags} —
+ % endif
+ ${docstitle|h}
+%block>
+
<%block name="headers">
@@ -78,15 +89,10 @@ withsidebar = bool(toc) and current_page_name != 'index'
@@ -128,9 +134,7 @@ withsidebar = bool(toc) and current_page_name != 'index'
<%block name="show_title">
- % if title:
${title}
- % endif
%block>
@@ -157,6 +161,11 @@ withsidebar = bool(toc) and current_page_name != 'index'
% endif
+ % if rtd:
+ Project Versions
+
+ % endif
+
Quick Search