Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update help text and template
  • Loading branch information
YoannQDQ committed Apr 29, 2023
1 parent 947931a commit c8bb641
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions python/user.py
Expand Up @@ -66,8 +66,8 @@ def load_user_expressions(path):
template = """from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='Custom', referenced_columns=[])
def my_sum(value1, value2, feature, parent):
@qgsfunction(group='Custom', referenced_columns=[])
def my_sum(value1, value2):
\"\"\"
Calculates the sum of the two parameters value1 and value2.
<h2>Example usage:</h2>
Expand Down
18 changes: 7 additions & 11 deletions src/gui/qgsexpressionbuilderwidget.cpp
Expand Up @@ -209,26 +209,20 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
mFunctionBuilderHelp->setReadOnly( true );
mFunctionBuilderHelp->setText( tr( "\"\"\"Define a new function using the @qgsfunction decorator.\n\
\n\
The function accepts the following parameters\n\
Besides its normal arguments, the function may specify the following arguments in its signature\n\
Those will not need to be specified when calling the function, but will be automatically injected \n\
\n\
: param [any]: Define any parameters you want to pass to your function before\n\
the following arguments.\n\
: param feature: The current feature\n\
: param parent: The QgsExpression object\n\
: param context: If there is an argument called ``context`` found at the last\n\
position, this variable will contain a ``QgsExpressionContext``\n\
object, that gives access to various additional information like\n\
expression variables. E.g. ``context.variable( 'layer_id' )``\n\
: param context: ``QgsExpressionContext`` object, that gives access to various additional information like\n\
expression variables. E.g. ``context.variable( 'layer_id' )``\n\
: returns: The result of the expression.\n\
\n\
\n\
\n\
The @qgsfunction decorator accepts the following arguments:\n\
\n\
\n\
: param args: Defines the number of arguments. With ``args = 'auto'`` the number of\n\
arguments will automatically be extracted from the signature.\n\
With ``args = -1``, any number of arguments are accepted.\n\
: param group: The name of the group under which this expression function will\n\
be listed.\n\
: param handlesnull: Set this to True if your function has custom handling for NULL values.\n\
Expand All @@ -238,7 +232,9 @@ QgsExpressionBuilderWidget::QgsExpressionBuilderWidget( QWidget *parent )
feature.geometry(). Defaults to False.\n\
: param referenced_columns: An array of attribute names that are required to run\n\
this function. Defaults to [QgsFeatureRequest.ALL_ATTRIBUTES].\n\
\"\"\"" ) );
: param params_as_list : Set this to True to pass the function parameters as a list. Can be used to mimic \n\
behavior before 3.32, when args was not \"auto\". Defaults to False.\n\
\"\"\"" ) );
}


Expand Down

0 comments on commit c8bb641

Please sign in to comment.