Skip to content

Commit

Permalink
[processing] rst files are now the default for help files
Browse files Browse the repository at this point in the history
  • Loading branch information
volaya committed Jun 8, 2014
1 parent 2073026 commit d8dfdd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions python/plugins/processing/core/GeoAlgorithm.py
Expand Up @@ -25,13 +25,15 @@

__revision__ = '$Format:%H$'

import inspect
import os.path
import traceback
import copy
from PyQt4 import QtGui
from PyQt4.QtCore import *
from qgis.core import *

from processing.gui.Help2Html import getHtmlFromRstFile
from processing.core.ProcessingLog import ProcessingLog
from processing.core.ProcessingConfig import ProcessingConfig
from processing.core.GeoAlgorithmExecutionException import \
Expand Down Expand Up @@ -112,11 +114,25 @@ 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
where the description is stored.
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
"""
return False, None
name = self.commandLineName().split(':')[1].lower()
filename = os.path.join(os.path.dirname(inspect.getfile(self.__class__)), 'help', name + '.rst')
print filename
try:
html = getHtmlFromRstFile(filename)
print html
return True, html
except:
print "error"
return False, None


def processAlgorithm(self):
"""Here goes the algorithm itself.
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/processing/gui/Help2Html.py
Expand Up @@ -45,7 +45,7 @@

def getHtmlFromRstFile(rst):
if not os.path.exists(rst):
return ''
return None
with open(rst) as f:
lines = f.readlines()
s = "".join(lines)
Expand Down

0 comments on commit d8dfdd2

Please sign in to comment.