MATLAB Answers

12

How to implement function hints in your code

Asked by D. Plotnick on 1 May 2017
Latest activity Commented on by Jan Rubak on 17 Mar 2019
I have seen that this has been asked previously, but never answered, and I want to know if this should go in as a feature request or if the capability is just not obvious.
When one starts typing e.g. 'plot(' and then waits, a series of suggested completions pops up. If I try this on my own code, it simply bases the suggestion on the top line. An abstract MWE example:
function out = foo(in, varargin)
p = inputParser;
addParameter(p,'mult',2)
parse(p,varargin{:})
out = in*p.Results.mult;
end
The function hint for this is 'foo(in,...)'.
Now, if I have a large number of possible inputs (similar to plot), I instead want the function hint to display some custom combinations of possible inputs as opposed to the single line based on the function definition. Preferably this would be based directly off of the comment header in the function file, although I could see it using an external file as well. This would be extremely helpful for building toolkits for other users.
Is this now possible? If not, I will submit it as a feature request.
Cheers, -Dan

  1 Comment

Rik
on 1 May 2017
This is indeed an interesting question. (this comment is mostly to get in on my watch list)

Sign in to comment.

1 Answer

Answer by Kevin Gleason on 4 May 2017
 Accepted Answer

As of MATLAB R2017a, this feature is not available.
I have submitted a feature request on your behalf. The development team is aware of the issue and may consider adding it in a future release.

  4 Comments

Show 1 older comment
As of release R2018a you can create a file that MATLAB will use to provide tab completions and function hints.
Great! Thanks a lot!
Hi Steven,
In R2018a, user-defined function hints via functionSignature.json is supported for Live Scripts, but not (yet) at the standard command line or during code editing.
I don't see any mention in the R2018b release notes that this has changed.
Am I correct in understanding that this will be coming in a (near-) future release, but that it's just not yet ready for primetime? Without any promises implied, are you able to say what the approximate time frame may be?
I'm very grateful that you're adding this, and am happy to wait if that's what's required for it to be properly implemented. But knowing if/when it is coming helps me decide whether I should invest time setting up the json file for code which will mostly be called from other code or from the command line rather than a Live Script.
Cheers, Jan

Sign in to comment.