How to Make Function Help Stings (not functionSignatures.json)

Hello,
I am wondering if it is possible to achieve function help strings like there are for MATLAB builtins.
For example, in the editor (not the command prompt) if I start typing "pl" then I get a drop down list of autocompletes that list the following
plot 2-D line plot
plot3 3-D point or line plot
place pole placement design
plus add numbers, append stirngs
etc.
My question is, lets say I have myfunc.m. I know how to add some amount of auto-completion with functionSignatures.json. But I don't see in the .json file where I can specify the short descriptions (shown above for MATLAB builtins such "2-D line plot"). Is it possible?

 Accepted Answer

Hello,
I understand that you are looking for displaying function descriptions during tab auto-completion in MATLAB editor.
The task you want to achieve is possible and can be easily implemented in MATLAB with the “functionSignatures.json” file. You can add the “purpose” field into the JSON schema as shown below.
{
"myFunc": {
"inputs": [
{
"name": "inputArg1",
"kind": "required",
"type":["numeric"],
"purpose": "arg description"
}
],
"purpose": "Function Description"
}
}
The above schema adds auto-complete support for function “myFunc” which takes in a single input. Note that both the argument and function will have descriptions provided in the auto-complete window.
Please refer to the below documentation for more information regarding auto-completion of custom functions.
I hope this helps.

4 Comments

Thanks for the tip - however this is not working for me. I am using 2023a.
I tried adding the field as "purpose" and also as "description" since the validate json signatures complains that "purpose" is no longer used. Also this does not appear to be documented in the link you described above.
In either case thanks for the suggestion but I am not seeing this in the intellisense/auto-completion information. I tried inspecting some of MATLAB's builtin functionSignatures.json but nothing from there works either.
Just to reiterate - my expectation is I should be able to start typing the function name and I should get a drop down with a list of possible autocompletions and to the right of each one should be a short description of the function. For example when I do pl... I can see a suggested completion for plot that says "2-D line plot".
I'm not facing any issues in MATLAB R2023a when I add the "purpose" field. I've attached a screenshot where I've opened 3 files in editor which shows the autocomplete functionality in action. I've kept the "functionSignatures.json" in the same path as the matlab functions.
Okay so I now I am able to reproduce it as well but I had to create a clean directory containing just myfunc.m and a testing script.
Before I was trying to test it on some package code I was using that get's installed as an Add-On. The package is "packaged" as a toolbox and inside there I have a functionSignatures.json with functions referenced like "myPackage.myfunc{ ..." . Not sure if that makes a difference? I will experiement with it a bit more and see if I can get it to work correctly.
PS, somewhat related note. I noticed that Mathworks says to put functionSignatures.json at the root of the package code for it to work correctly. But in their own builtin files on my system I can see they store their own signature files in a "resources/" directory. I wonder if we can do that? Seems cleaner than just leaving it at the root.
Just a follow-up. I just tested this with a simple "mypack" containing "myfunc" and the description does not get parsed. That's a shame. I guess a limitation of MATLABs signature parser.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!