Sunday, 12 May 2019

Documenting custom Python functions in QGIS


How can I document my custom Python functions in QGIS?


I would like to offer users help for functions I wrote for them:


enter image description here


I've tried adding a docstring:


enter image description here


But whenever I click Load an error message is displayed:


enter image description here


The error message clearly shows an indentation error, which does not correspond to my actual code.




Answer



What you are doing is the correct way to document your custom function.
The error you are encountering is because by default when you write a function in the Function Editor, the indentation before the return statement is that of 4 spaces characters and not 'tab space'. Just check if that is the case. The indentation should be consistent (either only spaces or tab space).


No comments:

Post a Comment