@@ -43,6 +43,18 @@ def special(values, feature, parent):
43
43
def sqrt (values , feature , parent ):
44
44
pass
45
45
46
+ @qgsfunction (1 , 'testing' , register = False )
47
+ def help_with_docstring (values , feature , parent ):
48
+ """The help comes from the python docstring."""
49
+ pass
50
+
51
+ help_text = 'The help comes from a variable.'
52
+
53
+ @qgsfunction (1 , 'testing' , register = False , helpText = help_text )
54
+ def help_with_variable (values , feature , parent ):
55
+ """This docstring is not used for the help."""
56
+ pass
57
+
46
58
@qgsfunction (1 , 'testing' , register = False , usesgeometry = True )
47
59
def geomtest (values , feature , parent ):
48
60
pass
@@ -68,6 +80,17 @@ def testAutoCountsCorrectArgs(self):
68
80
args = function .params ()
69
81
self .assertEqual (args , 3 )
70
82
83
+ def testHelp (self ):
84
+ QgsExpression .registerFunction (self .help_with_variable )
85
+ html = ('<h3>help_with_variable function</h3><br>'
86
+ 'The help comes from a variable.' )
87
+ self .assertEqual (self .help_with_variable .helpText (), html )
88
+
89
+ QgsExpression .registerFunction (self .help_with_docstring )
90
+ html = ('<h3>help_with_docstring function</h3><br>'
91
+ 'The help comes from the python docstring.' )
92
+ self .assertEqual (self .help_with_docstring .helpText (), html )
93
+
71
94
def testAutoArgsAreExpanded (self ):
72
95
function = self .expandargs
73
96
args = function .params ()
0 commit comments