Skip to content

Commit d21c51e

Browse files
authored
Merge pull request #78 from jabraham17/fix-operator-names
Fix signature regex to match more possible operator names
2 parents 42eeef9 + f60f18e commit d21c51e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Diff for: sphinxcontrib/chapeldomain/__init__.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
# (type, param, ref)
4747
)?
4848
([\w$.]*\.)? # class name(s)
49-
([\w\+\-/\*$\<\=\>\!]+) \s* # function or method name
49+
\s*?
50+
(
51+
(?:[\w$][\w$=]*)| # function or method name
52+
(?:[+*/!~%<>=&^|\-:]+) # or operator name
53+
) \s*
5054
(?:\((.*?)\))? # opt: arguments
5155
(\s+(?:const\s)? (?:\w+?)| # or return intent
5256
\s* : \s* (?:[^:]+?)| # or return type

Diff for: test/test_chapeldomain.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,11 @@ def test_with_all(self):
840840
('operator *(s: string, n: integral) : string', 'operator ', None, '*', 's: string, n: integral', ' : string', None),
841841
('inline operator string.==(param s0: string, param s1: string) param', 'inline operator ', 'string.', '==', 'param s0: string, param s1: string', ' param', None),
842842
('operator bytes.=(ref lhs: bytes, rhs: bytes) : void ', 'operator ', 'bytes.', '=', 'ref lhs: bytes, rhs: bytes', ' : void ', None),
843-
# can't handle this pattern, ":" is set as punctuation, and casts don't seem to be doc'd anyway
844-
# ('operator :(x: bytes)', 'operator ', None, ':', 'x: bytes', None),
843+
('operator :(x: bytes)', 'operator ', None, ':', 'x: bytes', None, None),
844+
('proc x: int', 'proc ', None, 'x', None, ': int', None),
845+
('proc x ref: int', 'proc ', None, 'x', None, ' ref: int', None),
846+
('proc foo.bar: int', 'proc ', 'foo.', 'bar', None, ': int', None),
847+
('proc foo.bar ref: int', 'proc ', 'foo.', 'bar', None, ' ref: int', None),
845848
]
846849
for sig, prefix, class_name, name, arglist, retann, where_clause in test_cases:
847850
self.check_sig(sig, prefix, class_name, name, arglist, retann, where_clause)

0 commit comments

Comments
 (0)