sphinx-contrib / matlabdomain

A Sphinx extension for documenting Matlab code
http://sphinxcontrib-matlabdomain.readthedocs.io/
Other
70 stars 45 forks source link

Static methods in folder based classes #91

Closed MartinK84 closed 5 years ago

MartinK84 commented 5 years ago

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 commented 5 years ago

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