src/eric7/QScintilla/DocstringGenerator/BaseDocstringGenerator.py

branch
eric7
changeset 10431
64157aeb0312
parent 10078
9ebe2183cf49
child 10439
21c28b0f9e41
equal deleted inserted replaced
10430:e440aaf179ce 10431:64157aeb0312
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 contextlib
10 import importlib 11 import importlib
11 import re 12 import re
12 13
13 from PyQt6.QtCore import Qt 14 from PyQt6.QtCore import Qt
14 from PyQt6.QtWidgets import QMenu 15 from PyQt6.QtWidgets import QMenu
137 extracted function information. 138 extracted function information.
138 139
139 @param functionInfo reference to the function info object 140 @param functionInfo reference to the function info object
140 @type FunctionInfo 141 @type FunctionInfo
141 @param docstringType kind of docstring to be generated 142 @param docstringType kind of docstring to be generated
143 @type str
142 @return list of docstring lines 144 @return list of docstring lines
143 @rtype str 145 @rtype str
144 """ 146 """
145 generatorModuleMapping = { 147 generatorModuleMapping = {
146 "ericdoc": ".EricdocGenerator", 148 "ericdoc": ".EricdocGenerator",
147 "numpydoc": ".NumpydocGenerator", 149 "numpydoc": ".NumpydocGenerator",
148 "goodledoc": ".GoogledocGenerator", 150 "goodledoc": ".GoogledocGenerator",
149 "sphinxdoc": ".SphinxdocGenerator", 151 "sphinxdoc": ".SphinxdocGenerator",
150 } 152 }
151 if docstringType in generatorModuleMapping: 153 with contextlib.suppress(KeyError):
152 mod = importlib.import_module( 154 mod = importlib.import_module(
153 generatorModuleMapping[docstringType], __package__ 155 generatorModuleMapping[docstringType], __package__
154 ) 156 )
155 return mod.generateDoc(functionInfo, self.editor) 157 return mod.generateDoc(functionInfo, self.editor)
156 158

eric ide

mercurial