summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-10-19 19:20:18 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-10-19 19:20:18 -0400
commit675558bffb3c58647cde2605186dd7d7d7d9e593 (patch)
tree62b19270c21cd42706fb5c01b3cf9aed1d296687 /doc
parent5cd1d774c2ed35eecd47cd189903640618ca89c3 (diff)
downloadsqlalchemy-675558bffb3c58647cde2605186dd7d7d7d9e593.tar.gz
- rework the sphinx customizations into distinct modules
- build a new Sphinx extension that allows dialect info to be entered as directives which is then rendered consistently throughout all dialect/dbapi sections - break out the "empty_strings" requirement for oracle test
Diffstat (limited to 'doc')
-rw-r--r--doc/build/builder/__init__.py12
-rw-r--r--doc/build/builder/autodoc_mods.py47
-rw-r--r--doc/build/builder/builders.py244
-rw-r--r--doc/build/builder/dialect_info.py175
-rw-r--r--doc/build/builder/mako.py79
-rw-r--r--doc/build/builder/sqlformatter.py132
-rw-r--r--doc/build/conf.py5
-rw-r--r--doc/build/dialects/drizzle.rst6
-rw-r--r--doc/build/dialects/firebird.rst2
-rw-r--r--doc/build/dialects/informix.rst4
-rw-r--r--doc/build/dialects/mssql.rst4
-rw-r--r--doc/build/dialects/mysql.rst16
-rw-r--r--doc/build/dialects/oracle.rst10
-rw-r--r--doc/build/dialects/postgresql.rst7
-rw-r--r--doc/build/dialects/sybase.rst6
15 files changed, 462 insertions, 287 deletions
diff --git a/doc/build/builder/__init__.py b/doc/build/builder/__init__.py
index e69de29bb..0e29e69c4 100644
--- a/doc/build/builder/__init__.py
+++ b/doc/build/builder/__init__.py
@@ -0,0 +1,12 @@
+
+
+from . import autodoc_mods, dialect_info, sqlformatter, mako
+
+def setup(app):
+ app.add_config_value('release_date', "", True)
+ app.add_config_value('site_base', "", True)
+ app.add_config_value('build_number', "", 1)
+ mako.setup(app)
+ autodoc_mods.setup(app)
+ dialect_info.setup(app)
+ sqlformatter.setup(app)
diff --git a/doc/build/builder/autodoc_mods.py b/doc/build/builder/autodoc_mods.py
new file mode 100644
index 000000000..8c687fb3a
--- /dev/null
+++ b/doc/build/builder/autodoc_mods.py
@@ -0,0 +1,47 @@
+import re
+
+def autodoc_skip_member(app, what, name, obj, skip, options):
+ if what == 'class' and skip and \
+ name in ('__init__', '__eq__', '__ne__', '__lt__',
+ '__le__', '__call__') and \
+ obj.__doc__:
+ return False
+ else:
+ return skip
+
+# im sure this is in the app somewhere, but I don't really
+# know where, so we're doing it here.
+_track_autodoced = {}
+def autodoc_process_docstring(app, what, name, obj, options, lines):
+ if what == "class":
+ _track_autodoced[name] = obj
+ elif what in ("attribute", "method") and \
+ options.get("inherited-members"):
+ m = re.match(r'(.*?)\.([\w_]+)$', name)
+ if m:
+ clsname, attrname = m.group(1, 2)
+ if clsname in _track_autodoced:
+ cls = _track_autodoced[clsname]
+ for supercls in cls.__mro__:
+ if attrname in supercls.__dict__:
+ break
+ if supercls is not cls:
+ lines[:0] = [
+ ".. container:: inherited_member",
+ "",
+ " *inherited from the* :%s:`.%s.%s` *%s of* :class:`.%s`" % (
+ "attr" if what == "attribute"
+ else "meth",
+ supercls.__name__,
+ attrname,
+ what,
+ supercls.__name__
+ ),
+ ""
+ ]
+
+
+def setup(app):
+ app.connect('autodoc-skip-member', autodoc_skip_member)
+ app.connect('autodoc-process-docstring', autodoc_process_docstring)
+
diff --git a/doc/build/builder/builders.py b/doc/build/builder/builders.py
deleted file mode 100644
index 0776bd475..000000000
--- a/doc/build/builder/builders.py
+++ /dev/null
@@ -1,244 +0,0 @@
-from sphinx.application import TemplateBridge
-from sphinx.builders.html import StandaloneHTMLBuilder
-from sphinx.highlighting import PygmentsBridge
-from sphinx.jinja2glue import BuiltinTemplateLoader
-from pygments import highlight
-from pygments.lexer import RegexLexer, bygroups, using
-from pygments.token import *
-from pygments.filter import Filter, apply_filters
-from pygments.lexers import PythonLexer, PythonConsoleLexer
-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)
-
- builder.config.html_context['release_date'] = builder.config['release_date']
- builder.config.html_context['site_base'] = builder.config['site_base']
-
- self.lookup = TemplateLookup(directories=builder.config.templates_path,
- #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)
- 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)
-
- def render_string(self, template, context):
- # this is used for .js, .css etc. and we don't have
- # local copies of that stuff here so use the jinja render.
- return self.jinja2_fallback.render_string(template, context)
-
-class StripDocTestFilter(Filter):
- def filter(self, lexer, stream):
- for ttype, value in stream:
- if ttype is Token.Comment and re.match(r'#\s*doctest:', value):
- continue
- yield ttype, value
-
-class PyConWithSQLLexer(RegexLexer):
- name = 'PyCon+SQL'
- aliases = ['pycon+sql']
-
- flags = re.IGNORECASE | re.DOTALL
-
- tokens = {
- 'root': [
- (r'{sql}', Token.Sql.Link, 'sqlpopup'),
- (r'{opensql}', Token.Sql.Open, 'opensqlpopup'),
- (r'.*?\n', using(PythonConsoleLexer))
- ],
- 'sqlpopup':[
- (
- r'(.*?\n)((?:PRAGMA|BEGIN|SELECT|INSERT|DELETE|ROLLBACK|COMMIT|ALTER|UPDATE|CREATE|DROP|PRAGMA|DESCRIBE).*?(?:{stop}\n?|$))',
- bygroups(using(PythonConsoleLexer), Token.Sql.Popup),
- "#pop"
- )
- ],
- 'opensqlpopup':[
- (
- r'.*?(?:{stop}\n*|$)',
- Token.Sql,
- "#pop"
- )
- ]
- }
-
-
-class PythonWithSQLLexer(RegexLexer):
- name = 'Python+SQL'
- aliases = ['pycon+sql']
-
- flags = re.IGNORECASE | re.DOTALL
-
- tokens = {
- 'root': [
- (r'{sql}', Token.Sql.Link, 'sqlpopup'),
- (r'{opensql}', Token.Sql.Open, 'opensqlpopup'),
- (r'.*?\n', using(PythonLexer))
- ],
- 'sqlpopup':[
- (
- r'(.*?\n)((?:PRAGMA|BEGIN|SELECT|INSERT|DELETE|ROLLBACK|COMMIT|ALTER|UPDATE|CREATE|DROP|PRAGMA|DESCRIBE).*?(?:{stop}\n?|$))',
- bygroups(using(PythonLexer), Token.Sql.Popup),
- "#pop"
- )
- ],
- 'opensqlpopup':[
- (
- r'.*?(?:{stop}\n*|$)',
- Token.Sql,
- "#pop"
- )
- ]
- }
-
-
-def _strip_trailing_whitespace(iter_):
- buf = list(iter_)
- if buf:
- buf[-1] = (buf[-1][0], buf[-1][1].rstrip())
- for t, v in buf:
- yield t, v
-
-class PopupSQLFormatter(HtmlFormatter):
- def _format_lines(self, tokensource):
- buf = []
- for ttype, value in apply_filters(tokensource, [StripDocTestFilter()]):
- if ttype in Token.Sql:
- for t, v in HtmlFormatter._format_lines(self, iter(buf)):
- yield t, v
- buf = []
-
- if ttype is Token.Sql:
- yield 1, "<div class='show_sql'>%s</div>" % re.sub(r'(?:[{stop}|\n]*)$', '', value)
- elif ttype is Token.Sql.Link:
- yield 1, "<a href='#' class='sql_link'>sql</a>"
- elif ttype is Token.Sql.Popup:
- yield 1, "<div class='popup_sql'>%s</div>" % re.sub(r'(?:[{stop}|\n]*)$', '', value)
- else:
- buf.append((ttype, value))
-
- for t, v in _strip_trailing_whitespace(HtmlFormatter._format_lines(self, iter(buf))):
- yield t, v
-
-class PopupLatexFormatter(LatexFormatter):
- def _filter_tokens(self, tokensource):
- 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}', '', value)
- else:
- continue
- else:
- yield ttype, value
-
- def format(self, tokensource, outfile):
- 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 in ('__init__', '__eq__', '__ne__', '__lt__', '__le__', '__call__') and \
- obj.__doc__:
- return False
- else:
- return skip
-
-# im sure this is in the app somewhere, but I don't really
-# know where, so we're doing it here.
-_track_autodoced = {}
-def autodoc_process_docstring(app, what, name, obj, options, lines):
- if what == "class":
- _track_autodoced[name] = obj
- elif what in ("attribute", "method") and \
- options.get("inherited-members"):
- m = re.match(r'(.*?)\.([\w_]+)$', name)
- if m:
- clsname, attrname = m.group(1, 2)
- if clsname in _track_autodoced:
- cls = _track_autodoced[clsname]
- for supercls in cls.__mro__:
- if attrname in supercls.__dict__:
- break
- if supercls is not cls:
- lines[:0] = [
- ".. container:: inherited_member",
- "",
- " *inherited from the* :%s:`.%s.%s` *%s of* :class:`.%s`" % (
- "attr" if what == "attribute"
- else "meth",
- supercls.__name__,
- attrname,
- what,
- supercls.__name__
- ),
- ""
- ]
-
-def setup(app):
- app.add_lexer('pycon+sql', PyConWithSQLLexer())
- app.add_lexer('python+sql', PythonWithSQLLexer())
- app.add_config_value('release_date', "", True)
- app.add_config_value('site_base', "", True)
- app.add_config_value('build_number', "", 1)
- app.connect('autodoc-skip-member', autodoc_skip_member)
- app.connect('autodoc-process-docstring', autodoc_process_docstring)
- PygmentsBridge.html_formatter = PopupSQLFormatter
- PygmentsBridge.latex_formatter = PopupLatexFormatter
-
diff --git a/doc/build/builder/dialect_info.py b/doc/build/builder/dialect_info.py
new file mode 100644
index 000000000..808b3cdf4
--- /dev/null
+++ b/doc/build/builder/dialect_info.py
@@ -0,0 +1,175 @@
+import re
+from sphinx.util.compat import Directive
+from docutils import nodes
+
+class DialectDirective(Directive):
+ has_content = True
+
+ _dialects = {}
+
+ def _parse_content(self):
+ d = {}
+ d['default'] = self.content[0]
+ d['text'] = []
+ idx = 0
+ for line in self.content[1:]:
+ idx += 1
+ m = re.match(r'\:(.+?)\: +(.+)', line)
+ if m:
+ attrname, value = m.group(1, 2)
+ d[attrname] = value
+ else:
+ break
+ d["text"] = self.content[idx + 1:]
+ return d
+
+ def _dbapi_node(self):
+
+ dialect_name, dbapi_name = self.dialect_name.split("+")
+
+ try:
+ dialect_directive = self._dialects[dialect_name]
+ except KeyError:
+ raise Exception("No .. dialect:: %s directive has been established"
+ % dialect_name)
+
+ output = []
+
+ content = self._parse_content()
+
+ parent_section_ref = self.state.parent.children[0]['ids'][0]
+ self._append_dbapi_bullet(dialect_name, dbapi_name,
+ content['name'], parent_section_ref)
+
+ p = nodes.paragraph('', '',
+ nodes.Text(
+ "Support for the %s database via the %s driver." % (
+ dialect_directive.database_name,
+ content['name']
+ ),
+ "Support for the %s database via the %s driver." % (
+ dialect_directive.database_name,
+ content['name']
+ )
+ ),
+ )
+
+ self.state.nested_parse(content['text'], 0, p)
+ output.append(p)
+
+ if "url" in content or "driverurl" in content:
+ sec = nodes.section(
+ '',
+ nodes.title("DBAPI", "DBAPI"),
+ ids=["dialect-%s-%s-url" % (dialect_name, dbapi_name)]
+ )
+ if "url" in content:
+ text = "%s is available at:\n" % dbapi_name
+ uri = content['url']
+ sec.append(
+ nodes.paragraph('', '',
+ nodes.Text(text, text),
+ nodes.reference('', '',
+ nodes.Text(uri, uri),
+ refuri=uri,
+ )
+ )
+ )
+ if "driverurl" in content:
+ text = "Drivers for this database are available at:\n"
+ sec.append(
+ nodes.paragraph('', '',
+ nodes.Text(text, text),
+ nodes.reference('', '',
+ nodes.Text(content['driverurl'], content['driverurl']),
+ refuri=content['driverurl']
+ )
+ )
+ )
+ output.append(sec)
+
+
+ if "connectstring" in content:
+ # TODO: wish I knew how to just embed RST here and parse it into
+ # nodes
+ sec = nodes.section(
+ '',
+ nodes.title("Connecting", "Connecting"),
+ nodes.paragraph('', '',
+ nodes.Text("Connect String:", "Connect String:"),
+ nodes.literal_block(content['connectstring'],
+ content['connectstring'])
+ ),
+ ids=["dialect-%s-%s-connect" % (dialect_name, dbapi_name)]
+ )
+ output.append(sec)
+
+ return output
+
+ def _dialect_node(self):
+ self._dialects[self.dialect_name] = self
+
+ content = self._parse_content()
+ self.database_name = content['name']
+
+ self.bullets = nodes.bullet_list()
+ text = "The following dialect/DBAPI options are available. "\
+ "Please refer to individual DBAPI sections for connect information."
+ sec = nodes.section('',
+ nodes.paragraph('', '',
+ nodes.Text(
+ "Support for the %s database." % content['name'],
+ "Support for the %s database." % content['name']
+ ),
+ ),
+ nodes.title("DBAPI Support", "DBAPI Support"),
+ nodes.paragraph('', '',
+ nodes.Text(text, text),
+ self.bullets
+ ),
+ ids=["dialect-%s" % self.dialect_name]
+ )
+
+ return [sec]
+
+ def _append_dbapi_bullet(self, dialect_name, dbapi_name, name, idname):
+ env = self.state.document.settings.env
+ dialect_directive = self._dialects[dialect_name]
+
+ list_node = nodes.list_item('',
+ nodes.paragraph('', '',
+ nodes.reference('', '',
+ nodes.Text(name, name),
+ refdocname=self.docname,
+ refuri=env.app.builder.get_relative_uri(
+ dialect_directive.docname, self.docname) +
+ "#" + idname
+ ),
+ #nodes.Text(" ", " "),
+ #nodes.reference('', '',
+ # nodes.Text("(connectstring)", "(connectstring)"),
+ # refdocname=self.docname,
+ # refuri=env.app.builder.get_relative_uri(
+ # dialect_directive.docname, self.docname) +
+ ## "#" + ("dialect-%s-%s-connect" %
+ # (dialect_name, dbapi_name))
+ # )
+ )
+ )
+ dialect_directive.bullets.append(list_node)
+
+ def run(self):
+ env = self.state.document.settings.env
+ self.docname = env.docname
+
+ self.dialect_name = dialect_name = self.content[0]
+
+ has_dbapi = "+" in dialect_name
+ if has_dbapi:
+ return self._dbapi_node()
+ else:
+ return self._dialect_node()
+
+def setup(app):
+ app.add_directive('dialect', DialectDirective)
+
diff --git a/doc/build/builder/mako.py b/doc/build/builder/mako.py
new file mode 100644
index 000000000..0a6955188
--- /dev/null
+++ b/doc/build/builder/mako.py
@@ -0,0 +1,79 @@
+from __future__ import absolute_import
+
+from sphinx.application import TemplateBridge
+from sphinx.jinja2glue import BuiltinTemplateLoader
+from mako.lookup import TemplateLookup
+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)
+
+ builder.config.html_context['release_date'] = builder.config['release_date']
+ builder.config.html_context['site_base'] = builder.config['site_base']
+
+ self.lookup = TemplateLookup(directories=builder.config.templates_path,
+ #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)
+
+ # 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)
+
+ def render_string(self, template, context):
+ # this is used for .js, .css etc. and we don't have
+ # local copies of that stuff here so use the jinja render.
+ return self.jinja2_fallback.render_string(template, context)
+
+def setup(app):
+ app.config['template_bridge'] = "builder.mako.MakoBridge"
+
diff --git a/doc/build/builder/sqlformatter.py b/doc/build/builder/sqlformatter.py
new file mode 100644
index 000000000..2d8074900
--- /dev/null
+++ b/doc/build/builder/sqlformatter.py
@@ -0,0 +1,132 @@
+from pygments.lexer import RegexLexer, bygroups, using
+from pygments.token import Token
+from pygments.filter import Filter
+from pygments.filter import apply_filters
+from pygments.lexers import PythonLexer, PythonConsoleLexer
+from sphinx.highlighting import PygmentsBridge
+from pygments.formatters import HtmlFormatter, LatexFormatter
+
+import re
+
+
+def _strip_trailing_whitespace(iter_):
+ buf = list(iter_)
+ if buf:
+ buf[-1] = (buf[-1][0], buf[-1][1].rstrip())
+ for t, v in buf:
+ yield t, v
+
+
+class StripDocTestFilter(Filter):
+ def filter(self, lexer, stream):
+ for ttype, value in stream:
+ if ttype is Token.Comment and re.match(r'#\s*doctest:', value):
+ continue
+ yield ttype, value
+
+class PyConWithSQLLexer(RegexLexer):
+ name = 'PyCon+SQL'
+ aliases = ['pycon+sql']
+
+ flags = re.IGNORECASE | re.DOTALL
+
+ tokens = {
+ 'root': [
+ (r'{sql}', Token.Sql.Link, 'sqlpopup'),
+ (r'{opensql}', Token.Sql.Open, 'opensqlpopup'),
+ (r'.*?\n', using(PythonConsoleLexer))
+ ],
+ 'sqlpopup': [
+ (
+ r'(.*?\n)((?:PRAGMA|BEGIN|SELECT|INSERT|DELETE|ROLLBACK|'
+ 'COMMIT|ALTER|UPDATE|CREATE|DROP|PRAGMA'
+ '|DESCRIBE).*?(?:{stop}\n?|$))',
+ bygroups(using(PythonConsoleLexer), Token.Sql.Popup),
+ "#pop"
+ )
+ ],
+ 'opensqlpopup': [
+ (
+ r'.*?(?:{stop}\n*|$)',
+ Token.Sql,
+ "#pop"
+ )
+ ]
+ }
+
+
+class PythonWithSQLLexer(RegexLexer):
+ name = 'Python+SQL'
+ aliases = ['pycon+sql']
+
+ flags = re.IGNORECASE | re.DOTALL
+
+ tokens = {
+ 'root': [
+ (r'{sql}', Token.Sql.Link, 'sqlpopup'),
+ (r'{opensql}', Token.Sql.Open, 'opensqlpopup'),
+ (r'.*?\n', using(PythonLexer))
+ ],
+ 'sqlpopup': [
+ (
+ r'(.*?\n)((?:PRAGMA|BEGIN|SELECT|INSERT|DELETE|ROLLBACK'
+ '|COMMIT|ALTER|UPDATE|CREATE|DROP'
+ '|PRAGMA|DESCRIBE).*?(?:{stop}\n?|$))',
+ bygroups(using(PythonLexer), Token.Sql.Popup),
+ "#pop"
+ )
+ ],
+ 'opensqlpopup': [
+ (
+ r'.*?(?:{stop}\n*|$)',
+ Token.Sql,
+ "#pop"
+ )
+ ]
+ }
+
+class PopupSQLFormatter(HtmlFormatter):
+ def _format_lines(self, tokensource):
+ buf = []
+ for ttype, value in apply_filters(tokensource, [StripDocTestFilter()]):
+ if ttype in Token.Sql:
+ for t, v in HtmlFormatter._format_lines(self, iter(buf)):
+ yield t, v
+ buf = []
+
+ if ttype is Token.Sql:
+ yield 1, "<div class='show_sql'>%s</div>" % \
+ re.sub(r'(?:[{stop}|\n]*)$', '', value)
+ elif ttype is Token.Sql.Link:
+ yield 1, "<a href='#' class='sql_link'>sql</a>"
+ elif ttype is Token.Sql.Popup:
+ yield 1, "<div class='popup_sql'>%s</div>" % \
+ re.sub(r'(?:[{stop}|\n]*)$', '', value)
+ else:
+ buf.append((ttype, value))
+
+ for t, v in _strip_trailing_whitespace(
+ HtmlFormatter._format_lines(self, iter(buf))):
+ yield t, v
+
+class PopupLatexFormatter(LatexFormatter):
+ def _filter_tokens(self, tokensource):
+ 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}', '', value)
+ else:
+ continue
+ else:
+ yield ttype, value
+
+ def format(self, tokensource, outfile):
+ LatexFormatter.format(self, self._filter_tokens(tokensource), outfile)
+
+def setup(app):
+ app.add_lexer('pycon+sql', PyConWithSQLLexer())
+ app.add_lexer('python+sql', PythonWithSQLLexer())
+
+ PygmentsBridge.html_formatter = PopupSQLFormatter
+ PygmentsBridge.latex_formatter = PopupLatexFormatter
+
diff --git a/doc/build/conf.py b/doc/build/conf.py
index 9079232d5..73cd47e6b 100644
--- a/doc/build/conf.py
+++ b/doc/build/conf.py
@@ -30,10 +30,10 @@ import sqlalchemy
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
#extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode',
-# 'sphinx.ext.doctest', 'builder.builders']
+# 'sphinx.ext.doctest', 'builder']
extensions = ['sphinx.ext.autodoc',
- 'sphinx.ext.doctest', 'builder.builders']
+ 'sphinx.ext.doctest', 'builder']
# Add any paths that contain templates here, relative to this directory.
# not sure why abspath() is needed here, some users
@@ -45,7 +45,6 @@ nitpicky = True
# The suffix of source filenames.
source_suffix = '.rst'
-template_bridge = "builder.builders.MakoBridge"
# The encoding of source files.
#source_encoding = 'utf-8-sig'
diff --git a/doc/build/dialects/drizzle.rst b/doc/build/dialects/drizzle.rst
index ec0af93ce..99ff596d7 100644
--- a/doc/build/dialects/drizzle.rst
+++ b/doc/build/dialects/drizzle.rst
@@ -70,9 +70,7 @@ construction arguments, are as follows:
:show-inheritance:
-.. _drizzle_mysqldb:
-
-MySQL-Python Notes
---------------------
+MySQL-Python
+------------
.. automodule:: sqlalchemy.dialects.drizzle.mysqldb
diff --git a/doc/build/dialects/firebird.rst b/doc/build/dialects/firebird.rst
index 2ec0103ef..d5b6b2ffd 100644
--- a/doc/build/dialects/firebird.rst
+++ b/doc/build/dialects/firebird.rst
@@ -5,8 +5,6 @@ Firebird
.. automodule:: sqlalchemy.dialects.firebird.base
-.. _kinterbasdb:
-
kinterbasdb
-----------
diff --git a/doc/build/dialects/informix.rst b/doc/build/dialects/informix.rst
index 12eaa0438..f37ae6cf5 100644
--- a/doc/build/dialects/informix.rst
+++ b/doc/build/dialects/informix.rst
@@ -5,7 +5,7 @@ Informix
.. automodule:: sqlalchemy.dialects.informix.base
-informixdb Notes
---------------------
+informixdb
+----------
.. automodule:: sqlalchemy.dialects.informix.informixdb \ No newline at end of file
diff --git a/doc/build/dialects/mssql.rst b/doc/build/dialects/mssql.rst
index f96998332..615d1a11d 100644
--- a/doc/build/dialects/mssql.rst
+++ b/doc/build/dialects/mssql.rst
@@ -19,7 +19,7 @@ they originate from :mod:`sqlalchemy.types` or from the local dialect::
SMALLINT, SMALLMONEY, SQL_VARIANT, TEXT, TIME, \
TIMESTAMP, TINYINT, UNIQUEIDENTIFIER, VARBINARY, VARCHAR
-Types which are specific to SQL Server, or have SQL Server-specific
+Types which are specific to SQL Server, or have SQL Server-specific
construction arguments, are as follows:
.. currentmodule:: sqlalchemy.dialects.mssql
@@ -109,7 +109,7 @@ pymssql
-------
.. automodule:: sqlalchemy.dialects.mssql.pymssql
-zxjdbc Notes
+zxjdbc
--------------
.. automodule:: sqlalchemy.dialects.mssql.zxjdbc
diff --git a/doc/build/dialects/mysql.rst b/doc/build/dialects/mysql.rst
index 2110e375a..b5119f23f 100644
--- a/doc/build/dialects/mysql.rst
+++ b/doc/build/dialects/mysql.rst
@@ -155,50 +155,36 @@ construction arguments, are as follows:
:members: __init__
:show-inheritance:
-.. _mysqldb:
-
MySQL-Python
--------------------
.. automodule:: sqlalchemy.dialects.mysql.mysqldb
-.. _oursql:
-
OurSQL
--------------
.. automodule:: sqlalchemy.dialects.mysql.oursql
-.. _pymysql:
-
pymysql
-------------
.. automodule:: sqlalchemy.dialects.mysql.pymysql
-.. _mysqlconnector:
-
MySQL-Connector
----------------------
.. automodule:: sqlalchemy.dialects.mysql.mysqlconnector
-.. _gaerdbms:
-
Google App Engine
-----------------------
.. automodule:: sqlalchemy.dialects.mysql.gaerdbms
-.. _mysql_pyodbc:
-
pyodbc
---------------
+------
.. automodule:: sqlalchemy.dialects.mysql.pyodbc
-.. _mysql_zxjdbc:
-
zxjdbc
--------------
diff --git a/doc/build/dialects/oracle.rst b/doc/build/dialects/oracle.rst
index 5e259ead7..4be8c5b51 100644
--- a/doc/build/dialects/oracle.rst
+++ b/doc/build/dialects/oracle.rst
@@ -18,7 +18,7 @@ they originate from :mod:`sqlalchemy.types` or from the local dialect::
NUMBER, NVARCHAR, NVARCHAR2, RAW, TIMESTAMP, VARCHAR, \
VARCHAR2
-Types which are specific to Oracle, or have Oracle-specific
+Types which are specific to Oracle, or have Oracle-specific
construction arguments, are as follows:
.. currentmodule:: sqlalchemy.dialects.oracle
@@ -51,12 +51,12 @@ construction arguments, are as follows:
:members: __init__
:show-inheritance:
-cx_Oracle Notes
----------------
+cx_Oracle
+----------
.. automodule:: sqlalchemy.dialects.oracle.cx_oracle
-zxjdbc Notes
---------------
+zxjdbc
+-------
.. automodule:: sqlalchemy.dialects.oracle.zxjdbc
diff --git a/doc/build/dialects/postgresql.rst b/doc/build/dialects/postgresql.rst
index cf6f277f5..55705a037 100644
--- a/doc/build/dialects/postgresql.rst
+++ b/doc/build/dialects/postgresql.rst
@@ -76,23 +76,16 @@ psycopg2
.. automodule:: sqlalchemy.dialects.postgresql.psycopg2
-
-.. _pypostgresql:
-
py-postgresql
--------------------
.. automodule:: sqlalchemy.dialects.postgresql.pypostgresql
-.. _pg8000:
-
pg8000
--------------
.. automodule:: sqlalchemy.dialects.postgresql.pg8000
-.. _zxjdbc:
-
zxjdbc
--------------
diff --git a/doc/build/dialects/sybase.rst b/doc/build/dialects/sybase.rst
index 8200f223d..8e9695325 100644
--- a/doc/build/dialects/sybase.rst
+++ b/doc/build/dialects/sybase.rst
@@ -5,17 +5,17 @@ Sybase
.. automodule:: sqlalchemy.dialects.sybase.base
-python-sybase notes
+python-sybase
-------------------
.. automodule:: sqlalchemy.dialects.sybase.pysybase
-pyodbc notes
+pyodbc
------------
.. automodule:: sqlalchemy.dialects.sybase.pyodbc
-mxodbc notes
+mxodbc
------------
.. automodule:: sqlalchemy.dialects.sybase.mxodbc