@@ -107,25 +107,48 @@ def getDefaultIcon():
107
107
108
108
def help (self ):
109
109
"""Returns the help with the description of this algorithm.
110
- It returns a tuple boolean, string. IF the boolean value is true, it means that
111
- the string contains the actual description. If false, it is an url or path to a file
112
- where the description is stored. In both cases, the string or the content of the file
113
- have to be HTML, ready to be set into the help display component.
110
+ It returns a tuple boolean, string. IF the boolean value is True,
111
+ it means that the string contains the actual description. If False,
112
+ it is an url or path to a file where the description is stored.
113
+ In both cases, the string or the content of the file have to be HTML,
114
+ ready to be set into the help display component.
114
115
115
116
Returns None if there is no help file available.
116
117
117
- The default implementation looks for an rst file in a help folder under the folder
118
- where the algorithm is located.
119
- The name of the file is the name console name of the algorithm, without the namespace part
118
+ The default implementation looks for an HTML page in the QGIS
119
+ documentation site taking into account QGIS version.
120
120
"""
121
- name = self .commandLineName ().split (':' )[1 ].lower ()
122
- filename = os .path .join (os .path .dirname (inspect .getfile (self .__class__ )), 'help' , name + '.rst' )
123
- try :
124
- html = getHtmlFromRstFile (filename )
125
- return True , html
126
- except :
127
- return False , None
128
121
122
+ qgsVersion = QGis .QGIS_VERSION_INT
123
+ major = qgsVersion / 10000
124
+ minor = minor = (qgsVersion - major * 10000 ) / 100
125
+ if minor % 2 == 1 :
126
+ qgsVersion = 'testing'
127
+ else :
128
+ qgsVersion = '{}.{}' .format (major , minor )
129
+
130
+ providerName = self .provider .getName ().lower ()
131
+ groupName = self .group .lower ()
132
+ groupName = groupName .replace ('[' , '' ).replace (']' , '' ).replace (' - ' , '_' )
133
+ groupName = groupName .replace (' ' , '_' )
134
+ cmdLineName = self .commandLineName ()
135
+ algName = cmdLineName [cmdLineName .find (':' ) + 1 :].lower ()
136
+ validChars = \
137
+ 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
138
+ safeGroupName = '' .join (c for c in groupName if c in validChars )
139
+ safeAlgName = '' .join (c for c in algName if c in validChars )
140
+
141
+ helpUrl = 'http://docs.qgis.org/{}/en/docs/user_manual/processing_algs/{}/{}/{}.html' .format (qgsVersion , providerName , safeGroupName , safeAlgName )
142
+ print 'HELP' , helpUrl
143
+ return False , helpUrl
144
+
145
+ #name = self.commandLineName().split(':')[1].lower()
146
+ #filename = os.path.join(os.path.dirname(inspect.getfile(self.__class__)), 'help', name + '.rst')
147
+ #try:
148
+ #html = getHtmlFromRstFile(filename)
149
+ #return True, html
150
+ #except:
151
+ #return False, None
129
152
130
153
def processAlgorithm (self ):
131
154
"""Here goes the algorithm itself.
0 commit comments