Skip to content

Commit fc6ad27

Browse files
committedDec 7, 2014
[processing] load documentation from online QGIS User Guide
1 parent a6fcb3a commit fc6ad27

File tree

3 files changed

+39
-16
lines changed

3 files changed

+39
-16
lines changed
 

‎python/plugins/processing/core/GeoAlgorithm.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,48 @@ def getDefaultIcon():
107107

108108
def help(self):
109109
"""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.
114115
115116
Returns None if there is no help file available.
116117
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.
120120
"""
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
128121

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
129152

130153
def processAlgorithm(self):
131154
"""Here goes the algorithm itself.

‎python/plugins/processing/core/outputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def __init__(self, name='', description='', hidden=False):
6060
self.open = True
6161

6262
def __str__(self):
63-
return self.name + ' <' + self.__class__.__name__ + '>'
63+
return u'{} <{}>'.format(self.name, self.__class__.__name__)
6464

6565
def getValueAsCommandLineParameter(self):
6666
if self.value is None:

‎python/plugins/processing/core/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def setValue(self, obj):
7575
return True
7676

7777
def __str__(self):
78-
return self.name + ' <' + self.__module__.split('.')[-1] + '>'
78+
return u'{} <{}>'.format(self.name, self.__class__.__name__)
7979

8080
def getValueAsCommandLineParameter(self):
8181
"""

0 commit comments

Comments
 (0)
Please sign in to comment.