Skip to content
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

Restrict class interface? #25

Closed
mriehl opened this issue Jan 22, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@mriehl
Copy link

commented Jan 22, 2015

Hi,

Subclassing bloated classes (like cmd.Cmd) will result in pdoc showing all methods from the inheritance tree, which is a lot.

Is there some kind of __all__ at the class level to restrict these? The Cmd class for example has lots of internal methods that do not begin with underscores, and I would like to omit those from the documentation.

Any ideas how to go about this?

@BurntSushi

This comment has been minimized.

Copy link
Contributor

commented Jan 22, 2015

Hmm. You can technically achieve your goal today, but it isn't pretty. It's based on this little line at the end of the docs:

If __pdoc__[key] = None, then key will not be included in the public interface of the module.

So if Cmd has a member foo that you don't want to show up, I think you can do this:

class MyCmd(Cmd):
    __pdoc__['MyCmd.foo'] = None

Listing all the fields sucks, so maybe you can do:

class MyCmd(Cmd):
    for field in Cmd.__dict__.keys():
        __pdoc__['MyCmd.%s' % field] = None

But this isn't pretty. In that light, I think #15 is a duplicate.

@mriehl

This comment has been minimized.

Copy link
Author

commented Jan 22, 2015

Thanks!
It does the job for my use case, so I'll close this in favor of #15 which has more discussion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.