PyCharm View Own Docstring

Posted on
Fri Sep 01, 2017 4:17 pm
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

PyCharm View Own Docstring

Talk about your niche issues...

In PyCharm, you can put the cursor at the start of a method call and select F1 to view the appropriate documentation. As far as I can tell, when I'm working on a docstring for my own methods I can't view the restructured text version within the code window. So what I do is create a new (temporary) python file and add an import of the file I want to view (does that make sense?)

foo.py
Code: Select all
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

import plugin

Then I can view my documentation.

Does anyone know if it's possible to view docstrings within the source's project window? I can't find one.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Sep 02, 2017 10:24 am
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

Re: PyCharm View Own Docstring

LOL - I didn't even know you could do that (it's a handy feature if I remember to use it). I normally just cmd-click the method name and it opens the file with the method in it.

As for your problem, I'm not really following.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat Sep 02, 2017 11:13 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PyCharm View Own Docstring

jay (support) wrote:
LOL - I didn't even know you could do that (it's a handy feature if I remember to use it). I normally just cmd-click the method name and it opens the file with the method in it.

As for your problem, I'm not really following.

Yeah, I could've been more clear. Within the docstring you can use RestructuredText for formatting (to make it look more like a man page, for example).

Code: Select all
    def channelListGenerator(self, filter="", valuesDict=None, typeId="", targetId=0):
        """ The channelListGenerator() method generates a list of channel names
        and IDs which are used to identify the target channel.

        :**url**: "/channels.json"
        :**parms**: {'api_key': self.pluginPrefs.get('apiKey', '')}
        :**return**: [(channel_id, channel_name), (channel_id, channel_name)] """

        self.debugLog(u'channelListGenerator() called.')

        url   = "/channels.json"
        parms = {'api_key': self.pluginPrefs.get('apiKey', '')}

        response, response_dict = self.sendToThingspeak('get', url, parms)

        return [(thing['id'], thing['name']) for thing in response_dict]


foo.py
Code: Select all
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-

import plugin

plugin.Plugin.channelListGenerator()

Then I put my cursor on 'channelListGenerator()', hit F1, and I get this constructed view of the docstring (simple example):
Screen Shot 2017-09-02 at 12.07.45 PM.png
Screen Shot 2017-09-02 at 12.07.45 PM.png (78.05 KiB) Viewed 1362 times


What I was wondering was whether you could get the same view directly when viewing plugin.py (as a corollary, if you have a markdown file called foo.md, PyCharm will show a viewer allowing you to see the markdown as you create it.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Sep 02, 2017 7:43 pm
jay (support) offline
Site Admin
User avatar
Posts: 18216
Joined: Mar 19, 2008
Location: Austin, Texas

Re: PyCharm View Own Docstring

I'm guessing because of how we manipulate the python interpreter via the IPH process. Someday when we make indigo a real python module I suspect this (and many other) issue will go away. Someday...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Sep 03, 2017 4:43 am
DaveL17 offline
User avatar
Posts: 6753
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: PyCharm View Own Docstring

Thanks Jay - it's a low order thing for sure!

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests