Skip to content

Commit d8dfdd2

Browse files
committed
[processing] rst files are now the default for help files
1 parent 2073026 commit d8dfdd2

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

python/plugins/processing/core/GeoAlgorithm.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28+
import inspect
2829
import os.path
2930
import traceback
3031
import copy
3132
from PyQt4 import QtGui
3233
from PyQt4.QtCore import *
3334
from qgis.core import *
3435

36+
from processing.gui.Help2Html import getHtmlFromRstFile
3537
from processing.core.ProcessingLog import ProcessingLog
3638
from processing.core.ProcessingConfig import ProcessingConfig
3739
from processing.core.GeoAlgorithmExecutionException import \
@@ -112,11 +114,25 @@ def help(self):
112114
"""Returns the help with the description of this algorithm.
113115
It returns a tuple boolean, string. IF the boolean value is true, it means that
114116
the string contains the actual description. If false, it is an url or path to a file
115-
where the description is stored
117+
where the description is stored.
116118
117119
Returns None if there is no help file available.
120+
121+
The default implementation looks for an rst file in a help folder under the folder
122+
where the algorithm is located.
123+
The name of the file is the name console name of the algorithm, without the namespace part
118124
"""
119-
return False, None
125+
name = self.commandLineName().split(':')[1].lower()
126+
filename = os.path.join(os.path.dirname(inspect.getfile(self.__class__)), 'help', name + '.rst')
127+
print filename
128+
try:
129+
html = getHtmlFromRstFile(filename)
130+
print html
131+
return True, html
132+
except:
133+
print "error"
134+
return False, None
135+
120136

121137
def processAlgorithm(self):
122138
"""Here goes the algorithm itself.

python/plugins/processing/gui/Help2Html.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
def getHtmlFromRstFile(rst):
4747
if not os.path.exists(rst):
48-
return ''
48+
return None
4949
with open(rst) as f:
5050
lines = f.readlines()
5151
s = "".join(lines)

0 commit comments

Comments
 (0)