Skip to content

[FIX] fixes root m file processing#315

Draft
jasonnicholson wants to merge 11 commits into
sphinx-contrib:masterfrom
jasonnicholson:fix-root-m-file-processing
Draft

[FIX] fixes root m file processing#315
jasonnicholson wants to merge 11 commits into
sphinx-contrib:masterfrom
jasonnicholson:fix-root-m-file-processing

Conversation

@jasonnicholson
Copy link
Copy Markdown
Contributor

This addresses files in the root of matlab_src_dir. The following will now work:

.. mat:autofunction:: myFunction
.. mat:autoscript:: myScript
.. mat:autoclass:: myClass
    :show-inheritance:
    :members:

This one documents everything in the global namespace in matlab_src_dir:

.. mat:automodule:: .

@Remi-Gau Remi-Gau changed the title [Fix] fixes root m file processing [FIX] fixes root m file processing Jan 3, 2026
Comment thread sphinxcontrib/mat_types.py Outdated
Comment thread sphinxcontrib/mat_types.py Outdated
Comment thread sphinxcontrib/mat_types.py Outdated
@Remi-Gau
Copy link
Copy Markdown
Collaborator

Remi-Gau commented Jan 3, 2026

just to be sure: there was no issue for this, right?

arguments = argblock_match.get("args")

# Bug fix: Check if arguments is None before iterating
if arguments is None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be necessary? The * operator in q_argblock should return the empty list for the args capture name.

Either way this shouldn't hurt to add but would be good to add a test for this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also probably no need to have Bug fix in the comment, as it only adds semantic noise.

if not modname:
modname = self.env.temp_data.get("mat:module")
# ... else, it stays None, which means invalid
# ... else, default to root module (empty string)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, is this always a sane default? I suspect that this can lead to subtle bugs where things that were considered invalid before will now get dumbed in the "root" module.

# for implicit module members, check __module__ to avoid
# documenting imported objects
return True, self.object.safe_getmembers()
members = self.object.safe_getmembers()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to declare the local variable here.

@jasonnicholson
Copy link
Copy Markdown
Contributor Author

just to be sure: there was no issue for this, right?

No, there was no GitHub issue.

The unreleased version doesn't handle m-files in the root well. The previous version struggled too, but there was a workaround setting .. mat:currentmodule:: . before using .. mat:auto<qualifier>:: thing.

Co-authored-by: Remi Gau <remi_gau@hotmail.com>
@jasonnicholson jasonnicholson force-pushed the fix-root-m-file-processing branch from 759c14c to 28f6c63 Compare January 4, 2026 23:04
@jasonnicholson jasonnicholson marked this pull request as draft January 4, 2026 23:04
@jasonnicholson
Copy link
Copy Markdown
Contributor Author

I see that @Remi-Gau is making direct changes to the master branch solo. I will wait till he is finished and then work on this branch.

@Remi-Gau
Copy link
Copy Markdown
Collaborator

@jasonnicholson I will fix the merge conflicts

@jasonnicholson
Copy link
Copy Markdown
Contributor Author

@jasonnicholson I will fix the merge conflicts

Thank you

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants