pytkdocs icon indicating copy to clipboard operation
pytkdocs copied to clipboard

Allow to specify what exactly is a docstring for a given class

Open yajo opened this issue 5 years ago • 2 comments

Is your feature request related to a problem? Please describe. Yes, the problem is that some libraries use different attributes for docstrings than just __doc__.

For example, when using plumbum.cli.SwitchAttr, you define it like this. Now that object contains some data that is important to autodocument it:

>>> from copier.cli import CopierApp
>>> CopierApp.answers_file._switch_info.names
['a', 'answers-file']
>>> CopierApp.answers_file._switch_info.help
'Update using this path (relative to `destination_path`) to find the answers file'

Describe the solution you'd like I'd like to be able to explain to pytkdocs that the docstring for SwitchAttr objects is different than just __doc__. Or, at least, that it needs to obtain additional attributes from them (_switch_info) which I could override in the mkdocstrings template.

Describe alternatives you've considered I tried to override the attributes template, but it didn't have the necessary context information to obtain the data I needed.

Additional context Since I'm documenting CLI flags/switches, a very important thing I need to document is the --switch itself. That's not easy to get from current provided info.

yajo avatar Aug 12 '20 12:08 yajo

Hey @Yajo, so sorry for having never answered to this :bow:

This won't happen in pytkdocs, but I'm working on a replacement. This tool replacing pytkdocs will parse the code instead of executing it. It will also make it easy to write extensions, to support third-party libraries such as plumbum. Taking your code example, it will be possible for an extension to visit the nodes corresponding to the assigned value (the cli.SwitchAttr instantiation) and set the docstring of the answers_file object using the value in the help parameter.

It's not ready yet, but I'm allocating time on it, so please be a bit more patient :pray: :sweat_smile:

pawamoy avatar Sep 17 '21 21:09 pawamoy

Yay cool! I'll be patient. 🤓🍿

yajo avatar Sep 18 '21 11:09 yajo