miss_hit icon indicating copy to clipboard operation
miss_hit copied to clipboard

Docstring format enforcer and generator

Open jand271 opened this issue 3 years ago • 9 comments

What kind of feature is this?

  • New feature in MISS_HIT

MISS_HIT component affected Choose one or more of the below:

  • Style checker

Describe the solution you'd like Mathworks provides a system to read help doc strings for functions.

It would be nice if miss_hit would enforce the following in my continuous integration workflow: (1) every function and class has a docstring (2) every function and class has a docstring compatible with the Matlab help feature.

In addition, it would be nice to miss_hit included a function to autogenerate those doc strings (including variable arguments, e.g., via the arg parser functions).

I can't seem to find a good tool online that do the above. Apologies if I didn't look hard enough.

jand271 avatar Apr 20 '21 08:04 jand271

Right. This sounds like a reasonable feature request :)

I think the most likely place this check will go into is MH Lint, since a missing docstring is not something that can be fixed automatically. Checking that the docstring in question conforms to some established pattern will also be a MH Lint check (we do a limited form of that already on copyright notices).

As to auto-generating the docstring, that is something I could consider later but right now I can't do it for technical reasons. Specifically to understand parameter types and deciphering varargs will require some form of semantic analysis. This work is planned (as it will be super important to stronger analysis in MH Lint) but quite complex, so please don't expect anything done on that front in the short-term.

florianschanda avatar Apr 29 '21 09:04 florianschanda

Oh, and sorry for not replying sooner. I have a mad busy few weeks for now so did not find much time to look at github :)

florianschanda avatar Apr 29 '21 10:04 florianschanda

np....very busy here in grad school rn. Your tool is helping me enforce good coding practices for the undergraduate researchers coding for me. Thanks you!

Any automated doc string enforcement would be amazing!

jand271 avatar May 03 '21 04:05 jand271

Ah yes, getting students to indent, I remember that problem ;) Teach them Python it fixes that particular problem XD

florianschanda avatar May 03 '21 05:05 florianschanda

well I have always used the ctrl + a ctrl + i shortcuts of matlab IDE to do the indent for me. :smile:

now I just need to make sure the setting is the same as for MISS_HIT.

Remi-Gau avatar May 03 '21 06:05 Remi-Gau

Lol, I do most of my Matlab dev in sublime...I added mh to my sublime builder via ⌘B.

jand271 avatar May 06 '21 08:05 jand271

Do you think this could make the next release?

jand271 avatar May 11 '21 07:05 jand271

Also, this ST package makes context-aware Matlab doc autogeneration. Might be useful start for mh.

https://packagecontrol.io/packages/AutoMatlab

jand271 avatar May 11 '21 07:05 jand271

That is a good pointer, thanks

florianschanda avatar May 13 '21 11:05 florianschanda