From f0dd6a672d91259b9e56b714c2435f8ce3722c51 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 23 Jul 2008 15:19:11 +0000 Subject: [PATCH] Merged revisions 65199 via svnmerge from svn+ssh://pythondev@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. ........ --- Doc/tools/sphinxext/pyspecific.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py index 6ca48059fdc..42bb1bfceef 100644 --- a/Doc/tools/sphinxext/pyspecific.py +++ b/Doc/tools/sphinxext/pyspecific.py @@ -83,6 +83,28 @@ def finish(self): 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)