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

Static methods in folder based classes #91

Closed
MartinK84 opened this issue May 11, 2019 · 1 comment
Closed

Static methods in folder based classes #91

MartinK84 opened this issue May 11, 2019 · 1 comment

Comments

@MartinK84
Copy link

When you have a folder based class all non static functions are automatically loaded and parsed from the folder. For static classes you, however, still have to define the functions header in the classes main file, the code itself can still be in a separate file. For this definition the static function the function keyword is not present and I think this is what causes the parsing to fail with an error.

Example matlab code:

classdef Test < handle
    %TEST Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
        Property1
    end
    
    methods
        function obj = Test(inputArg1,inputArg2)          
        end
    end
    
    methods(Static)
        out = StaticFunction();
    end
end

the error you get when building the documentation with auotmodule, autofunction or even autoclass:

WARNING: [sphinxcontrib-matlabdomain] Parsing failed in Classes.@Test.None. Expected "=".
/home/martin/Documents/MedPhys/MATLAB_MRI_Framework/Documentation/source/modules/fitting/concept.rst:5: WARNING: autodoc: failed to import class 'Test' from module 'Classes.@test'; the following exception was raised:
Traceback (most recent call last):
File "/home/martin/miniconda3/envs/mk_sphinx/lib/python3.6/site-packages/sphinxcontrib/mat_documenters.py", line 132, in import_object
obj = self.get_attr(obj, part)
File "/home/martin/miniconda3/envs/mk_sphinx/lib/python3.6/site-packages/sphinx/ext/autodoc/init.py", line 231, in get_attr
return autodoc_attrgetter(self.env.app, obj, name, *defargs)
File "/home/martin/miniconda3/envs/mk_sphinx/lib/python3.6/site-packages/sphinx/ext/autodoc/init.py", line 1444, in autodoc_attrgetter
return func(obj, name, *defargs)
File "/home/martin/miniconda3/envs/mk_sphinx/lib/python3.6/site-packages/sphinxcontrib/mat_types.py", line 413, in getter
attr = MatObject.matlabify('.'.join([self.package, name]))
File "/home/martin/miniconda3/envs/mk_sphinx/lib/python3.6/site-packages/sphinxcontrib/mat_types.py", line 139, in matlabify
return MatObject.parse_mfile(mfile, name, path) # parse mfile
File "/home/martin/miniconda3/envs/mk_sphinx/lib/python3.6/site-packages/sphinxcontrib/mat_types.py", line 185, in parse_mfile
return MatClass(name, modname, tks)
File "/home/martin/miniconda3/envs/mk_sphinx/lib/python3.6/site-packages/sphinxcontrib/mat_types.py", line 971, in init
if not meth.name.split('.')[0] in ['get', 'set']:
AttributeError: 'NoneType' object has no attribute 'split'

@joeced joeced closed this as completed in 88dee47 May 11, 2019
@joeced
Copy link
Collaborator

joeced commented May 11, 2019

Thanks for the report. The trailing semi-colon was the culprit.

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

No branches or pull requests

2 participants