diff -r d89cd224dd1b -r d0de2b378b24 UI/CodeDocumentationViewerTemplate.py --- a/UI/CodeDocumentationViewerTemplate.py Sat Oct 21 15:13:56 2017 +0200 +++ b/UI/CodeDocumentationViewerTemplate.py Sat Oct 21 15:18:15 2017 +0200 @@ -9,6 +9,11 @@ from __future__ import unicode_literals +from PyQt5.QtCore import QCoreApplication + +import Utilities + + def prepareDocumentationViewerHtmlDocument(documentationInfo): """ Public function to prepare the HTML document. @@ -69,9 +74,15 @@ 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@", documentationInfo["argspec"]) + .replace("@ARGSPEC@", argspec) else: argspec = "" if documentationInfo["note"]: @@ -98,13 +109,18 @@ .replace("\r", "<br/>") docstring = docstringTemplate.replace("@DOCSTRING@", docstring) else: - docstring = "" + docstring = \ + """<div class="hr"></div><div id="doc-warning">{0}</div>"""\ + .format(QCoreApplication.translate( + "CodeDocumentationViewer", + "No further documentation available")) return mainTemplate\ .replace("@HEADER@", header)\ .replace("@DOCSTRING@", docstring) -def prepareDocumentationViewerHtmlWarningDocument(text): + +def prepareDocumentationViewerHtmlDocWarningDocument(text): """ Public function to prepare a HTML warning document. @@ -128,3 +144,29 @@ """ return mainTemplate.replace("@TEXT@", text) + + +def prepareDocumentationViewerHtmlWarningDocument(text): + """ + Public function to prepare a HTML warning document. + + @param text warning text to be shown + @type str + @return prepared HTML document + @rtype str + """ + mainTemplate = """ + <!DOCTYPE html> + <html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <link rel="stylesheet" href="qrc:documentViewerStyle.css" + type="text/css" /> + </head> + <body> + <div id="warning">@TEXT@</div> + </body> + </html> + """ + + return mainTemplate.replace("@TEXT@", text)