Skip to content

Commit

Permalink
More information in saga help files + stylesheet.
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@244 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com committed Jun 14, 2012
1 parent 506bcc0 commit 8b5a0c7
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
39 changes: 35 additions & 4 deletions src/sextante/saga/SagaHelpGenerator.py
Expand Up @@ -62,6 +62,29 @@ def __init__(self, params, i):
self.parameter = params.Get_Parameter(i)
self.name = self.parameter.Get_Name()
self.description = self.parameter.Get_Description()
self.typeName = self.parameter.Get_Type_Name()
if self.parameter.is_Output():
self.typeName = "Output " + self.typeName
if self.parameter.is_Input():
self.typeName = "Input " + self.typeName
typ = self.parameter.Get_Type()
self.minimum = None
self.maximum = None
if (typ == saga.PARAMETER_TYPE_Int) or \
(typ == saga.PARAMETER_TYPE_Double) or \
(typ == saga.PARAMETER_TYPE_Degree) or \
(typ == saga.PARAMETER_TYPE_Range):
parameterValue = self.parameter.asValue()
if parameterValue.has_Minimum():
self.minimum = parameterValue.Get_Minimum()
if parameterValue.has_Maximum():
self.maximum = parameterValue.Get_Maximum()
self.choices = None
if typ == saga.PARAMETER_TYPE_Choice:
parameterChoice = self.parameter.asChoice()
self.choices = [parameterChoice.Get_Item(i) for i in
range(parameterChoice.Get_Count())]


def getLibraryPaths(userPath = None):
try:
Expand Down Expand Up @@ -98,13 +121,21 @@ def writeHTML(path, mod):
docs += "<div class='author'>%s</div>\n" % mod.author
docs += "<div class='description'>%s</div>\n" % mod.description.replace('\n', '<br/>\n')
if mod.parameters():
docs += "<h2>Parameters:</h2>\n<dl class='parameters'>\n"
docs += "<h2>Parameters</h2>\n<dl class='parameters'>\n"
for p in mod.parameters():
docs += "\t<dt>%s</dt>" % p.name
docs += "<dd>%s</dd>\n" % p.description
constraints = list()
if p.minimum:
constraints.append("Minimum: " + str(p.minimum))
if p.maximum:
constraints.append("Maximum: " + str(p.maximum))
if p.choices:
constraints.append("Available choices: " + ', '.join(p.choices))

docs += "\t<dt>%s <div class='type'>%s</div></dt>" % (p.name, p.typeName)
docs += "<dd>%s <div class='constraints'>%s</div></dd>\n" % (p.description, '; '.join(constraints))
docs += "</dl>"
out = open(path, 'w')
out.write('<html><body>\n')
out.write('<html>\n<head><link rel="stylesheet" type="text/css" href="help.css" /></head>\n<body>\n')
out.write(docs.encode('utf-8'))
out.write('\n</body></html>\n')
out.close()
Expand Down
9 changes: 9 additions & 0 deletions src/sextante/saga/help/help.css
@@ -0,0 +1,9 @@
h1 { color: darkblue; font-size: 1.4em;}
h2 { color: darkblue; font-size: 1.2em; }
table { border: 1px solid darkblue; margin: 20px}
div.author { font-style: italic; font-size: small; }
div.description { text-indent:50px; text-align:justify; margin: 20px; }
dt { font-weight: bold; background-color: lightgrey; border-bottom: 1px solid grey; }
dd { font-style: normal; float: center; }
div.type { font-weight: normal; font-style: italic; float: right;}
div.constraints{ font-style: italic; }

0 comments on commit 8b5a0c7

Please sign in to comment.