diff --git a/doc/_static/psycopg.css b/doc/_static/psycopg.css new file mode 100644 index 00000000..fd84ba09 --- /dev/null +++ b/doc/_static/psycopg.css @@ -0,0 +1,6 @@ +@import url("default.css"); + +div.dbapi-extension { + background-color: #f5ffd4; + border: 1px solid #bda; +} diff --git a/doc/conf.py b/doc/conf.py index 541de32b..51212139 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -22,7 +22,8 @@ import sys, os # 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.todo', 'sphinx.ext.ifconfig'] +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo', 'sphinx.ext.ifconfig', + 'dbapi_extension' ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -109,6 +110,10 @@ rst_epilog = """ # Sphinx are currently 'default' and 'sphinxdoc'. html_theme = 'default' +# The stylesheet to use with HTML output: this will include the original one +# adding a few classes. +html_style = 'psycopg.css' + # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. diff --git a/doc/dbapi_extension.py b/doc/dbapi_extension.py new file mode 100755 index 00000000..583c7523 --- /dev/null +++ b/doc/dbapi_extension.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +""" + extension + ~~~~~~~~~ + + A directive to create a box warning that a certain bit of Psycopg is an + extension to the DBAPI 2.0. + + :copyright: Copyright 2010 by Daniele Varrazzo. +""" + +from docutils import nodes + +from sphinx.util.compat import Directive, make_admonition + +class extension_node(nodes.Admonition, nodes.Element): pass + + +class Extension(Directive): + """ + An extension entry, displayed as an admonition. + """ + + has_content = True + required_arguments = 0 + optional_arguments = 0 + final_argument_whitespace = False + option_spec = {} + + def run(self): + nodes = make_admonition(extension_node, + self.name, [_('DB API extension')], self.options, + self.content, self.lineno, self.content_offset, + self.block_text, self.state, self.state_machine) + nodes[0]['classes'].append('dbapi-extension') + return nodes + + +def visit_extension_node(self, node): + self.visit_admonition(node) + +def depart_extension_node(self, node): + self.depart_admonition(node) + +def setup(app): + app.add_node(extension_node, + html=(visit_extension_node, depart_extension_node), + latex=(visit_extension_node, depart_extension_node), + text=(visit_extension_node, depart_extension_node)) + + app.add_directive('extension', Extension) +