R2018a functionSignatures.json (user function tab complete) not working as documented outside of live-script

조회 수: 11 (최근 30일)
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
Ken Atwell
Ken Atwell 2018년 8월 14일
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.
Rik
Rik 2018년 8월 14일
Thanks a lot, I just tested it on R2017b, and it seems to work as intended. I would suggest changing the default display name of Name,Value pairs to "Name,Value", instead of "options". That would have removed a lot of ambiguity for me, and also automatically solves the problem of two definitions merging in the display when one is named "options". (I have just file a feature request to that effect)
If you move one of your comments to the answer section I can mark it as accepted answer, thank you for your time.

댓글을 달려면 로그인하십시오.

채택된 답변

Ken Atwell
Ken Atwell 2018년 8월 14일
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개)

카테고리

Help CenterFile Exchange에서 JSON Format에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by