- Be sure that the functionSignatures.json is in the same folder as where your WMB function is located.
- If you have just created this file, you may need to restart MATLAB before it becomes visible. After the restart, you should be able to subsequently update the file without a restart.
R2018a functionSignatures.json (user function tab complete) not working as documented outside of live-script
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Rik
am 9 Aug. 2018
Beantwortet: Ken Atwell
am 14 Aug. 2018
In a recent thread, I came across a mention of a new feature in R2018a: tab completion suggestions for user-defined functions. (release notes link to this feature)
I applaud this development. I know I am not the only one complaining that it didn't already exist. So I immediately tried to check it out. I used the guide linked in the release notes, which states: "To experiment with code suggestions, start to call the function from a live script and observe the suggestions."
That suggests that it's also possible to use this outside of live scripts, but they just suggest you use that. I don't appear to be the only one thinking that, as suggested by Sean de Wolski: "While I can't talk about the future, if you look at 18a, there is new infrastructure for adding function signatures for code complete/suggest especially in regards to the live editor."
But I failed to get it to work. In the normal editor I only got the normal header-derived hint, and in the live script I could only get a single input type, instead of the two included in my JSON file. What am I doing wrong? Or is the feature not yet at the level the documentation has us believe? Is this a bug that I should report (there aren't any about this yet)?
(Function header, result in live script, and JSON file below and in zip)
function outfilename=WBM(filename,url_part,varargin)
% syntax:
% outfilename=WBM(filename,url_part)
% outfilename=WBM(___,options)
% outfilename=WBM(___,Name,Value)
.
{
"WBM":
{
"inputs":
[
{"name":"filename", "kind":"required", "type":["char"],
"purpose":"Target file name"},
{"name":"url_part", "kind":"required", "type":["char"],
"purpose":"URL of the file/website"},
{"name":"options", "kind":"ordered", "type":["struct"],
"purpose":"Struct containing the options"}
]
},
"WBM":
{
"inputs":
[
{"name":"filename", "kind":"required", "type":["char"],
"purpose":"Target file name"},
{"name":"url_part", "kind":"required", "type":["char"],
"purpose":"URL of the file/website"},
{"name":"date_part", "kind":"namevalue", "type":["char"],
"purpose":"Partial or complete date of the capture"},
{"name":"tries", "kind":"namevalue", "type":["numeric","numel=3"],
"purpose":"Number of times a [load,save,timeout] is allowed"},
{"name":"verbose", "kind":"namevalue", "type":["numeric","scalar","integer"],
"purpose":"The amount of text displayed"},
{"name":"m_date_r", "kind":"namevalue", "type":["char", "choices={'ignore','warning','error'}"],
"purpose":"Missing date response"},
{"name":"response", "kind":"namevalue", "type":["char"],
"purpose":"Cell with responses"},
{"name":"ignore", "kind":"namevalue", "type":["char"],
"purpose":"HTML error codes to be ignored"}
]
}
}
6 Kommentare
Ken Atwell
am 14 Aug. 2018
Yes, you can see multiple signatures. In your specific case, you would if you rename your "options" argument to something else, say "optionsStruct". You currently see only one line because you'd otherwise get two identical-looking signatures... hardly helpful.
Akzeptierte Antwort
Ken Atwell
am 14 Aug. 2018
See the "comments" section for more discussion. In this particular case, the use of the argument name "options" is making the display a little ambiguous, since "options" is also generically used as the name for trailing name/value pairs (and, more rare, trailing flags).
In R2018a specifically, JSON definitions are use to display:
- Function hints and suggested completions in the Live Editor
- Tab-completion only in the command window and plain-text editor. Function hints still use older facilities.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu JSON Format finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!