Backward compatible functionSignatures.json
1 view (last 30 days)
I'm writing a toolbox (packaged as described here) and I want to
- use functionSignatures.json to provide autocomplete information for function signatures when using the toolbox in R2021b, and
- support versions of MATLAB going back to at least R2016b (possibly without autocomplete infomation).
I have written a functionSignatures.json file that works well on R2021b, but because changes between MATLAB versions of how functionSignatures.json works, the command line prints the following errors when it tries to suggest autocompletions on R2016b:
Unknown attribute "purpose" with value "Initial state"
Unknown kind value "ordered".
Clearly, this is because support for "kind":"ordered" the attribute "purpose" in functionSignatures.json was not added to till after R2016b.
Is there a way to gracefully handle differences in functionSignatures.json between R2016b and R2021b?
Rik on 5 Oct 2021
In that case my proposed solution would be implementing something like Jan suggested in his answer.
Write a function similar to this:
%Because a pref (getpref and setpref) can be slow on Octave, I prefer
%to save a txt or mat file with a flag in a folder. I use the function
%below to get the path.
Now you can write a RunPostInstall function that will write the correct JSON file (you might be interested in my ifversion function).
This setup has minimal overhead, as it will only go to disk once to see if the file exists. If you put a call to this same function in every entry function of your toolbox, the same persistent variable will apply to every call.