Tip: Add documentation for user-defined functions

3.41K viewsScripting
0

A while ago Simon was asking about adding documentation for functions in user-defined function sets, so that it would appear in the functions tab when editing formulas. This functionality is available as of 4.0.46. Here’s how it works:

[quote:1sxqnni6]The [b:1sxqnni6]@FunctionDoc[/b:1sxqnni6] annotation can be used to decorate a scripted function with documentation, which will appear in the Functions tab when the function is selected.

The syntax of [b:1sxqnni6]@FunctionDoc[/b:1sxqnni6] is as follows:

[code:1sxqnni6]
@FunctionDoc(description=”[I]description[/I]”,
argNames=[”[I]arg1[/I]”, “[I]arg2[/I]”, ...],
argDocs = [”[I]doc1[/I]”, “[I]doc2[/I]”, ...])
[/code:1sxqnni6]

[b:1sxqnni6]@FunctionDoc[/b:1sxqnni6] must precede a method declaration in a function set. All elements are optional. When the documentation is displayed, [i:1sxqnni6]arg1[/i:1sxqnni6] will be paired with [i:1sxqnni6]doc1[/i:1sxqnni6], [i:1sxqnni6]arg2 [/i:1sxqnni6]with[i:1sxqnni6] doc2[/i:1sxqnni6], and so forth. If argNames has more items than argDocs, names will be displayed without descriptions for the extra arguments. If argDocs has more items than argNames, the extra descriptions will be ignored.[/quote:1sxqnni6]

Latest Questions