• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# formatting.py
2# Sphinx extension providing formatting for Gallium-specific data
3# (c) Corbin Simpson 2010
4# Public domain to the extent permitted; contact author for special licensing
5
6import docutils.nodes
7import sphinx.addnodes
8
9def parse_envvar(env, sig, signode):
10    envvar, t, default = sig.split(" ", 2)
11    envvar = envvar.strip().upper()
12    t = " Type: %s" % t.strip(" <>").lower()
13    default = " Default: %s" % default.strip(" ()")
14    signode += sphinx.addnodes.desc_name(envvar, envvar)
15    signode += sphinx.addnodes.desc_type(t, t)
16    signode += sphinx.addnodes.desc_annotation(default, default)
17    return envvar
18
19def parse_opcode(env, sig, signode):
20    opcode, desc = sig.split("-", 1)
21    opcode = opcode.strip().upper()
22    desc = " (%s)" % desc.strip()
23    signode += sphinx.addnodes.desc_name(opcode, opcode)
24    signode += sphinx.addnodes.desc_annotation(desc, desc)
25    return opcode
26
27def setup(app):
28    app.add_description_unit("envvar", "envvar", "%s (environment variable)",
29        parse_envvar)
30    app.add_description_unit("opcode", "opcode", "%s (TGSI opcode)",
31        parse_opcode)
32