Skip to content

compiler module deprecated #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
metakermit opened this issue Jan 21, 2014 · 5 comments
Closed

compiler module deprecated #8

metakermit opened this issue Jan 21, 2014 · 5 comments

Comments

@metakermit
Copy link
Contributor

Currently raises ImportError on Python 3.

As mentioned here, the module's functionality should be replaced with one of these:

@pv
Copy link
Member

pv commented Jan 22, 2014

Those are used only in the traits and phantom_import sphinx plugins. If you don't use them, you are fine.

IIRC, porting those modules from compiler is not completely straightforward, so I left it to someone who actually uses them.

@metakermit
Copy link
Contributor Author

I'm trying to dig into them. Does anyone maybe know more about these traits (comment_eater.get_class_traits in specific)? I don't see it documented or tested. From what I saw, it parses the top-level assignments in a class, but I can't figure out what doc is it trying to get. For example for this class:

class Bla(object):
    ''' class description '''
    # before
    a = 7 # same line
    # after

it still only returns doc='':

In [2]: list(get_class_traits(Bla))
Out[2]: [('a', '7', '')]

@rkern
Copy link
Member

rkern commented Jan 22, 2014

It's for documenting HasTraits subclasses that typically look like this:

from traits.api import Float, HasTraits

class Position(HasTraits):
    # The X coordinate.
    x = Float(10.0)

    # The Y coordinate.
    y = Float(20.0)

I'm not entirely sure why it got pushed up into numpydoc.

@metakermit
Copy link
Contributor Author

Thanks @rkern. Think I understand the idea now. I guess it's in numpydoc, because it should work for any class (nothing from traits.api is imported).

Think I also found a bug in the current implementation - search_for_comment should state block = self.index.get(lineno - 1, None) instead of just lineno. I'll send a PR once I manage to use ast.

@rkern
Copy link
Member

rkern commented Jan 22, 2014

comment_eater is only used in traitsdoc which, while it does not import traits itself, does only work for HasTraits subclasses by checking the names of the superclasses.

Thanks for updating all this! We've just got traits ported to Python 3 and this will be very nice to have working there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants