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

Napoleon reformulation does not get applied to MatProperty docstrings. #250

Closed
apozharski opened this issue Jul 3, 2024 · 1 comment · Fixed by #255
Closed

Napoleon reformulation does not get applied to MatProperty docstrings. #250

apozharski opened this issue Jul 3, 2024 · 1 comment · Fixed by #255

Comments

@apozharski
Copy link
Collaborator

apozharski commented Jul 3, 2024

Hello,
I recently ran into what is either a bug (or perhaps unsupported behavior). When using sphinx.ext.napoleon style inline docstrings for properties, for example:

classdef IAmAClass
    properties
        i_am_a_property % IAmAType: this property has a type in the comment
    end 
end

napoleon ignores the Type: rest of docstring syntax and does not correctly reformulate is with :type: IAmAType

My understanding of sphinx internals is certainly not complete but from digging around in pdb it seems like it is a combination of this line in MatInstanceAttributeDocumentor which sets the objtype as 'instanceattribute' and this line in sphinx.ext.napoleon.docstring where inline comments are only parsed for 'attribute', 'data', or 'property'. I see that the commented out import_object method used to "disguise" the instance attribute as 'attribute', and simply changing the class level objtype does fix this bug.

Reading through the rest of the codebase this does not seem to ever be used for anything internally however you likely have better insight whether this is simply a hack or a valid approach. From a high level it seems to me that the distinction between 'attribute' and 'instanceattribute' are moot in matlab unless one also wants to document dynamicprops added in the constructor.

Thanks for the really useful package!

@joeced
Copy link
Collaborator

joeced commented Jul 16, 2024

Thanks for the report. I think you are right, that we could simplify the number of documenters for MATLAB.
Do you have some Sphinx example I can add as a test?

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 a pull request may close this issue.

2 participants