PyCharm and reStructuredText (Sphinx) documentatio

2019-07-19 15:56发布

Let's imagine, I want to see a docstring popup for one simple method in PyCharm 4.5 Community Edition (tried also in 5.0).

I wrote down these docstrings in both epytext syntax (Epydoc generator is unsupported since 2008 and works only for Python2) and reStructuredText syntax (which is used by Sphinx - actively supported generator, used for offical python docs)

The epytext one works in PyCharm documentation popups perfectly

PyCharm works with epytext Screenshot

But the reStructuredText one doesn't show any parameters at all!

PyCharm fails with reStructuredText Screenshot

Trying to handle this with PyCharm settings, reading the PyCharm helps, searching through the PyCharm bugtracker and using Google couldn't help me to find the reason why these docstring popups in PyCharm don't work correctly with community-recommended docstring markup language.

Is this because of low demand of the feature? Perhaps, is there some useful alternatives to view the modern documentation markup inside PyCharm or even another IDE? I also need to be able to generate HTML pretty formatted docpages.

I've found another topic here, related to the same issue, but it is still unanswered since previous year. So, I'm guessing what's wrong with my desires to view modern documentation inside modern IDE.

Here are my code examples

def find_links(self, issue, link_type):
    """

    Find all issues linked with C{issue} with C{link_type}.

    @param issue: Issue key
    @type issue: str
    @param link_type: Accepts either Type Name (like 'Child') or Link Description (like 'child of')
    @type link_type: str
    @return: Keys of found issues
    @rtype: list

    """
    result_keys = []
    link_list = self.get_link_list(issue)
    for link in link_list:
        ... # omitted
    return result_keys

def test_sphinx_docs_method(self, issue, link_type):
    """

    Find all issues linked with *issue* with *link_type*.

    :param issue: Issue key
    :type issue: str
    :param link_type: Accepts either Type Name (like 'Child') or Link Description (like 'child of')
    :type link_type: str
    :return: Keys of found issues
    :rtype: list

    """
    result_keys = []
    link_list = self.get_link_list(issue)
    for link in link_list:
        ... # omitted
    return result_keys

1条回答
成全新的幸福
2楼-- · 2019-07-19 16:25

I do not know if this feature present only in recent PyCharm versions so what version do you have? In my PyCharm CE 2016.2.2 it looks like on the screenshot.

enter image description here

Check Preferences > Editor > General > Code Completion, to be sure option "Autopop documentation" is enabled.

Good luck!

查看更多
登录 后发表回答