Skip to content
Permalink
Browse files

[processing] load documentation from online QGIS User Guide

  • Loading branch information
alexbruy committed Dec 7, 2014
1 parent a6fcb3a commit fc6ad27db8be82a5984f3430e1a9724a1bc60d42
@@ -107,25 +107,48 @@ def getDefaultIcon():

def help(self):
"""Returns the help with the description of this algorithm.
It returns a tuple boolean, string. IF the boolean value is true, it means that
the string contains the actual description. If false, it is an url or path to a file
where the description is stored. In both cases, the string or the content of the file
have to be HTML, ready to be set into the help display component.
It returns a tuple boolean, string. IF the boolean value is True,
it means that the string contains the actual description. If False,
it is an url or path to a file where the description is stored.
In both cases, the string or the content of the file have to be HTML,
ready to be set into the help display component.
Returns None if there is no help file available.
The default implementation looks for an rst file in a help folder under the folder
where the algorithm is located.
The name of the file is the name console name of the algorithm, without the namespace part
The default implementation looks for an HTML page in the QGIS
documentation site taking into account QGIS version.
"""
name = self.commandLineName().split(':')[1].lower()
filename = os.path.join(os.path.dirname(inspect.getfile(self.__class__)), 'help', name + '.rst')
try:
html = getHtmlFromRstFile(filename)
return True, html
except:
return False, None

qgsVersion = QGis.QGIS_VERSION_INT
major = qgsVersion / 10000
minor = minor = (qgsVersion - major * 10000) / 100
if minor % 2 == 1:
qgsVersion = 'testing'
else:
qgsVersion = '{}.{}'.format(major, minor)

providerName = self.provider.getName().lower()
groupName = self.group.lower()
groupName = groupName.replace('[', '').replace(']', '').replace(' - ', '_')
groupName = groupName.replace(' ', '_')
cmdLineName = self.commandLineName()
algName = cmdLineName[cmdLineName.find(':') + 1:].lower()
validChars = \
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'
safeGroupName = ''.join(c for c in groupName if c in validChars)
safeAlgName = ''.join(c for c in algName if c in validChars)

helpUrl = 'http://docs.qgis.org/{}/en/docs/user_manual/processing_algs/{}/{}/{}.html'.format(qgsVersion, providerName, safeGroupName, safeAlgName)
print 'HELP', helpUrl
return False, helpUrl

#name = self.commandLineName().split(':')[1].lower()
#filename = os.path.join(os.path.dirname(inspect.getfile(self.__class__)), 'help', name + '.rst')
#try:
#html = getHtmlFromRstFile(filename)
#return True, html
#except:
#return False, None

def processAlgorithm(self):
"""Here goes the algorithm itself.
@@ -60,7 +60,7 @@ def __init__(self, name='', description='', hidden=False):
self.open = True

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

def getValueAsCommandLineParameter(self):
if self.value is None:
@@ -75,7 +75,7 @@ def setValue(self, obj):
return True

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

def getValueAsCommandLineParameter(self):
"""

0 comments on commit fc6ad27

Please sign in to comment.
You can’t perform that action at this time.