Closed pslacerda closed 8 years ago
Funnily enough, in ipython
gromacs.tool_name?
works and shows the doc string:
In [6]: gromacs.grompp?
Type: Grompp
String form: <gromacs.tools.Grompp object at 0x105c60910>
File: /Volumes/Data/oliver/Biop/Projects/Methods/GromacsWrapper/gromacs/tools.py
Signature: gromacs.grompp(self, *args, **kwargs)
Docstring:
DESCRIPTION
gmx grompp (the gromacs preprocessor) reads a molecular topology file, checks
the validity of the file, expands the topology from a molecular description to
...
whereas
In [8]: help(gromacs.grompp)
Help on Grompp in module gromacs.tools object:
class Grompp(gromacs.core.GromacsCommand)
| Gromacs tool '%(name)r'.
|
| Method resolution order:
| Grompp
| gromacs.core.GromacsCommand
| gromacs.core.Command
| __builtin__.object
|
| Data and other attributes defined here:
|
| command_name = 'grompp'
|
| driver = 'gmx'
|
| ----------------------------------------------------------------------
| Methods inherited from gromacs.core.GromacsCommand:
|
| __init__(self, *args, **kwargs)
| Set up the command with gromacs flags as keyword arguments.
|
| The following are generic instructions; refer to the Gromacs
Funny that getdoc
works but help
doesn't.
import pydoc, gromacs
pydoc.getdoc(gromacs.trjconv)
pydoc.help(gromacs.trjconv)
Is related to the fact that properties are being used as C
has the same problem:
class C:
@property
def __doc__(self):
return "c"
I looked at https://bfroehle.com/2012/11/08/property-for-doc-attribute/ (see https://gist.github.com/bfroehle/4041015) which proposes a custom docstring_property
but when I tried it, it didn't not solve our problem, it just makes a class-level doc string available when there's no generated property doc string.
I also looked on StackOverflow but couldn't find an answer.
Given that you have a minimum working example do you want to ask on S/O?
Nice read, I never heard about the descriptor protocol and just learned a bit about how Python resolve member attributes of an object.
Also very funny, I tried dostring_property
than set up some breakpoints inside pydoc.py to realize that help
works on the object's class instead of the object itself (see https://hg.python.org/cpython/file/v2.7.12/Lib/pydoc.py#l1571). It means that help(1)
invokes the int
class help instead of print the __doc__
. Maybe shows the doc string is a IPython feature?
So much work and we simply need to remove this line https://github.com/Becksteinlab/GromacsWrapper/blob/develop/gromacs/__init__.py#L77
Just committed =)
Yes, I agree – changing the docs was the easiest route.
(It is slightly strange behavior that help()
only shows the class-level doc string. We could perhaps do something very hackish with class methods but I didn't find a useable solution and it does not seem worthwhile.... more important things to do.)
gromacs.tool_name.help()
works buthelp(gromacs.tool_name)
doesn't