traitlets icon indicating copy to clipboard operation
traitlets copied to clipboard

help= does not set trait docstring

Open astrofrog opened this issue 7 years ago • 6 comments

At the moment, it looks like the help= text doesn't set the __doc__ attribute of traits, which produces this kind of output when using sphinx's autosummary:

screen shot 2017-12-04 at 15 01 23

Would it be possible to use the help text to also set __doc__ on traits or is there a good reason why this isn't done?

astrofrog avatar Dec 04 '17 15:12 astrofrog

It isn't usual to set __doc__ on instances of types, is it?

minrk avatar Dec 06 '17 12:12 minrk

@minrk - is there any reason not to though? Documentation pages like the one above would look a lot clearer.

astrofrog avatar Dec 06 '17 12:12 astrofrog

What's generating that page? Is there any precedent for setting __doc__ on instances? I'm not necessarily opposed, I'd just like to not be the first to change the meaning of a a pretty fundamental Python attribute.

minrk avatar Dec 07 '17 12:12 minrk

The page was generated by sphinx-automodapi but I think ultimately that uses autoattribute from Sphinx's autodoc.

astrofrog avatar Dec 07 '17 15:12 astrofrog

I second this request. I am running into exactly the same problem. I have put in help strings for each of my traits but they do not show up in the documentation. How do I document the traits that are used by a class? I would prefer to not replicate the help string, but documenting a class's traits even with duplicating the help string would be much better than getting a table like above.

I just came across the autoattribute attribute documentation. I discovered that I can add the documentation that I want by adding a triple-quoted docstring on the line below the Trait definition.

pwm1234 avatar Jan 31 '19 21:01 pwm1234

The triple quoted string works with the exception that when traits are inherited from parent classes, the subclass documentation shows the original trait documentation.

dopplershift avatar May 15 '19 21:05 dopplershift