-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement a parser for our Matlab functions' documentation #19
Comments
closing because duplicate of #17 |
Originally posted by @jcohenadad in #17 (comment) Now, regarding the "other" issue, i.e., parsing the header to change the output format for writing the .md file. Following on #17 (comment), i think it will take more than regexprep to address the issue. For example, one thing that needs to be done:
to there:
it would be nice to implement that feature in HelpDocMd. |
I implemented a Here's what the Matlab documentation looks like:
And the returned structure contains the fields:
Though I'm still not statisfied with the parser for 2 main reasons:
I think there are many other defaults in the code but it might be a good start with some useful parsing Matlab features that I found. The next step is to find a way to reorganize that structure as a .md file. |
Looks promising! Indeed, ensuring adherence to the template could be a bit tricky... Ideally Matlab would just do all of this for us 👎 :( Alternatively, we could consider functionalizing the writing of the header itself: i.e. rather than manually copying/editing the template, the author actually declares the sections/content as string variables to be passed to a function—or class methods—which then checks everything required is indeed there, formats everything as desired, and returns the text and/or copies it to the clipboard (
Might be sufficiently weird that everyone would be put off from using it... but maybe not—manually formatting the text in the editor is actually kind of a hassle. (just an idea) |
terrific work @gaspardcereza! i suggest
|
i love the idea. My biggest concern would be that the 'help' inside the command window would be lost then, right? |
#17 would address (part of) it, right? |
I was thinking this would just be a utility to help fill the template — i.e. the user still pastes the output into their file once they're done. #17 would, indeed, be an alternative (at least for filling out the basic stuff, like argument names, types, defaults—a human still needs to fill in the description). But I see this as being a lot more work—a utility I wish Matlab just supplied, since for now pretty much all you can get in terms of info is |
ah! i misunderstood. I thought you suggested to replace the header by this code 😅. Hum, to be honest i think we can trust people to do a decent job of copy/pasting/replacing from the template. Also, the suggested utility would only be used when creating a function, whereas many times, the code is being updated (arguments added/removed/modified), so the utility function could not be used during those events.
actually, i was thinking of using #17 not for the filling basic stuff but during CI. I.e.: the match between the arguments (code) and what's in the docstrings would be continuously verified by our CI. That will ensure a healthy codebase and no mismatch at all. |
i figure if we could already validate the doc, we'd already be in a position to have matlab generate it (minus descriptions) 🙏 |
Is there a specific folder where we usually put the unit tests ? |
for inspiration: https://github.com/shimming-toolbox/shimming-toolbox/tree/master/tests |
funny: i recall a similar conversation ~1 year ago, where positions were inverted and i was the one pushing for not manually filling info in the headers because people make mistakes and it should be done manually. One year later, after digging a bit into Mathworks capabilities, i turned (very) pessimistic about the whole thing. I would suggest to wait before doing this auto-fill because:
|
To be sure, as MATLAB isn't strongly-typed, allows variable inputs/outputs (e.g. |
Context
We are currently trying to define how to document our functions within the Matlab code. We also wan to gather all these descriptions on our website.
Problem
What looks good in the Matlab code isn't always visually satisfying once on the website (and vice-versa).
Solution
Parsing the Matlab code to gather all the useful information (description, syntax, inputs, outputs...) as structures or class object that will then be used for the website's generation (and displayed as we want).
Playing with the parser will also help us defining what could be the best convention for documenting our functions (related to this issue).
Feel free to comment if you have ideas, advice or anything...
The text was updated successfully, but these errors were encountered: