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