Discussion:
[Python-3000-checkins] r65202 - in python/branches/py3k: Doc/tools/sphinxext/pyspecific.py
georg.brandl
2008-07-23 15:19:11 UTC
Permalink
Author: georg.brandl
Date: Wed Jul 23 17:19:11 2008
New Revision: 65202

Log:
Merged revisions 65199 via svnmerge from
svn+ssh://pythondev at svn.python.org/python/trunk

........
r65199 | georg.brandl | 2008-07-23 17:17:09 +0200 (Wed, 23 Jul 2008) | 2 lines

Move opcode handling to Python's extension.
........


Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Doc/tools/sphinxext/pyspecific.py

Modified: python/branches/py3k/Doc/tools/sphinxext/pyspecific.py
==============================================================================
--- python/branches/py3k/Doc/tools/sphinxext/pyspecific.py (original)
+++ python/branches/py3k/Doc/tools/sphinxext/pyspecific.py Wed Jul 23 17:19:11 2008
@@ -83,6 +83,28 @@
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)

Loading...