--- a/eric6/DocumentationTools/ModuleDocumentor.py Sun Jan 17 13:53:08 2021 +0100 +++ b/eric6/DocumentationTools/ModuleDocumentor.py Mon Feb 01 10:38:16 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 = {} @@ -961,9 +970,17 @@ while dlist and not dlist[0]: del dlist[0] lastTag = "" + buffer = "" for ditem in dlist: ditem = self.__processInlineTags(ditem) desc = ditem.strip() + if buffer: + if desc.startswith("@"): + buffer = "" + raise TagError( + "Wrong format in {0} line.\n".format(lastTag)) + else: + desc = buffer + desc if desc: if desc.startswith(("@param", "@keyparam")): inTagSection = True @@ -1021,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] @@ -1030,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) @@ -1048,36 +1087,39 @@ lastTag = desc.split(None, 1)[0] m = _signal(desc, 0) if m is None: - raise TagError("Wrong format in @signal line.\n") - signalName = ( - 1 and m.group("SignalName1") or m.group("SignalName2") - ) - signalDesc = ( - 1 and m.group("SignalDescription1") or - m.group("SignalDescription2") - ) - signalDict[signalName] = [] - if signalDesc is not None: - signalDict[signalName].append(signalDesc) - lastItem = signalDict[signalName] + buffer = desc + else: + buffer = "" + signalName = ( + m.group("SignalName1") or m.group("SignalName2") + ) + signalDesc = ( + m.group("SignalDescription1") or + m.group("SignalDescription2") + ) + signalDict[signalName] = [] + if signalDesc is not None: + signalDict[signalName].append(signalDesc) + lastItem = signalDict[signalName] elif desc.startswith("@event"): inTagSection = True lastTag = desc.split(None, 1)[0] m = _event(desc, 0) if m is None: - raise TagError( - "Wrong format in {0} line.\n".format(parts[0])) - eventName = ( - 1 and m.group("EventName1") or m.group("EventName2") - ) - eventDesc = ( - 1 and m.group("EventDescription1") or - m.group("EventDescription2") - ) - eventDict[eventName] = [] - if eventDesc is not None: - eventDict[eventName].append(eventDesc) - lastItem = eventDict[eventName] + buffer = desc + else: + buffer = "" + eventName = ( + m.group("EventName1") or m.group("EventName2") + ) + eventDesc = ( + m.group("EventDescription1") or + m.group("EventDescription2") + ) + eventDict[eventName] = [] + if eventDesc is not None: + eventDict[eventName].append(eventDesc) + lastItem = eventDict[eventName] elif desc.startswith("@deprecated"): inTagSection = True parts = desc.split(None, 1) @@ -1149,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( @@ -1195,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): """