Skip to content

Commit a86ae64

Browse files
authored
Fix issue with parsing of MATLAB files. (#234)
1 parent 2fc26b2 commit a86ae64

File tree

12 files changed

+84
-21
lines changed

12 files changed

+84
-21
lines changed

CHANGES.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
sphinxcontrib-matlabdomain-0.21.3 (2024-01-02)
2+
==============================================
3+
4+
* Fix issue with parsing of MATLAB files, where keywords were used in ``struct``
5+
fieldnames. E.g. ``a = pkg.arguments``. These were mistaken as ``keyword``
6+
tokens and could result in warnings with ``Check if valid MATLAB code.``.
7+
* Bump copyright to 2024.
8+
19
sphinxcontrib-matlabdomain-0.21.2 (2023-12-17)
210
==============================================
311

CITATION.bib

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ @software{jorgen_cederberg_2023_7747374
1616
Marc-Henri Bleu-Laine and
1717
Nikolaas N. Oosterhof and
1818
ptitrex},
19-
title = {sphinx-contrib/matlabdomain: 0.21.1},
20-
month = dec,
21-
year = 2023,
19+
title = {sphinx-contrib/matlabdomain: 0.21.2},
20+
month = jan,
21+
year = 2024,
2222
publisher = {Zenodo},
23-
version = {0.21.1},
23+
version = {0.21.2},
2424
doi = {10.5281/zenodo.7746009},
2525
url = {https://github.com/sphinx-contrib/matlabdomain}
2626
}

LICENSE

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
If not otherwise noted, the extensions in this package are licensed
2-
under the following license.
1+
License for sphinxcontrib-matlabdomain
2+
======================================
33

4-
Copyright (c) 2009 by the contributors (see AUTHORS file).
5-
All rights reserved.
4+
Unless otherwise indicated, all code in the sphinxcontrib-matlabdomain project
5+
is licenced under the two clause BSD licence below.
6+
7+
Copyright (c) 2009-2024 by the sphinxcontrib-matlabdomain team (see AUTHORS
8+
file). All rights reserved.
69

710
Redistribution and use in source and binary forms, with or without
811
modification, are permitted provided that the following conditions are
@@ -19,7 +22,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1922
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2023
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2124
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2326
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2427
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2528
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY

sphinxcontrib/mat_directives.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
"""
2+
sphinxcontrib.mat_directives
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
5+
Extend autodoc directives to matlabdomain.
6+
7+
:copyright: Copyright 2014-2024 by the sphinxcontrib-matlabdomain team, see AUTHORS.
8+
:license: BSD, see LICENSE for details.
9+
"""
10+
111
from sphinx.ext.autodoc.directive import (
212
AutodocDirective,
313
DummyOptionSpec,

sphinxcontrib/mat_documenters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
sphinxcontrib.mat_documenters
43
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
54
65
Extend autodoc directives to matlabdomain.
76
8-
:copyright: Copyright 2014 Mark Mikofski
7+
:copyright: Copyright 2014-2024 by the sphinxcontrib-matlabdomain team, see AUTHORS.
98
:license: BSD, see LICENSE for details.
109
"""
10+
1111
from .mat_types import ( # noqa: E401
1212
MatModule,
1313
MatObject,

sphinxcontrib/mat_lexer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
pygments.lexers.matlab
43
~~~~~~~~~~~~~~~~~~~~~~
@@ -288,7 +287,8 @@ class MatlabLexer(RegexLexer):
288287
"try",
289288
"while",
290289
),
291-
suffix=r"\b",
290+
prefix=r"(?<!\.)(",
291+
suffix=r")\b",
292292
),
293293
Keyword,
294294
),

sphinxcontrib/mat_parser.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# -*- coding: utf-8 -*-
21
"""
3-
Functions for parsing MatlabLexer output.
2+
sphinxcontrib.mat_parser
3+
~~~~~~~~~~~~~~~~~~~~~~~~
44
5-
:copyright: Copyright 2023 Jørgen Cederberg
6-
:license: BSD, see LICENSE for details.
5+
Functions for parsing MatlabLexer output.
6+
7+
:copyright: Copyright 2023-2024 by the sphinxcontrib-matlabdomain team, see AUTHORS.
8+
:license: BSD, see LICENSE for details.
79
"""
810

911
import re

sphinxcontrib/mat_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
sphinxcontrib.mat_types
43
~~~~~~~~~~~~~~~~~~~~~~~
54
65
Types for MATLAB.
76
8-
:copyright: Copyright 2014 Mark Mikofski
7+
:copyright: Copyright 2014-2024 by the sphinxcontrib-matlabdomain team, see AUTHORS.
98
:license: BSD, see LICENSE for details.
109
"""
10+
1111
from io import open # for opening files with encoding in Python 2
1212
import os
1313
from copy import copy

sphinxcontrib/matlab.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# -*- coding: utf-8 -*-
21
"""
32
sphinxcontrib.matlab
43
~~~~~~~~~~~~~~~~~~~~
54
65
The MATLAB domain.
76
8-
:copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
7+
:copyright: Copyright 2014-2024 by the sphinxcontrib-matlabdomain team, see AUTHORS.
98
:license: BSD, see LICENSE for details.
109
"""
10+
11+
1112
from . import mat_documenters as doc
1213
from . import mat_directives
1314
from . import mat_types
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
classdef ClassWithKeywordsAsFieldnames
2+
% Class that uses keywords as fieldnames, i.e preceeded by a dot and not
3+
% followed by a word break.
4+
properties
5+
a
6+
b
7+
c
8+
end
9+
10+
methods
11+
function obj = ClassWithKeywordsAsFieldnames()
12+
% In MATLAB you can use `keywords` as fieldnames.
13+
obj.a = pkg.arguments.end;
14+
obj.b = pkg.otherwise.if;
15+
obj.c = pkg.persisent.try.while;
16+
end
17+
18+
function d = calculate(obj)
19+
% Returns the value of `d`
20+
d = obj.a + obj.b + obj.c;
21+
end
22+
end
23+
end

0 commit comments

Comments
 (0)