Closed H0R5E closed 1 year ago
Hi,
Given a function defined like so in a file test.m:
test.m
function bob = test bob = 1; disp("bob") end
In this case matlabdomain will generate a warning WARNING: [sphinxcontrib-matlabdomain] Unexpected function name: 'bob'. Expected 'test' in module ''.
WARNING: [sphinxcontrib-matlabdomain] Unexpected function name: 'bob'. Expected 'test' in module ''.
The tokens provided to the MatFunction class seem to be wrong for this case. I captured them as follows:
[(Token.Text.Whitespace, '\n'), (Token.Keyword, 'end'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ')'), (Token.Literal.String, '"bob"'), (Token.Punctuation, '('), (Token.Name.Builtin, 'disp'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ';'), (Token.Literal.Number.Integer, '1'), (Token.Text, ' '), (Token.Punctuation, '='), (Token.Text, ' '), (Token.Name, 'bob'), (Token.Text.Whitespace, '\n'), (Token.Name, 'test'), (Token.Text, ' '), (Token.Punctuation, '='), (Token.Text, ' '), (Token.Name.Function, 'bob')]
Note the (Token.Name.Function, 'bob') at the end.
(Token.Name.Function, 'bob')
When you include parentheses the tokens are correct:
function bob = test() bob = 1; disp("bob") end
[(Token.Text.Whitespace, '\n'), (Token.Keyword, 'end'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ')'), (Token.Literal.String, '"bob"'), (Token.Punctuation, '('), (Token.Name.Builtin, 'disp'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ';'), (Token.Literal.Number.Integer, '1'), (Token.Text, ' '), (Token.Punctuation, '='), (Token.Text, ' '), (Token.Name, 'bob'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ')'), (Token.Punctuation, '('), (Token.Name.Function, 'test')]
And also when you include a docstring:
function bob = test %bob bob = 1; disp("bob") end
[(Token.Text.Whitespace, '\n'), (Token.Keyword, 'end'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ')'), (Token.Literal.String, '"bob"'), (Token.Punctuation, '('), (Token.Name.Builtin, 'disp'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ';'), (Token.Literal.Number.Integer, '1'), (Token.Text, ' '), (Token.Punctuation, '='), (Token.Text, ' '), (Token.Name, 'bob'), (Token.Text.Whitespace, '\n'), (Token.Comment, '%bob'), (Token.Text.Whitespace, '\n'), (Token.Punctuation, ')'), (Token.Punctuation, '('), (Token.Name.Function, 'test')]
I've run these tests against the master branch. Any help would be greatly appreciated.
Best wishes,
Mat
Thanks for the detailed report. I'm away from my computer at the moment. I'll look into it as soon as I get back.
@joeced, I've offered a solution in #200
Hi,
Given a function defined like so in a file
test.m
:In this case matlabdomain will generate a warning
WARNING: [sphinxcontrib-matlabdomain] Unexpected function name: 'bob'. Expected 'test' in module ''.
The tokens provided to the MatFunction class seem to be wrong for this case. I captured them as follows:
Note the
(Token.Name.Function, 'bob')
at the end.When you include parentheses the tokens are correct:
And also when you include a docstring:
I've run these tests against the master branch. Any help would be greatly appreciated.
Best wishes,
Mat