mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 09:24:07 +03:00
Added `extension
` directive to mark Psycopg extensions to the DB API.
This commit is contained in:
parent
3e66529864
commit
5417d7153d
6
doc/_static/psycopg.css
vendored
Normal file
6
doc/_static/psycopg.css
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
@import url("default.css");
|
||||
|
||||
div.dbapi-extension {
|
||||
background-color: #f5ffd4;
|
||||
border: 1px solid #bda;
|
||||
}
|
|
@ -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.
|
||||
|
|
52
doc/dbapi_extension.py
Executable file
52
doc/dbapi_extension.py
Executable file
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user