File tree 2 files changed +19
-3
lines changed
python/plugins/processing
2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 25
25
26
26
__revision__ = '$Format:%H$'
27
27
28
+ import inspect
28
29
import os .path
29
30
import traceback
30
31
import copy
31
32
from PyQt4 import QtGui
32
33
from PyQt4 .QtCore import *
33
34
from qgis .core import *
34
35
36
+ from processing .gui .Help2Html import getHtmlFromRstFile
35
37
from processing .core .ProcessingLog import ProcessingLog
36
38
from processing .core .ProcessingConfig import ProcessingConfig
37
39
from processing .core .GeoAlgorithmExecutionException import \
@@ -112,11 +114,25 @@ def help(self):
112
114
"""Returns the help with the description of this algorithm.
113
115
It returns a tuple boolean, string. IF the boolean value is true, it means that
114
116
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.
116
118
117
119
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
118
124
"""
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
+
120
136
121
137
def processAlgorithm (self ):
122
138
"""Here goes the algorithm itself.
Original file line number Diff line number Diff line change 45
45
46
46
def getHtmlFromRstFile (rst ):
47
47
if not os .path .exists (rst ):
48
- return ''
48
+ return None
49
49
with open (rst ) as f :
50
50
lines = f .readlines ()
51
51
s = "" .join (lines )
You can’t perform that action at this time.
0 commit comments