summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-07-23 15:17:09 (GMT)
committerGeorg Brandl <georg@python.org>2008-07-23 15:17:09 (GMT)
commitd4c7e636a98323c1d88ab6936318d4052117dc10 (patch)
treed164f0a9e923125fb106a6eb0c528ca0af528ad0
parentf9efabb6d216791076bd386dd6c6e33055433910 (diff)
downloadcpython-d4c7e636a98323c1d88ab6936318d4052117dc10.zip
cpython-d4c7e636a98323c1d88ab6936318d4052117dc10.tar.gz
cpython-d4c7e636a98323c1d88ab6936318d4052117dc10.tar.bz2
Move opcode handling to Python's extension.
-rw-r--r--Doc/tools/sphinxext/pyspecific.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py
index 568a6a1..9a8b897 100644
--- a/Doc/tools/sphinxext/pyspecific.py
+++ b/Doc/tools/sphinxext/pyspecific.py
@@ -85,6 +85,28 @@ class PydocTopicsBuilder(Builder):
f.close()
+# Support for documenting Opcodes
+
+import re
+from sphinx import addnodes
+
+opcode_sig_re = re.compile(r'(\w+(?:\+\d)?)\s*\((.*)\)')
+
+def parse_opcode_signature(env, sig, signode):
+ """Transform an opcode signature into RST nodes."""
+ m = opcode_sig_re.match(sig)
+ if m is None:
+ raise ValueError
+ opname, arglist = m.groups()
+ signode += addnodes.desc_name(opname, opname)
+ paramlist = addnodes.desc_parameterlist()
+ signode += paramlist
+ paramlist += addnodes.desc_parameter(arglist, arglist)
+ return opname.strip()
+
+
def setup(app):
app.add_role('issue', issue_role)
app.add_builder(PydocTopicsBuilder)
+ app.add_description_unit('opcode', 'opcode', '%s (opcode)',
+ parse_opcode_signature)