summaryrefslogtreecommitdiffstats
path: root/docs/lib/sql_role.py
blob: a40c9f40419bf3ff3f4107989e7cd7f7b217572f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# -*- coding: utf-8 -*-
"""
    sql role
    ~~~~~~~~

    An interpreted text role to style SQL syntax in Psycopg documentation.

    :copyright: Copyright 2010 by Daniele Varrazzo.
    :copyright: Copyright 2020 The Psycopg Team.
"""

from docutils import nodes, utils
from docutils.parsers.rst import roles


def sql_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
    text = utils.unescape(text)
    options["classes"] = ["sql"]
    return [nodes.literal(rawtext, text, **options)], []


def setup(app):
    roles.register_local_role("sql", sql_role)