sphinx-contrib / matlabdomain

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

.. autoclass:: failing if a method uses a string with "%" #87

Closed ludovicsteinbach closed 5 years ago

ludovicsteinbach commented 5 years ago

It seems that .. autoclass:: fails to document a class if one of the method uses sprintf and a formatSpec that includes a '%' character.

Class definition

classdef whatever
    %WHATEVER Summary of this class goes here
    %   Detailed explanation goes here

    properties
        Property1
    end

    methods
        function obj = whatever(inputArg1)
            %WHATEVER Construct an instance of this class
            %   Detailed explanation goes here
            obj.Property1 = sprintf("%d",inputArg1);
        end

        function outputArg = method1(obj,inputArg)
            %METHOD1 Summary of this method goes here
            %   Detailed explanation goes here
            outputArg = obj.Property1 + inputArg;
        end
    end
end

rst .. autoclass:: whatever

Error sphinx-err-w_6f0dvv.log

joeced commented 5 years ago

I tried running this on my own machine, where it doesn't fail. Can you provide a list with version numbers of installed modules, something like pip list.

Edit1: It does actually fail, but not exactly as you described. The %s in the sprintf( function call, turns the rest of the line into a comment. This results in us missing the rest of the methods.

Edit2: Link to Pygments highlighting http://pygments.org/demo/6783196/

Edit3: A quick fix, is to use single quotes for strings instead of double quotes.

joeced commented 5 years ago

Fixed in https://github.com/sphinx-contrib/matlabdomain/commit/abb5c34f44399a87f35447818aca2cd3173667d4.

I just pushed an update, fixing the parsing of strings in double quotes. I'll prepare a new release tonight.