Sorry, in the patch attached in last mail, the
'Tools/cython-epydoc.py' script is a bit broken. The attached script
is perhaps more appropriate.
On Thu, Sep 18, 2008 at 6:28 PM, Lisandro Dalcin <[EMAIL PROTECTED]> wrote:
> Function/method signature embedding finally implemented. Currently,
> this seems to work just fine for mpi4py and petsc4py. I would love
> Stefan give a try in lxml, and Robert in sage. Fernando and Brian CC'd
> (sorry if you get this twice!), as they could provide further comments
> on this, especially regarding the way signatures are formatted. After
> some rounds, perhaps IPython could be made even smarter at the time of
> displaying info on the console.
>
> Finally, some notes about the attached patch.
>
> * All this needs to be properly documented (I hardly find spare time
> for documenting my own projects!)
> * A testcase was added, perhaps it needs to be extended.
> * This do not play well with '--embed-positions' global option
> * I did not handle any indentation issues.
> * Pehaps the determination of the value for default arguments could be
> made smarter.
> * The epydoc monkeypatching in Tools/cython-epydoc.py only tested with
> epydoc-3.0.1.
>
> Enjoy!
>
> --
> Lisandro Dalcín
> ---------------
> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
> Tel/Fax: +54-(0)342-451.1594
>
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
#! /usr/bin/env python
# --------------------------------------------------------------------
import re
from epydoc import docstringparser as dsp
CYTHON_SIGNATURE_RE = re.compile(
# Class name (for builtin methods)
r'^\s*((?P<class>\w+)\.)?' +
# The function name
r'(?P<func>\w+)' +
# The parameters
r'\(((?P<self>(?:self|cls|mcs)),?)?(?P<params>.*)\)' +
# The return value (optional)
r'(\s*(->)\s*(?P<return>\w+(?:\s*\w+)))?' +
# The end marker
r'\s*(?:\n|$)')
parse_signature = dsp.parse_function_signature
def parse_function_signature(func_doc, doc_source,
docformat, parse_errors):
PYTHON_SIGNATURE_RE = dsp._SIGNATURE_RE
assert PYTHON_SIGNATURE_RE is not CYTHON_SIGNATURE_RE
try:
dsp._SIGNATURE_RE = CYTHON_SIGNATURE_RE
found = parse_signature(func_doc, doc_source,
docformat, parse_errors)
dsp._SIGNATURE_RE = PYTHON_SIGNATURE_RE
if not found:
found = parse_signature(func_doc, doc_source,
docformat, parse_errors)
return found
finally:
dsp._SIGNATURE_RE = PYTHON_SIGNATURE_RE
dsp.parse_function_signature = parse_function_signature
# --------------------------------------------------------------------
from epydoc.cli import cli
cli()
# --------------------------------------------------------------------
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev