--- a/UI/CodeDocumentationViewerTemplate.py Sun Nov 05 13:24:07 2017 +0100 +++ b/UI/CodeDocumentationViewerTemplate.py Sun Nov 05 17:16:40 2017 +0100 @@ -51,6 +51,7 @@ metadataTemplate = """ <div class="metadata"> @ARGSPEC@ + @TYPE@ @NOTE@ </div> """ @@ -60,6 +61,11 @@ '<p><b>Definition:</b> <span class="def">@NAME@@ARGSPEC@</span></p>', "Just translate 'Definition:' and leave the rest intact.") + typeTemplate = QCoreApplication.translate( + "CodeDocumentationViewer", + "<p><b>Type:</b> @TYPE@</p>", + "Just translate 'Type:' and leave the rest intact.") + noteTemplate = QCoreApplication.translate( "CodeDocumentationViewer", "<p><b>Note:</b> @NOTE@</p>", @@ -74,31 +80,37 @@ name = documentationInfo["name"] if name: title = titleTemplate.replace("@NAME@", name) - if documentationInfo["argspec"] or documentationInfo["note"]: - if documentationInfo["argspec"]: - argspec = Utilities.html_encode(documentationInfo["argspec"]) - for char in ['=', ',', '(', ')', '*', '**']: - argspec = argspec.replace( - char, - '<span class="argspec-highlight">{0}</span>'.format( - char)) - argspec = argspecTemplate\ - .replace("@NAME@", name)\ - .replace("@ARGSPEC@", argspec) - else: - argspec = argspecTemplate\ - .replace("@NAME@", name)\ - .replace("@ARGSPEC@", "") - if documentationInfo["note"]: - note = noteTemplate.replace("@NOTE@", - documentationInfo["note"]) - else: - note = "" - metaData = metadataTemplate\ - .replace("@ARGSPEC@", argspec)\ - .replace("@NOTE@", note) + if "argspec" in documentationInfo and documentationInfo["argspec"]: + argspec = Utilities.html_encode(documentationInfo["argspec"]) + for char in ['=', ',', '(', ')', '*', '**']: + argspec = argspec.replace( + char, + '<span class="argspec-highlight">{0}</span>'.format( + char)) + argspec = argspecTemplate\ + .replace("@NAME@", name)\ + .replace("@ARGSPEC@", argspec) else: - metaData = "" + argspec = argspecTemplate\ + .replace("@NAME@", name)\ + .replace("@ARGSPEC@", "") + + if "typ" in documentationInfo and documentationInfo["typ"]: + typeInfo = typeTemplate.replace("@TYPE@", + documentationInfo["typ"]) + else: + typeInfo = "" + + if "note" in documentationInfo and documentationInfo["note"]: + note = noteTemplate.replace("@NOTE@", + documentationInfo["note"]) + else: + note = "" + + metaData = metadataTemplate\ + .replace("@ARGSPEC@", argspec)\ + .replace("@TYPE@", typeInfo)\ + .replace("@NOTE@", note) header = headerTemplate\ .replace("@TITLE@", title)\ @@ -106,7 +118,7 @@ else: header = "" - if documentationInfo["docstring"]: + if "docstring" in documentationInfo and documentationInfo["docstring"]: docstring = documentationInfo["docstring"]\ .replace("\r\n", "<br/>")\ .replace("\n", "<br/>")\