src/eric7/QScintilla/DocstringGenerator/BaseDocstringGenerator.py

branch
eric7
changeset 9486
5a8179763e38
parent 9482
a2bc06a54d9d
child 9497
8beca4047c53
equal deleted inserted replaced
9485:0f3620304d7a 9486:5a8179763e38
5 5
6 """ 6 """
7 Module implementing a docstring generator base class. 7 Module implementing a docstring generator base class.
8 """ 8 """
9 9
10 import importlib
10 import re 11 import re
11 12
12 from PyQt6.QtCore import Qt 13 from PyQt6.QtCore import Qt
13 from PyQt6.QtWidgets import QMenu 14 from PyQt6.QtWidgets import QMenu
14 15
139 @type FunctionInfo 140 @type FunctionInfo
140 @param docstringType kind of docstring to be generated 141 @param docstringType kind of docstring to be generated
141 @return list of docstring lines 142 @return list of docstring lines
142 @rtype str 143 @rtype str
143 """ 144 """
144 if docstringType == "ericdoc": 145 generatorModuleMapping = {
145 from .EricdocGenerator import generateEricDoc # __IGNORE_WARNING_I101__ 146 "ericdoc": "EricdocGenerator",
146 147 "numpydoc": "NumpydocGenerator",
147 return generateEricDoc(functionInfo) 148 "goodledoc": "GoogledocGenerator",
148 elif docstringType == "numpydoc": 149 "sphinxdoc": "SphinxdocGenerator",
149 from .NumpydocGenerator import generateNumpyDoc # __IGNORE_WARNING_I101__ 150 }
150 151 if docstringType in generatorModuleMapping:
151 return generateNumpyDoc(functionInfo) 152 mod = importlib.import_module(
152 elif docstringType == "googledoc": 153 "eric7.QScintilla.DocstringGenerator.{0}".format(
153 from .GoogledocGenerator import generateGoogleDoc # __IGNORE_WARNING_I101__ 154 generatorModuleMapping[docstringType]
154 155 )
155 return generateGoogleDoc(functionInfo, self.editor) 156 )
156 elif docstringType == "sphinxdoc": 157 return mod.generateDoc(functionInfo, self.editor)
157 from .SphinxdocGenerator import generateSphinxDoc # __IGNORE_WARNING_I101__ 158
158 159 return []
159 return generateSphinxDoc(functionInfo)
160 else:
161 return []
162 160
163 161
164 class FunctionInfo: 162 class FunctionInfo:
165 """ 163 """
166 Class implementing an object to store function information. 164 Class implementing an object to store function information.

eric ide

mercurial