-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
special indenting for functions without end #265
Comments
Now that is just ugly, why'd you want to do that? :) Are there some other tools that expect it to be like that? |
yes, I agree. I wonder if I can update this ticket to request a refined style to #255? in #255, I did not make it clear using the word "top-level" functions. What I really meant was the top-most (or main) function in each .m file, not all the subfunctions in the same unit. For example, my desired output looks like the following
essentially, my goal is to have access to two formatting features
let me know if you see these make sense - I am happy to update the ticket to reflect the desired formats. |
OK, thank you for the concrete example. I will see what I can do, but I am not getting a lot of time to work on MH these days; so it may take a while. |
@fangq your test contains a syntax error as far as I am aware (missing |
With function output = mainfun(input)
%
% docstring for mainfun
% copyright ...
% the main-function should be flattened without indentation
%
statement1;
statement2;
%% -------- local functions -------
% comment for relatively short localfun 1
function output = localfun1(input)
% local-functions, or functions with an "end" at the bottom should be indented
statement1;
statement2;
end
% comment for relatively short localfun 2
function output = localfun2(input)
% short comment on
statement1;
statement2;
end
end Isn't that exactly what you already need? |
@fangq I have added a test + config file that shows you can get precisely what you wrote above. https://github.com/florianschanda/miss_hit/tree/master/tests/style/issue_265_alternative_indent I am closing the ticket, but if I missed something please re-open! Sorry for not doing this sooner. |
thanks a lot for working on this feature! @florianschanda, MATLAB function does not require the closing your test result looks fine to me. if the primary function does have a matching a slightly more intuitive approach is to use the presence of the ending |
I didn't know the final end could be missing. I will add support for that. |
just to provide more info: if a function's so, both the following forms are acceptable, and they are equivalent
the above two forms are for local functions, it is different from the example code in your test, which is nested function, see their differences in https://www.mathworks.com/help/matlab/matlab_prog/types-of-functions.html for nested functions, one must explicitly write
both local and nested functions can appear in the same unit - in such a case, all
|
in a way, matlab's traditional indentation setting, which the
when the
would it be possible to use the following logic: when
|
This in this case (all or no ends) then it already works. I was super worried I missed a case ;) |
Describe the solution you'd like
This is a follow up to a previous issue #255. I would like to control the indentation of the docstring (the contiguous block of comments right below a function definition).
The current default setting is
I am wondering if the following is possible - if yes, how to achieve this? if not, would be nice to have a flag to control this doc string indentation
What kind of feature is this?
Your MATLAB/Octave environment
MISS_HIT component affected
Choose one or more of the below:
The text was updated successfully, but these errors were encountered: