Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Fixes #11363 - help file is created but not shown in the…
… Help tab
  • Loading branch information
slarosa committed Oct 8, 2014
1 parent c768f13 commit bb72302
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions python/plugins/processing/gui/Help2Html.py
Expand Up @@ -26,6 +26,7 @@

__revision__ = '$Format:%H$'

from PyQt4.QtCore import QCoreApplication
import os
import re
import json
Expand All @@ -42,7 +43,6 @@
(r"::(\s*\n(\s*\n)*((\s+).*?\n)(((\4).*?\n)|(\s*\n))*)",r"<pre>\1</pre>"),
("\n+", "</p><p>")]


def getHtmlFromRstFile(rst):
if not os.path.exists(rst):
return None
Expand All @@ -54,20 +54,17 @@ def getHtmlFromRstFile(rst):
s = p.sub(replace, s)
return s


def getHtmlFromHelpFile(alg, helpFile):
if not os.path.exists(helpFile):
return None
try:
with open(helpFile) as f:
descriptions = json.load(f)
return getHtmlFromDescriptionsDict(descriptions)
return getHtmlFromDescriptionsDict(alg, descriptions)
except:
return None


def getHtmlFromDescriptionsDict(alg, descriptions):

s = tr('<html><body><h2>Algorithm description</h2>\n')
s += '<p>' + getDescription(ALG_DESC, descriptions) + '</p>\n'
s += tr('<h2>Input parameters</h2>\n')
Expand All @@ -80,17 +77,16 @@ def getHtmlFromDescriptionsDict(alg, descriptions):
s += '<p>' + getDescription(out.name, descriptions) + '</p>\n'
s += '<br>'
s += tr('<p align="right">Algorithm author: %s</p>') % getDescription(ALG_CREATOR, descriptions)
s += tr('<p align="right">Help author: %s</p>') + getDescription(ALG_HELP_CREATOR, descriptions)
s += tr('<p align="right">Algorithm version: %s</p>') + getDescription(ALG_VERSION, descriptions)
s += tr('<p align="right">Help author: %s</p>') % getDescription(ALG_HELP_CREATOR, descriptions)
s += tr('<p align="right">Algorithm version: %s</p>') % getDescription(ALG_VERSION, descriptions)
s += '</body></html>'
return s


def getDescription(name, descriptions):
if name in descriptions:
return unicode(descriptions[name]).replace("\n", "<br>")
else:
return ''

def tr(string):
return QtCore.QCoreApplication.translate('Help2Html', string)
return QCoreApplication.translate('Help2Html', string)

0 comments on commit bb72302

Please sign in to comment.