Space after keyword properties or methods
anaselfathi opened this issue · comments
For classes, it seems that the convention used by Matlab is to leave a space between properties
(or methods
) and the optional access arguments. Example:
properties (GetAccess = public, SetAccess = public)
end
Instead of
properties(GetAccess = public, SetAccess = public)
end
This is not the behavior of MBeautifier.
Ressource:
https://www.mathworks.com/help/matlab/matlab_oop/developing-classes-typical-workflow.html
What I could imagine is a "keyword padding" rule. At the moment, not only properties
and methods
behave like this, but also if(true)
or while(index < 100)
is formatted the same way. It may be also considerable to introduce a new rule group, similar to "operator padding": "keyword padding", where for every single keyword (where it makes sense) the same padding rules could be applied - takes a bit of time to implement though.
Just a note about if
and while
I think the convention is to not put parentheses at all. see here:
https://www.mathworks.com/help/matlab/ref/if.html
https://www.mathworks.com/help/matlab/ref/while.html
If you ask my opinion I think a better default behavior for MBeautifier
would be to remove the extra parenthesis for if
and while
.
For now, I am using my fix anaselfathi@caed57f that might be considererd as a patch.
Thanks for your quick reply.
I don't think that Matlab conventions should be followed all the time. If you investigate some M files in the Matlab installation directory, they are really far away from readable, and badly formatted (for example from iskeyword
: nargin==0
:) ). Also, the convention should be defined by the configuration - that's why I proposed that way. E.g. if (true), disp(2); end
for me looks much better than if(true), disp(2); end
- as in the convention for Java (or for Kotlin as it is my primarily used language).
Anyways, it's a good suggestion, thanks for it. I will think about a good, flexible solution for it.
It has been implemented together with other keywords.