Skip to content
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

Autoapplication directive does not document source code #132

Open
QTBdev opened this issue Apr 15, 2022 · 5 comments
Open

Autoapplication directive does not document source code #132

QTBdev opened this issue Apr 15, 2022 · 5 comments

Comments

@QTBdev
Copy link

QTBdev commented Apr 15, 2022

Hello,

Autoapplication directive does not document the application source code, as only the metadata files are read by the parse_mlappfile function.

I understand that this limitation is most probably due to the fact that the source code is stored in a .mat file inside the .mlapp archive, instead of the usual .m file, and that reading a .mat file outside matlab is not a simple task.

Still I wanted to make this info show up on the project somewhere because I spent a good amount of time trying to understand why it wouldn't autodocument my application.

@joeced
Copy link
Collaborator

joeced commented Apr 20, 2022

Hi

I haven't used App Designer myself, so I would like to know what extra information that you need from the file? Could you share a simple App and what you expect to be documented?

@QTBdev
Copy link
Author

QTBdev commented Apr 20, 2022

Hello,

Of course, you will find attached an archive containing :

  • A simple application example
  • A class created by copy-pasting the whole application source code into a brand new .m file
  • And the sphinx generated documentation of both of them

I expected autoapplication to document the application just like autoclass documents the class created with the exact same source code, but the parse_mlappfile function does not look into the file that contains the application source code
autoapplicationTest.zip
.

@joeced
Copy link
Collaborator

joeced commented Apr 21, 2022

Thanks for the example! I think I found a way to get the documentation you expected. As the mlapp file is just a ZIP-file, I examined every file in there.

In <root>/matlab/document.xml there is a verbatim copy of the code that is used in the App. We can extract that, and parse it, and then we should be able to get the documentation you want.

@QTBdev
Copy link
Author

QTBdev commented Apr 21, 2022

That would be great ! I knew the application source code was stored in <root>/appdesigner/appModel.mat, but I didn't realise a copy was also available in this file

@joeced
Copy link
Collaborator

joeced commented Mar 15, 2023

I took a look at it, and frankly I'm not sure how to proceed exactly.

In the parse_mlappfile function in mat_types.py I can extract the MATLAB code with:

with ZipFile(mlappfile, "r") as mlapp:
    document = ET.fromstring(mlapp.read("matlab/document.xml"))

documentNs = {"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main"}
documentDesc = document.find(".//w:t", documentNs)

Then documentDesc will contain a verbatim copy of your MATLAB code in the app.
However, most of this is private methods, even the callbacks. So you would end
up with a ton of noise, and very little information.

If anyone has a good idea on how to present this, then please provide a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants