Skip to content

Commit 8b5a0c7

Browse files
author
cpolymeris@gmail.com
committed
More information in saga help files + stylesheet.
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@244 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent 506bcc0 commit 8b5a0c7

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

src/sextante/saga/SagaHelpGenerator.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,29 @@ def __init__(self, params, i):
6262
self.parameter = params.Get_Parameter(i)
6363
self.name = self.parameter.Get_Name()
6464
self.description = self.parameter.Get_Description()
65+
self.typeName = self.parameter.Get_Type_Name()
66+
if self.parameter.is_Output():
67+
self.typeName = "Output " + self.typeName
68+
if self.parameter.is_Input():
69+
self.typeName = "Input " + self.typeName
70+
typ = self.parameter.Get_Type()
71+
self.minimum = None
72+
self.maximum = None
73+
if (typ == saga.PARAMETER_TYPE_Int) or \
74+
(typ == saga.PARAMETER_TYPE_Double) or \
75+
(typ == saga.PARAMETER_TYPE_Degree) or \
76+
(typ == saga.PARAMETER_TYPE_Range):
77+
parameterValue = self.parameter.asValue()
78+
if parameterValue.has_Minimum():
79+
self.minimum = parameterValue.Get_Minimum()
80+
if parameterValue.has_Maximum():
81+
self.maximum = parameterValue.Get_Maximum()
82+
self.choices = None
83+
if typ == saga.PARAMETER_TYPE_Choice:
84+
parameterChoice = self.parameter.asChoice()
85+
self.choices = [parameterChoice.Get_Item(i) for i in
86+
range(parameterChoice.Get_Count())]
87+
6588

6689
def getLibraryPaths(userPath = None):
6790
try:
@@ -98,13 +121,21 @@ def writeHTML(path, mod):
98121
docs += "<div class='author'>%s</div>\n" % mod.author
99122
docs += "<div class='description'>%s</div>\n" % mod.description.replace('\n', '<br/>\n')
100123
if mod.parameters():
101-
docs += "<h2>Parameters:</h2>\n<dl class='parameters'>\n"
124+
docs += "<h2>Parameters</h2>\n<dl class='parameters'>\n"
102125
for p in mod.parameters():
103-
docs += "\t<dt>%s</dt>" % p.name
104-
docs += "<dd>%s</dd>\n" % p.description
126+
constraints = list()
127+
if p.minimum:
128+
constraints.append("Minimum: " + str(p.minimum))
129+
if p.maximum:
130+
constraints.append("Maximum: " + str(p.maximum))
131+
if p.choices:
132+
constraints.append("Available choices: " + ', '.join(p.choices))
133+
134+
docs += "\t<dt>%s <div class='type'>%s</div></dt>" % (p.name, p.typeName)
135+
docs += "<dd>%s <div class='constraints'>%s</div></dd>\n" % (p.description, '; '.join(constraints))
105136
docs += "</dl>"
106137
out = open(path, 'w')
107-
out.write('<html><body>\n')
138+
out.write('<html>\n<head><link rel="stylesheet" type="text/css" href="help.css" /></head>\n<body>\n')
108139
out.write(docs.encode('utf-8'))
109140
out.write('\n</body></html>\n')
110141
out.close()

src/sextante/saga/help/help.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
h1 { color: darkblue; font-size: 1.4em;}
2+
h2 { color: darkblue; font-size: 1.2em; }
3+
table { border: 1px solid darkblue; margin: 20px}
4+
div.author { font-style: italic; font-size: small; }
5+
div.description { text-indent:50px; text-align:justify; margin: 20px; }
6+
dt { font-weight: bold; background-color: lightgrey; border-bottom: 1px solid grey; }
7+
dd { font-style: normal; float: center; }
8+
div.type { font-weight: normal; font-style: italic; float: right;}
9+
div.constraints{ font-style: italic; }

0 commit comments

Comments
 (0)