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