--- a/eric6/DocumentationTools/ModuleDocumentor.py Fri Jan 15 19:49:36 2021 +0100 +++ b/eric6/DocumentationTools/ModuleDocumentor.py Sat Jan 16 16:32:01 2021 +0100 @@ -105,6 +105,9 @@ self.returnsTemplate = TemplatesListsStyleCSS.returnsTemplate self.returnTypesTemplate = ( TemplatesListsStyleCSS.returnTypesTemplate) + self.yieldsTemplate = TemplatesListsStyleCSS.yieldsTemplate + self.yieldTypesTemplate = ( + TemplatesListsStyleCSS.yieldTypesTemplate) self.exceptionsListTemplate = ( TemplatesListsStyleCSS.exceptionsListTemplate) self.exceptionsListEntryTemplate = ( @@ -170,6 +173,10 @@ TemplatesListsStyle.returnsTemplate.format(**colors)) self.returnTypesTemplate = ( TemplatesListsStyle.returnTypesTemplate.format(**colors)) + self.yieldsTemplate = ( + TemplatesListsStyle.yieldsTemplate.format(**colors)) + self.yieldTypesTemplate = ( + TemplatesListsStyle.yieldTypesTemplate.format(**colors)) self.exceptionsListTemplate = ( TemplatesListsStyle.exceptionsListTemplate.format(**colors)) self.exceptionsListEntryTemplate = ( @@ -938,7 +945,7 @@ @param descr The contents of the documentation string. (string) @exception TagError A tag doesn't have the correct number of arguments. - @return The formated contents of the documentation string. (string) + @return The formatted contents of the documentation string. (string) """ if not descr: return "" @@ -947,6 +954,8 @@ paramList = [] returns = [] returnTypes = [] + yields = [] + yieldTypes = [] exceptionDict = {} signalDict = {} eventDict = {} @@ -1029,7 +1038,7 @@ parts = desc.split(None, 1) if lastTag not in ["@return", "@ireturn"]: raise TagError( - "{0} line must be preceded by a return line\n" + "{0} line must be preceded by a @return line\n" .format(parts[0])) inTagSection = True lastTag = parts[0] @@ -1038,6 +1047,28 @@ "Wrong format in {0} line.\n".format(parts[0])) returnTypes = [parts[1]] lastItem = returnTypes + elif desc.startswith("@yield"): + inTagSection = True + parts = desc.split(None, 1) + lastTag = parts[0] + if len(parts) < 2: + raise TagError( + "Wrong format in {0} line.\n".format(parts[0])) + yields = [parts[1]] + lastItem = yields + elif desc.startswith("@ytype"): + parts = desc.split(None, 1) + if lastTag != "@yield": + raise TagError( + "{0} line must be preceded by a @yield line\n" + .format(parts[0])) + inTagSection = True + lastTag = parts[0] + if len(parts) < 2: + raise TagError( + "Wrong format in {0} line.\n".format(parts[0])) + yieldTypes = [parts[1]] + lastItem = yieldTypes elif desc.startswith(("@exception", "@throws", "@raise")): inTagSection = True parts = desc.split(None, 2) @@ -1160,6 +1191,18 @@ else: returnTypesSect = "" + if yields: + yieldSect = self.yieldsTemplate.format( + html_uencode('\n'.join(yields))) + else: + yieldSect = "" + + if yieldTypes: + yieldTypesSect = self.yieldTypesTemplate.format( + html_uencode('\n'.join(yieldTypes))) + else: + yieldTypesSect = "" + if exceptionDict: exceptionSect = self.exceptionsListTemplate.format( **{'Exceptions': self.__genDescriptionListSection( @@ -1206,11 +1249,11 @@ else: seeSect = '' - return "{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( + return "".join([ deprecatedSect, description, parameterSect, returnSect, - returnTypesSect, exceptionSect, signalSect, eventSect, - authorInfoSect, seeSect, sinceInfoSect, - ) + returnTypesSect, yieldSect, yieldTypesSect, exceptionSect, + signalSect, eventSect, authorInfoSect, seeSect, sinceInfoSect, + ]) def getQtHelpKeywords(self): """