eric6/QScintilla/DocstringGenerator/__init__.py

Fri, 22 Jan 2021 16:48:43 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 22 Jan 2021 16:48:43 +0100
changeset 7998
cd41c844862f
permissions
-rw-r--r--

Editor
- added functionality to insert docstring templates via the context menu (cursor placed on first line of function definition) or after entering the docstring start string (e.g. """ for Python)

# -*- coding: utf-8 -*-

# Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Package containing the documentation string generator tool.
"""

from PyQt5.QtCore import QCoreApplication


def getDocstringGenerator(editor):
    """
    Function to get a docstring generator for the given editor.
    
    @param editor reference to the editor to create a docstring generator for
    @type Editor
    @return reference to the created docstring generator
    @rtype BaseDocstringGenerator
    """
    if (
        editor.isPyFile() or
        editor.getFileType() in ("Python", "Python3", "MicroPython")
    ):
        from .PyDocstringGenerator import PyDocstringGenerator
        return PyDocstringGenerator(editor)
    else:
        from .BaseDocstringGenerator import BaseDocstringGenerator
        return BaseDocstringGenerator(editor)


def getSupportedDocstringTypes():
    """
    Function to get the supported docstring types/styles.
    
    @return list of tuples with supported docstring type/style and the
        corresponding display string
    @rtype tuple of (str, str)
    """
    return [
        ("ericdoc",
         QCoreApplication.translate("DocstringGenerator", "Eric")),
        ("numpydoc",
         QCoreApplication.translate("DocstringGenerator", "NumPy")),
        ("googledoc",
         QCoreApplication.translate("DocstringGenerator", "Google")),
        ("sphinxdoc",
         QCoreApplication.translate("DocstringGenerator", "Sphinx")),
    ]

eric ide

mercurial