sphinx-contrib / matlabdomain

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

Quote is not recognized as transpose after a closing curly brace #108

Closed denisrosset closed 4 years ago

denisrosset commented 4 years ago

I get a few warnings:

WARNING: [sphinxcontrib-matlabdomain] Parsing failed in +replab.SedumiData. Check if valid MATLAB code.
WARNING: [sphinxcontrib-matlabdomain] Parsing failed in +replab.CommutantVar. Check if valid MATLAB code.
WARNING: [sphinxcontrib-matlabdomain] Parsing failed in +replab.RepByImages. Check if valid MATLAB code.

and those files are valid MATLAB code. How can I get the line number where the parsing fails?

Attached the three files that can't be parsed.

src.zip

joeced commented 4 years ago

Unfortunately I cannot print the line number currently. The MATLAB source is parsed into tokens (with no knowledge of position).

In your examples I looked at CommuntVar and in the constructor there seems to be a mismatch in the with the number of ends. It simply runs out of "tokens". I haven't found where it is though.

denisrosset commented 4 years ago

I found a minimal test case for that bug:

classdef CommutantVar
    methods
        function self = CommutantVar
            A{i} = (A{i} + A{i}.')/2;
            A{i} = (A{i} + A{i}')/2;
        end
    end
end

which I guess is related to the lexing/parsing of single quote characters.

denisrosset commented 4 years ago

For some reason, the above code is not parsed correctly from Sphinx after the correction, but is parsed successfully when calling directly MatlabLexer and MatClass from a Python 3 REPL. And tests fail after the change?

denisrosset commented 4 years ago

See also the Matlab TM syntax where this was discussed ( https://github.com/mathworks/MATLAB-Language-grammar/issues/10 ). The current regexp is: ((?<=[^\s])|(?<=\])|(?<=\))|(?<=\}))'

joeced commented 4 years ago

Thanks a lot for the contribution. I'll make a new release tonight when I'm home.

denisrosset commented 4 years ago

@joeced as mentioned above, tests are failing and I'm at a loss to explain why!